index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <view class="settings-page">
  3. <!-- 顶部导航栏 -->
  4. <view class="header">
  5. <view class="back-btn" @click="goBack">
  6. <text class="back-icon">←</text>
  7. </view>
  8. <text class="header-title">账户设置</text>
  9. <view class="placeholder"></view>
  10. </view>
  11. <scroll-view scroll-y class="content">
  12. <!-- 账号安全分组 -->
  13. <view class="group-block">
  14. <text class="group-title">账户安全</text>
  15. <view class="card">
  16. <view class="setting-item" @click="goToPage('changePassword')">
  17. <view class="item-left">
  18. <text class="item-icon shield">🛡️</text>
  19. <text class="item-text">修改密码</text>
  20. </view>
  21. <text class="item-arrow">›</text>
  22. </view>
  23. <view class="setting-item" @click="goToPage('about')">
  24. <view class="item-left">
  25. <text class="item-icon">ℹ️</text>
  26. <text class="item-text">关于我们</text>
  27. </view>
  28. <text class="item-arrow">›</text>
  29. </view>
  30. <view class="setting-item logout-item" @click="handleLogout">
  31. <view class="item-left">
  32. <text class="item-icon">🚪</text>
  33. <text class="item-text">退出登录</text>
  34. </view>
  35. <text class="item-arrow">›</text>
  36. </view>
  37. </view>
  38. </view>
  39. </scroll-view>
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. data() {
  45. return {
  46. phoneNumber: '未绑定',
  47. idCardNumber: '未绑定',
  48. educationStatus: '未认证',
  49. notifyNewMessage: true,
  50. notifyMatchSuccess: true,
  51. notifySystem: true,
  52. darkMode: false
  53. }
  54. },
  55. onLoad() {
  56. this.loadUserInfo()
  57. },
  58. methods: {
  59. goBack() {
  60. uni.navigateBack()
  61. },
  62. loadUserInfo() {
  63. // 获取用户信息
  64. const userInfo = uni.getStorageSync('userInfo')
  65. // 加载手机号
  66. if (userInfo && userInfo.phone) {
  67. this.phoneNumber = this.maskPhone(userInfo.phone)
  68. } else {
  69. this.phoneNumber = '未绑定'
  70. }
  71. // 加载身份证号
  72. if (userInfo && userInfo.idCard) {
  73. this.idCardNumber = this.maskIdCard(userInfo.idCard)
  74. } else {
  75. this.idCardNumber = '未绑定'
  76. }
  77. // 加载学历认证状态
  78. if (userInfo && userInfo.isEducationVerified) {
  79. this.educationStatus = '已认证'
  80. } else {
  81. this.educationStatus = '未认证'
  82. }
  83. },
  84. maskPhone(phone) {
  85. if (!phone || phone.length < 11) return phone
  86. return phone.substring(0, 3) + '****' + phone.substring(7)
  87. },
  88. maskIdCard(idCard) {
  89. if (!idCard || idCard.length < 8) return idCard
  90. return idCard.substring(0, 6) + '********' + idCard.substring(idCard.length - 4)
  91. },
  92. goToPage(page) {
  93. console.log('跳转页面:', page)
  94. if (page === 'bindIdCard') {
  95. // 跳转到身份证绑定页面
  96. uni.navigateTo({
  97. url: '/pages/settings/id-verification'
  98. })
  99. }
  100. // else if (page === 'bindPhone') {
  101. // // 跳转到手机号绑定页面
  102. // uni.navigateTo({
  103. // url: '/pages/settings/phone-binding'
  104. // })
  105. // }
  106. else if (page === 'about') {
  107. // 跳转到关于我们页面
  108. uni.navigateTo({
  109. url: '/pages/settings/about'
  110. })
  111. } else {
  112. // // 其他功能
  113. // uni.showToast({
  114. // title: '功能开发中',
  115. // icon: 'none'
  116. // })
  117. }
  118. },
  119. handleLogout() {
  120. uni.showModal({
  121. title: '退出登录',
  122. content: '确定要退出登录吗?',
  123. success: (res) => {
  124. if (res.confirm) {
  125. // 1. 断开WebSocket连接
  126. try {
  127. const timPresenceManager = require('@/utils/tim-presence-manager.js').default;
  128. if (timPresenceManager) {
  129. timPresenceManager.disconnect();
  130. console.log('✅ 在线状态WebSocket已断开');
  131. }
  132. } catch (error) {
  133. console.error('❌ 断开在线状态WebSocket失败:', error);
  134. }
  135. // 2. 断开TIM WebSocket
  136. try {
  137. const timManager = require('@/utils/tim-manager.js').default;
  138. if (timManager && timManager.isLogin) {
  139. timManager.logout();
  140. console.log('✅ TIM已登出');
  141. }
  142. } catch (error) {
  143. console.error('❌ TIM登出失败:', error);
  144. }
  145. // 3. 清除登录信息
  146. uni.clearStorageSync()
  147. // 4. 跳转到登录页
  148. uni.reLaunch({
  149. url: '/pages/page3/page3'
  150. })
  151. }
  152. }
  153. })
  154. }
  155. }
  156. }
  157. </script>
  158. <style lang="scss" scoped>
  159. .settings-page {
  160. min-height: 100vh;
  161. background: #F5F5F5;
  162. display: flex;
  163. flex-direction: column;
  164. }
  165. /* 顶部导航栏 */
  166. .header {
  167. display: flex;
  168. align-items: center;
  169. justify-content: space-between;
  170. padding: 25rpx 30rpx;
  171. padding-top: calc(25rpx + env(safe-area-inset-top));
  172. background: #FFFFFF;
  173. border-bottom: 1rpx solid #F0F0F0;
  174. .back-btn {
  175. width: 60rpx;
  176. height: 60rpx;
  177. display: flex;
  178. align-items: center;
  179. justify-content: center;
  180. .back-icon {
  181. font-size: 40rpx;
  182. color: #333333;
  183. font-weight: bold;
  184. }
  185. }
  186. .header-title {
  187. font-size: 36rpx;
  188. font-weight: bold;
  189. color: #333333;
  190. }
  191. .placeholder {
  192. width: 60rpx;
  193. }
  194. }
  195. .content {
  196. flex: 1;
  197. background: #F5F5F5;
  198. }
  199. /* 分组标题 */
  200. .group-title {
  201. padding: 30rpx 30rpx 20rpx;
  202. font-size: 28rpx;
  203. color: #999999;
  204. }
  205. /* 设置列表 */
  206. .settings-list {
  207. background: #FFFFFF;
  208. .setting-item {
  209. display: flex;
  210. align-items: center;
  211. justify-content: space-between;
  212. padding: 35rpx 30rpx;
  213. border-bottom: 1rpx solid #F5F5F5;
  214. transition: background-color 0.2s;
  215. &:active {
  216. background-color: #F8F8F8;
  217. }
  218. &:last-child {
  219. border-bottom: none;
  220. }
  221. .item-left {
  222. display: flex;
  223. align-items: center;
  224. flex: 1;
  225. .item-icon {
  226. font-size: 40rpx;
  227. margin-right: 20rpx;
  228. }
  229. .item-text {
  230. font-size: 32rpx;
  231. color: #333333;
  232. }
  233. }
  234. .item-right {
  235. display: flex;
  236. align-items: center;
  237. .item-value {
  238. font-size: 28rpx;
  239. color: #999999;
  240. margin-right: 15rpx;
  241. }
  242. .item-arrow {
  243. font-size: 40rpx;
  244. color: #CCCCCC;
  245. font-weight: 300;
  246. }
  247. }
  248. .item-arrow {
  249. font-size: 40rpx;
  250. color: #CCCCCC;
  251. font-weight: 300;
  252. }
  253. }
  254. }
  255. </style>