index.vue 8.2 KB

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