setting.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <view class="uni-app">
  3. <view class="status-bar" />
  4. <view class="main-container">
  5. <wk-nav-bar title="设置" />
  6. <view class="container">
  7. <view class="cell-box">
  8. <view class="cell">
  9. <button class="cell-body" @click="handleTo('/pages_personal/resetPwd')">
  10. <text class="cell-body__label">
  11. 修改登录密码
  12. </text>
  13. <text class="wk wk-arrow-right" />
  14. </button>
  15. </view>
  16. <view class="cell">
  17. <button class="cell-body" @click="handleTo('/pages_personal/navConfig')">
  18. <text class="cell-body__label">
  19. 底部导航栏设置
  20. </text>
  21. <text class="wk wk-arrow-right" />
  22. </button>
  23. </view>
  24. </view>
  25. <view v-if="showDelete" class="cell-box">
  26. <view class="cell">
  27. <button class="cell-body" @click="handleCancelAccount">
  28. <text class="cell-body__label">
  29. 注销账户
  30. </text>
  31. <text class="delete-warning">
  32. 请谨慎操作
  33. </text>
  34. <text class="wk wk-arrow-right" />
  35. </button>
  36. </view>
  37. </view>
  38. <view class="logout linear-gradient" @click="handleLogout">
  39. 退出登录
  40. </view>
  41. </view>
  42. </view>
  43. <uni-popup ref="popup" type="dialog">
  44. <uni-popup-dialog
  45. :content="dialogMsg"
  46. :hiden-cancel="hidenCancel"
  47. :confirm-text="confirmText"
  48. type="warning"
  49. @confirm="handleConfirm" />
  50. </uni-popup>
  51. </view>
  52. </template>
  53. <script>
  54. import { logOut } from 'API/login'
  55. import { mapGetters, mapMutations } from 'vuex'
  56. export default {
  57. name: 'Setting',
  58. data() {
  59. return {
  60. dialogMsg: '',
  61. dialogType: '',
  62. hidenCancel: false,
  63. confirmText: '确定'
  64. }
  65. },
  66. computed: {
  67. ...mapGetters({
  68. userInfo: 'user/userInfo'
  69. }),
  70. showDelete() {
  71. return false
  72. }
  73. },
  74. methods: {
  75. ...mapMutations({
  76. clearData: 'user/CLEAR_DATA'
  77. }),
  78. handleTo(path) {
  79. this.$Router.navigateTo(path)
  80. },
  81. /**
  82. * 退出登录
  83. */
  84. handleLogout() {
  85. this.dialogMsg = '您确定要退出登录吗?'
  86. this.dialogType = 'logout'
  87. this.hidenCancel = false
  88. this.confirmText = '确定'
  89. this.$refs.popup.open()
  90. },
  91. handleCancelAccount() {
  92. this.dialogMsg = '注销后您的个人数据将会被永久删除,您真的要注销当前登录账号吗?'
  93. this.dialogType = 'delete'
  94. this.hidenCancel = false
  95. this.confirmText = '确定'
  96. this.$refs.popup.open()
  97. },
  98. handleConfirm(next) {
  99. console.log('confirm: ', this.dialogType)
  100. if (this.dialogType === 'logout') {
  101. logOut().then(response => {
  102. next()
  103. let appid = uni.getStorageSync('appid') || null
  104. this.clearData()
  105. if (appid) {
  106. uni.setStorageSync('appid', appid)
  107. }
  108. this.clearCache()
  109. }).catch(() => {
  110. next()
  111. let appid = uni.getStorageSync('appid') || null
  112. this.clearData()
  113. if (appid) {
  114. uni.setStorageSync('appid', appid)
  115. }
  116. this.clearCache()
  117. })
  118. } else if (this.dialogType === 'delete') {
  119. this.dialogMsg = '您的账户正在申请注销,30天内请勿登录'
  120. this.hidenCancel = true
  121. this.confirmText = '好的,我知道了'
  122. this.dialogType = ''
  123. } else {
  124. next()
  125. this.clearData()
  126. this.clearCache()
  127. }
  128. },
  129. clearCache() {
  130. getApp().globalData = {
  131. imgDict: {},
  132. selectedValBridge: {},
  133. auditInfo: {}
  134. }
  135. this.$Router.reLaunch('/pages/login/index')
  136. }
  137. }
  138. }
  139. </script>
  140. <style scoped lang="scss">
  141. .logout {
  142. width: 85%;
  143. height: 90rpx;
  144. text-align: center;
  145. font-size: 32rpx;
  146. line-height: 90rpx;
  147. color: white;
  148. border-radius: 45rpx;
  149. margin: 70rpx auto 0;
  150. }
  151. .delete-warning {
  152. font-size: 28rpx;
  153. color: #999;
  154. margin-right: 10rpx;
  155. }
  156. .main-container {
  157. .container {
  158. flex: 1;
  159. overflow: auto;
  160. .cell-box {
  161. margin-top: 20rpx;
  162. .cell {
  163. width: 100%;
  164. font-size: 32rpx;
  165. background-color: white;
  166. .cell-body {
  167. border-bottom: 1rpx solid $border-color;
  168. padding: 26rpx 30rpx;
  169. @include left;
  170. .cell-body__label {
  171. flex: 1;
  172. color: #666666;
  173. @include left;
  174. }
  175. .wk-arrow-right {
  176. font-size: 28rpx;
  177. color: #c8c8cd;
  178. }
  179. }
  180. &:last-child {
  181. .cell-body {
  182. border: 0 none;
  183. }
  184. }
  185. }
  186. }
  187. }
  188. }
  189. </style>