setting.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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="@/static/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">
  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. }
  26. },
  27. onLoad() {
  28. this.getVersion()
  29. },
  30. methods: {
  31. getVersion() {
  32. try {
  33. const accountInfo = wx.getAccountInfoSync()
  34. this.version = accountInfo.miniProgram.version || "1.0"
  35. } catch (error) {
  36. console.warn('获取版本号失败:', error)
  37. }
  38. },
  39. handleLogout() {
  40. uni.showModal({
  41. title: "提示",
  42. content: "确认退出登录吗?",
  43. confirmText: '确定',
  44. success: (res) => {
  45. if (res.confirm) {
  46. this.logout()
  47. }
  48. }
  49. })
  50. },
  51. toChangePassword(){
  52. uni.navigateTo({
  53. url: '/pages/auth/changePassword'
  54. })
  55. },
  56. logout() {
  57. // 清除登录相关存储
  58. uni.removeStorageSync('CompanyUserToken')
  59. uni.removeStorageSync('AppToken')
  60. uni.removeStorageSync('userInfo')
  61. // 通知其他页面更新登录状态
  62. uni.$emit('refreshLogin')
  63. // 跳转到登录页
  64. uni.navigateTo({
  65. url: '/pages/auth/login'
  66. })
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss">
  72. .setting-page {
  73. background: #ffffff;
  74. min-height: 100vh;
  75. .content {
  76. background: #ffffff;
  77. }
  78. .info-item {
  79. height: 104upx;
  80. padding: 0 30upx;
  81. display: flex;
  82. align-items: center;
  83. justify-content: space-between;
  84. border-bottom: 1px solid #F5F6FA;
  85. &:last-child {
  86. border-bottom: none;
  87. }
  88. .label {
  89. font-size: 30upx;
  90. font-family: PingFang SC;
  91. font-weight: 400;
  92. color: #0F1826;
  93. }
  94. .right {
  95. display: flex;
  96. align-items: center;
  97. justify-content: center;
  98. }
  99. .w36 {
  100. width: 36upx;
  101. height: 36upx;
  102. }
  103. }
  104. .btn-box {
  105. padding: 40upx 30upx;
  106. .logout-btn {
  107. width: 100%;
  108. height: 88upx;
  109. line-height: 88upx;
  110. text-align: center;
  111. font-family: PingFang SC;
  112. font-size: 32upx;
  113. color: #333333;
  114. background: #F7F8FA;
  115. border-radius: 44upx;
  116. }
  117. }
  118. }
  119. </style>