index.vue 5.7 KB

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