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. <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. console.log('跳转页面:', page)
  117. if (page === 'bindIdCard') {
  118. // 跳转到身份证绑定页面
  119. uni.navigateTo({
  120. url: '/pages/settings/id-verification'
  121. })
  122. }
  123. // else if (page === 'bindPhone') {
  124. // // 跳转到手机号绑定页面
  125. // uni.navigateTo({
  126. // url: '/pages/settings/phone-binding'
  127. // })
  128. // }
  129. else if (page === 'about') {
  130. // 跳转到关于我们页面
  131. uni.navigateTo({
  132. url: '/pages/settings/about'
  133. })
  134. } else {
  135. // // 其他功能
  136. // uni.showToast({
  137. // title: '功能开发中',
  138. // icon: 'none'
  139. // })
  140. }
  141. },
  142. handleLogout() {
  143. uni.showModal({
  144. title: '退出登录',
  145. content: '确定要退出登录吗?',
  146. success: (res) => {
  147. if (res.confirm) {
  148. // 1. 断开WebSocket连接
  149. try {
  150. const timPresenceManager = require('@/utils/tim-presence-manager.js').default;
  151. if (timPresenceManager) {
  152. timPresenceManager.disconnect();
  153. console.log('✅ 在线状态WebSocket已断开');
  154. }
  155. } catch (error) {
  156. console.error('❌ 断开在线状态WebSocket失败:', error);
  157. }
  158. // 2. 断开TIM WebSocket
  159. try {
  160. const timManager = require('@/utils/tim-manager.js').default;
  161. if (timManager && timManager.isLogin) {
  162. timManager.logout();
  163. console.log('✅ TIM已登出');
  164. }
  165. } catch (error) {
  166. console.error('❌ TIM登出失败:', error);
  167. }
  168. // 3. 清除登录信息
  169. uni.clearStorageSync()
  170. // 4. 跳转到登录页
  171. uni.reLaunch({
  172. url: '/pages/page3/page3'
  173. })
  174. }
  175. }
  176. })
  177. }
  178. }
  179. }
  180. </script>
  181. <style lang="scss" scoped>
  182. .settings-page {
  183. min-height: 100vh;
  184. background: #F5F5F5;
  185. display: flex;
  186. flex-direction: column;
  187. }
  188. /* 顶部导航栏 */
  189. .header {
  190. display: flex;
  191. align-items: center;
  192. justify-content: space-between;
  193. padding: 25rpx 30rpx;
  194. padding-top: calc(25rpx + env(safe-area-inset-top));
  195. background: #FFFFFF;
  196. border-bottom: 1rpx solid #F0F0F0;
  197. .back-btn {
  198. width: 60rpx;
  199. height: 60rpx;
  200. display: flex;
  201. align-items: center;
  202. justify-content: center;
  203. .back-icon {
  204. font-size: 40rpx;
  205. color: #333333;
  206. font-weight: bold;
  207. }
  208. }
  209. .header-title {
  210. font-size: 36rpx;
  211. font-weight: bold;
  212. color: #333333;
  213. }
  214. .placeholder {
  215. width: 60rpx;
  216. }
  217. }
  218. .content {
  219. flex: 1;
  220. background: #F5F5F5;
  221. }
  222. /* 分组块 */
  223. .group-block {
  224. margin-bottom: 30rpx;
  225. }
  226. /* 分组标题 */
  227. .group-title {
  228. padding: 30rpx 30rpx 20rpx;
  229. font-size: 28rpx;
  230. color: #999999;
  231. }
  232. /* 卡片容器 */
  233. .card {
  234. background: #FFFFFF;
  235. border-radius: 20rpx;
  236. margin: 0 30rpx;
  237. overflow: hidden;
  238. }
  239. /* 设置列表 */
  240. .settings-list {
  241. background: #FFFFFF;
  242. .setting-item {
  243. display: flex;
  244. align-items: center;
  245. justify-content: space-between;
  246. padding: 35rpx 30rpx;
  247. border-bottom: 1rpx solid #F5F5F5;
  248. transition: background-color 0.2s;
  249. &:active {
  250. background-color: #F8F8F8;
  251. }
  252. &:last-child {
  253. border-bottom: none;
  254. }
  255. .item-left {
  256. display: flex;
  257. align-items: center;
  258. flex: 1;
  259. .item-icon {
  260. font-size: 40rpx;
  261. margin-right: 20rpx;
  262. }
  263. .item-text {
  264. font-size: 32rpx;
  265. color: #333333;
  266. }
  267. }
  268. .item-right {
  269. display: flex;
  270. align-items: center;
  271. .item-value {
  272. font-size: 28rpx;
  273. color: #999999;
  274. margin-right: 15rpx;
  275. }
  276. .item-arrow {
  277. font-size: 40rpx;
  278. color: #CCCCCC;
  279. font-weight: 300;
  280. }
  281. }
  282. .item-arrow {
  283. font-size: 40rpx;
  284. color: #CCCCCC;
  285. font-weight: 300;
  286. }
  287. }
  288. }
  289. /* 设置项样式(在card内) */
  290. .card {
  291. .setting-item {
  292. display: flex;
  293. align-items: center;
  294. justify-content: space-between;
  295. padding: 35rpx 30rpx;
  296. border-bottom: 1rpx solid #F5F5F5;
  297. transition: background-color 0.2s;
  298. &:active {
  299. background-color: #F8F8F8;
  300. }
  301. &:last-child {
  302. border-bottom: none;
  303. }
  304. &.logout-item {
  305. .item-text {
  306. color: #FF4444;
  307. }
  308. }
  309. .item-left {
  310. display: flex;
  311. align-items: center;
  312. flex: 1;
  313. .item-icon {
  314. font-size: 40rpx;
  315. margin-right: 20rpx;
  316. }
  317. .item-text {
  318. font-size: 32rpx;
  319. color: #333333;
  320. }
  321. }
  322. .item-arrow {
  323. font-size: 40rpx;
  324. color: #CCCCCC;
  325. font-weight: 300;
  326. }
  327. }
  328. }
  329. </style>