setting.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view class="setting-page">
  3. <view class="content">
  4. <view class="info-item" @click="toChangePassword">
  5. <view class="label">修改密码</view>
  6. <view class="right">
  7. <image class="w36 h36" src="https://ysrw-1395926010.cos.ap-chengdu.myqcloud.com/image/icon_my_more.png" mode=""></image>
  8. </view>
  9. </view>
  10. <view class="info-item">
  11. <view class="label">版本号</view>
  12. <view class="right">v{{ version }}</view>
  13. </view>
  14. </view>
  15. <view class="btn-box" v-if="AppToken">
  16. <view class="logout-btn" @click="handleLogout">退出登录</view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. data() {
  23. return {
  24. version: "1.0",
  25. AppToken:''
  26. }
  27. },
  28. onLoad() {
  29. this.getVersion()
  30. },
  31. onShow() {
  32. this.AppToken=uni.getStorageSync('AppToken');
  33. },
  34. methods: {
  35. getVersion() {
  36. try {
  37. const accountInfo = wx.getAccountInfoSync()
  38. this.version = accountInfo.miniProgram.version || "1.0"
  39. } catch (error) {
  40. console.warn('获取版本号失败:', error)
  41. }
  42. },
  43. handleLogout() {
  44. uni.showModal({
  45. title: "提示",
  46. content: "确认退出登录吗?",
  47. confirmText: '确定',
  48. success: (res) => {
  49. if (res.confirm) {
  50. this.logout()
  51. }
  52. }
  53. })
  54. },
  55. toChangePassword(){
  56. uni.navigateTo({
  57. url: '/pages/auth/changePassword'
  58. })
  59. },
  60. logout() {
  61. // 清除登录相关存储
  62. uni.removeStorageSync('CompanyUserToken')
  63. uni.removeStorageSync('AppToken')
  64. uni.removeStorageSync('userInfo')
  65. // 通知其他页面更新登录状态
  66. uni.$emit('refreshLogin')
  67. // 跳转到登录页
  68. uni.navigateTo({
  69. url: '/pages/auth/login'
  70. })
  71. }
  72. }
  73. }
  74. </script>
  75. <style lang="scss">
  76. .setting-page {
  77. background: #ffffff;
  78. min-height: 100vh;
  79. .content {
  80. background: #ffffff;
  81. }
  82. .info-item {
  83. height: 104upx;
  84. padding: 0 30upx;
  85. display: flex;
  86. align-items: center;
  87. justify-content: space-between;
  88. border-bottom: 1px solid #F5F6FA;
  89. &:last-child {
  90. border-bottom: none;
  91. }
  92. .label {
  93. font-size: 30upx;
  94. font-family: PingFang SC;
  95. font-weight: 400;
  96. color: #0F1826;
  97. }
  98. .right {
  99. display: flex;
  100. align-items: center;
  101. justify-content: center;
  102. }
  103. .w36 {
  104. width: 36upx;
  105. height: 36upx;
  106. }
  107. }
  108. .btn-box {
  109. padding: 40upx 30upx;
  110. .logout-btn {
  111. width: 100%;
  112. height: 88upx;
  113. line-height: 88upx;
  114. text-align: center;
  115. font-family: PingFang SC;
  116. font-size: 32upx;
  117. color: #333333;
  118. background: #F7F8FA;
  119. border-radius: 44upx;
  120. }
  121. }
  122. }
  123. </style>