setting.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view>
  3. <u-navbar
  4. title="设置"
  5. title-color="#fff"
  6. :custom-back="customBack"
  7. :border-bottom="false"
  8. back-icon-color="#CCE8FF"
  9. :background="{background: 'linear-gradient(145deg, #41AFF9 0%, #2D8CFB 100%)' }"></u-navbar>
  10. <view class="cell-group" style="margin-top: 30rpx;">
  11. <u-cell-group>
  12. <u-cell-item title="修改密码" @click="openPage('pages/modifypwd/modifypwd')">
  13. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
  14. </u-cell-item>
  15. <u-cell-item title="打印走纸" @click="onPrintFeed()">
  16. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
  17. </u-cell-item>
  18. <u-cell-item title="退出登录" @click="onLoginOut()">
  19. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
  20. </u-cell-item>
  21. </u-cell-group>
  22. </view>
  23. <u-toast ref="uToast" />
  24. </view>
  25. </template>
  26. <script>
  27. //#ifdef APP-PLUS
  28. var device = uni.requireNativePlugin("DeviceInfo")
  29. //#endif
  30. export default{
  31. data(){
  32. return{
  33. }
  34. },
  35. onLoad(){
  36. },
  37. onShow(){
  38. },
  39. methods:{
  40. customBack(){
  41. this.$u.route({
  42. // type:'switchTab',
  43. url: 'pages/index/index'
  44. });
  45. },
  46. openPage(path) {
  47. // console.log('path',path);
  48. this.$u.route({
  49. url: path
  50. });
  51. },
  52. onPrintFeed(){
  53. //#ifdef APP-PLUS
  54. device.printFeed(10);
  55. //#endif
  56. //#ifdef H5
  57. uni.showToast({
  58. title: '非APP环境',
  59. duration: 2000
  60. });
  61. //#endif
  62. },
  63. onLoginOut(){
  64. uni.showModal({
  65. title: '温馨提示',
  66. content: '是否确认退出?',
  67. success: (res) => {
  68. if (res.confirm) {
  69. this.$u.api.loginOut({})
  70. .then(res=>{
  71. uni.clearStorage();
  72. this.$u.vuex('vuex_token', null);
  73. this.$u.vuex('vuex_user', null);
  74. this.$u.vuex('vuex_hasLogin', false);
  75. this.userInfo = [];
  76. this.theRoad = [];
  77. this.$refs.uToast.show({
  78. title: '退出成功,即将跳转登录页!',
  79. type: 'success',
  80. url:'pages/login/login'
  81. });
  82. // uni.showToast({
  83. // title: '退出成功',
  84. // duration: 2000
  85. // });
  86. // uni.redirectTo({
  87. // url:'../login/login'
  88. // });
  89. }).catch(err=>{
  90. uni.showToast({
  91. title: '退出失败',
  92. duration: 2000
  93. });
  94. });
  95. } else if (res.cancel) {
  96. }
  97. }
  98. })
  99. }
  100. }
  101. }
  102. </script>
  103. <style lang="scss">
  104. @import './setting.scss'
  105. </style>