index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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. }
  67. },
  68. maskPhone(phone) {
  69. if (!phone || phone.length < 11) return phone
  70. return phone.substring(0, 3) + '****' + phone.substring(7)
  71. },
  72. changeMobile() {
  73. uni.navigateTo({
  74. url: '/pages/mine/settings/security/change-phone/index'
  75. })
  76. },
  77. changePassword() {
  78. uni.navigateTo({
  79. url: '/pages/mine/settings/security/change-password/index'
  80. })
  81. },
  82. async deleteAccount() {
  83. uni.showModal({
  84. title: '警示',
  85. content: '注销账号后将无法恢复,确定要继续吗?',
  86. success: async (res) => {
  87. if (res.confirm) {
  88. try {
  89. const result = await deleteAccount()
  90. if (result.code === 200) {
  91. uni.showToast({ title: '账号已注销', icon: 'success' })
  92. setTimeout(() => {
  93. uni.reLaunch({ url: '/pages/login/index' })
  94. }, 1500)
  95. } else {
  96. uni.showToast({ title: result.msg || '注销失败', icon: 'none' })
  97. }
  98. } catch (e) {
  99. console.error('注销账号失败', e)
  100. uni.showToast({ title: '注销失败', icon: 'none' })
  101. }
  102. }
  103. }
  104. });
  105. }
  106. }
  107. }
  108. </script>
  109. <style>
  110. page {
  111. background-color: #F8F8F8;
  112. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  113. }
  114. .custom-header {
  115. position: fixed;
  116. top: 0;
  117. left: 0;
  118. width: 100%;
  119. height: 88rpx;
  120. padding-top: var(--status-bar-height);
  121. background-color: #fff;
  122. display: flex;
  123. align-items: center;
  124. justify-content: space-between;
  125. padding-left: 30rpx;
  126. padding-right: 30rpx;
  127. box-sizing: content-box;
  128. z-index: 100;
  129. }
  130. .header-placeholder {
  131. height: calc(88rpx + var(--status-bar-height));
  132. }
  133. .back-icon {
  134. width: 40rpx;
  135. height: 40rpx;
  136. }
  137. .header-title {
  138. font-size: 28rpx;
  139. font-weight: bold;
  140. color: #333;
  141. }
  142. .header-right {
  143. width: 40rpx;
  144. }
  145. .container {
  146. padding: 20rpx 30rpx;
  147. }
  148. .section-title-security {
  149. font-size: 24rpx;
  150. color: #999;
  151. margin-bottom: 20rpx;
  152. margin-top: 20rpx;
  153. padding-left: 10rpx;
  154. }
  155. .group-card {
  156. background-color: #fff;
  157. border-radius: 20rpx;
  158. padding: 0 30rpx;
  159. margin-bottom: 30rpx;
  160. }
  161. .list-item {
  162. display: flex;
  163. justify-content: space-between;
  164. align-items: center;
  165. height: 100rpx;
  166. border-bottom: 1px solid #F5F5F5;
  167. }
  168. .list-item.no-border {
  169. border-bottom: none;
  170. }
  171. .item-title {
  172. font-size: 28rpx;
  173. color: #333;
  174. }
  175. .item-right {
  176. display: flex;
  177. align-items: center;
  178. }
  179. .arrow-icon {
  180. width: 28rpx;
  181. height: 28rpx;
  182. opacity: 0.5;
  183. margin-left: 10rpx;
  184. }
  185. .item-value {
  186. font-size: 28rpx;
  187. color: #999;
  188. }
  189. </style>