index.vue 7.4 KB

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