setting.vue 2.7 KB

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