index.vue 7.9 KB

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