index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view class="container">
  3. <!-- 自定义头部 -->
  4. <view class="custom-header">
  5. <view class="header-left" @click="navBack">
  6. <image class="back-icon" src="/static/icons/chevron_right_dark.svg" style="transform: rotate(180deg);"></image>
  7. </view>
  8. <text class="header-title">账号与安全</text>
  9. <view class="header-right"></view>
  10. </view>
  11. <view class="header-placeholder"></view>
  12. <view class="section-title-security">安全设置</view>
  13. <view class="group-card">
  14. <view class="list-item" @click="changeMobile">
  15. <text class="item-title">手机号</text>
  16. <view class="item-right">
  17. <text class="item-value">{{ maskPhone(phone) || '未设置' }}</text>
  18. <image class="arrow-icon" src="/static/icons/chevron_right.svg"></image>
  19. </view>
  20. </view>
  21. <view class="list-item" @click="changePassword">
  22. <text class="item-title">登录密码</text>
  23. <view class="item-right">
  24. <text class="item-value">{{ hasPassword ? '已设置' : '未设置' }}</text>
  25. <image class="arrow-icon" src="/static/icons/chevron_right.svg"></image>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="section-title-security">高级设置</view>
  30. <view class="group-card">
  31. <view class="list-item no-border" @click="deleteAccount">
  32. <text class="item-title">注销账号</text>
  33. <image class="arrow-icon" src="/static/icons/chevron_right.svg"></image>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import { getMyProfile, deleteAccount } from '@/api/fulfiller'
  40. export default {
  41. data() {
  42. return {
  43. phone: '',
  44. hasPassword: false
  45. }
  46. },
  47. onLoad() {
  48. this.loadProfile()
  49. },
  50. methods: {
  51. navBack() {
  52. uni.navigateBack({
  53. delta: 1
  54. });
  55. },
  56. async loadProfile() {
  57. try {
  58. const res = await getMyProfile()
  59. if (res.code === 200 && res.data) {
  60. this.phone = res.data.phone || ''
  61. this.hasPassword = !!res.data.hasPassword
  62. }
  63. } catch (e) {
  64. console.error('加载个人信息失败', e)
  65. }
  66. },
  67. maskPhone(phone) {
  68. if (!phone || phone.length < 11) return phone
  69. return phone.substring(0, 3) + '****' + phone.substring(7)
  70. },
  71. changeMobile() {
  72. uni.navigateTo({
  73. url: '/pages/mine/settings/security/change-phone'
  74. })
  75. },
  76. changePassword() {
  77. uni.navigateTo({
  78. url: '/pages/mine/settings/security/change-password'
  79. })
  80. },
  81. async deleteAccount() {
  82. uni.showModal({
  83. title: '警示',
  84. content: '注销账号后将无法恢复,确定要继续吗?',
  85. success: async (res) => {
  86. if (res.confirm) {
  87. try {
  88. const result = await deleteAccount()
  89. if (result.code === 200) {
  90. uni.showToast({ title: '账号已注销', icon: 'success' })
  91. setTimeout(() => {
  92. uni.reLaunch({ url: '/pages/login/login' })
  93. }, 1500)
  94. } else {
  95. uni.showToast({ title: result.msg || '注销失败', icon: 'none' })
  96. }
  97. } catch (e) {
  98. console.error('注销账号失败', e)
  99. uni.showToast({ title: '注销失败', icon: 'none' })
  100. }
  101. }
  102. }
  103. });
  104. }
  105. }
  106. }
  107. </script>
  108. <style>
  109. page {
  110. background-color: #F8F8F8;
  111. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  112. }
  113. .custom-header {
  114. position: fixed;
  115. top: 0;
  116. left: 0;
  117. width: 100%;
  118. height: 88rpx;
  119. padding-top: var(--status-bar-height);
  120. background-color: #fff;
  121. display: flex;
  122. align-items: center;
  123. justify-content: space-between;
  124. padding-left: 30rpx;
  125. padding-right: 30rpx;
  126. box-sizing: content-box;
  127. z-index: 100;
  128. }
  129. .header-placeholder {
  130. height: calc(88rpx + var(--status-bar-height));
  131. }
  132. .back-icon {
  133. width: 40rpx;
  134. height: 40rpx;
  135. }
  136. .header-title {
  137. font-size: 28rpx;
  138. font-weight: bold;
  139. color: #333;
  140. }
  141. .header-right {
  142. width: 40rpx;
  143. }
  144. .container {
  145. padding: 20rpx 30rpx;
  146. }
  147. .section-title-security {
  148. font-size: 24rpx;
  149. color: #999;
  150. margin-bottom: 20rpx;
  151. margin-top: 20rpx;
  152. padding-left: 10rpx;
  153. }
  154. .group-card {
  155. background-color: #fff;
  156. border-radius: 20rpx;
  157. padding: 0 30rpx;
  158. margin-bottom: 30rpx;
  159. }
  160. .list-item {
  161. display: flex;
  162. justify-content: space-between;
  163. align-items: center;
  164. height: 100rpx;
  165. border-bottom: 1px solid #F5F5F5;
  166. }
  167. .list-item.no-border {
  168. border-bottom: none;
  169. }
  170. .item-title {
  171. font-size: 28rpx;
  172. color: #333;
  173. }
  174. .item-right {
  175. display: flex;
  176. align-items: center;
  177. }
  178. .arrow-icon {
  179. width: 28rpx;
  180. height: 28rpx;
  181. opacity: 0.5;
  182. margin-left: 10rpx;
  183. }
  184. .item-value {
  185. font-size: 28rpx;
  186. color: #999;
  187. }
  188. </style>