index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <view class="account-delete-page">
  3. <view class="warning-card">
  4. <uni-icons type="info-filled" size="48" color="#f44336"></uni-icons>
  5. <text class="warning-title">账号注销须知</text>
  6. <text class="warning-text">注销账号后,以下数据将被永久删除且不可恢复:</text>
  7. <view class="warning-list">
  8. <text class="warning-item">• 个人信息及宠物档案</text>
  9. <text class="warning-item">• 历史订单记录</text>
  10. <text class="warning-item">• 评价与投诉记录</text>
  11. <text class="warning-item">• 账户余额(如有)</text>
  12. </view>
  13. </view>
  14. <view class="confirm-section">
  15. <view class="check-row">
  16. <checkbox-group @change="onCheckChange">
  17. <label class="check-label">
  18. <checkbox :checked="confirmed" color="#f44336" style="transform: scale(0.7);" />
  19. <text>我已了解上述风险,确认注销</text>
  20. </label>
  21. </checkbox-group>
  22. </view>
  23. <button class="delete-btn" :disabled="!confirmed" @click="onDelete">确认注销账号</button>
  24. </view>
  25. </view>
  26. </template>
  27. <script setup>
  28. import { ref } from 'vue'
  29. import { cancelUser } from '@/api/system/user'
  30. const confirmed = ref(false)
  31. const onCheckChange = () => { confirmed.value = !confirmed.value }
  32. const onDelete = () => {
  33. uni.showModal({
  34. title: '最终确认',
  35. content: '账号注销后无法恢复,确定继续吗?',
  36. confirmColor: '#f44336',
  37. success: async (res) => {
  38. if (res.confirm) {
  39. try {
  40. // @Author: Antigravity
  41. await cancelUser()
  42. uni.showToast({ title: '账号已注销', icon: 'success' })
  43. // 注销成功后清除 token 并跳转回登录页
  44. uni.removeStorageSync('token')
  45. setTimeout(() => uni.reLaunch({ url: '/pages/login/index' }), 1500)
  46. } catch (error) {
  47. // 错误处理由 request.js 统一提示,此处无需额外处理
  48. }
  49. }
  50. }
  51. })
  52. }
  53. </script>
  54. <style lang="scss" scoped>
  55. .account-delete-page {
  56. min-height: 100vh;
  57. background: #f7f8fa;
  58. padding: 40rpx 32rpx;
  59. }
  60. .warning-card {
  61. background: #fff;
  62. border-radius: 24rpx;
  63. padding: 48rpx 32rpx;
  64. display: flex;
  65. flex-direction: column;
  66. align-items: center;
  67. text-align: center;
  68. }
  69. .warning-title {
  70. font-size: 36rpx;
  71. font-weight: 800;
  72. color: #f44336;
  73. margin: 24rpx 0 16rpx;
  74. }
  75. .warning-text {
  76. font-size: 28rpx;
  77. color: #666;
  78. margin-bottom: 24rpx;
  79. }
  80. .warning-list {
  81. align-self: flex-start;
  82. }
  83. .warning-item {
  84. display: block;
  85. font-size: 26rpx;
  86. color: #999;
  87. line-height: 2;
  88. }
  89. .confirm-section {
  90. margin-top: 48rpx;
  91. }
  92. .check-row {
  93. margin-bottom: 32rpx;
  94. }
  95. .check-label {
  96. display: flex;
  97. align-items: center;
  98. font-size: 26rpx;
  99. color: #666;
  100. }
  101. .delete-btn {
  102. width: 100%;
  103. height: 96rpx;
  104. background: #f44336;
  105. color: #fff;
  106. border: none;
  107. border-radius: 48rpx;
  108. font-size: 32rpx;
  109. font-weight: bold;
  110. line-height: 96rpx;
  111. }
  112. .delete-btn[disabled] {
  113. background: #ccc;
  114. }
  115. </style>