index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <view class="account-delete-page">
  3. <nav-bar title="账号注销" bgColor="#f7f8fa" color="#000"></nav-bar>
  4. <view class="form-container">
  5. <view class="warning-card">
  6. <view class="warning-icon">!</view>
  7. <text class="warning-title">账号注销须知</text>
  8. <text class="warning-text">注销账号后,以下数据将被永久删除且不可恢复:</text>
  9. <view class="warning-list">
  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. </view>
  27. </template>
  28. <script setup>
  29. import { ref } from 'vue'
  30. import navBar from '@/components/nav-bar/index.vue'
  31. import { cancelUser } from '@/api/system/user'
  32. const confirmed = ref(false)
  33. const onCheckChange = () => { confirmed.value = !confirmed.value }
  34. const onDelete = () => {
  35. uni.showModal({
  36. title: '最终确认',
  37. content: '账号注销后无法恢复,确定继续吗?',
  38. confirmColor: '#f44336',
  39. success: async (res) => {
  40. if (res.confirm) {
  41. try {
  42. await cancelUser()
  43. uni.showToast({ title: '账号已注销', icon: 'success' })
  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: 0 32rpx;
  59. }
  60. .form-container {
  61. margin-top: 20rpx;
  62. }
  63. .warning-card {
  64. background: #fff;
  65. border-radius: 24rpx;
  66. padding: 48rpx 32rpx;
  67. display: flex;
  68. flex-direction: column;
  69. align-items: flex-start;
  70. text-align: left;
  71. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
  72. }
  73. .warning-icon {
  74. width: 80rpx;
  75. height: 80rpx;
  76. line-height: 80rpx;
  77. text-align: center;
  78. border-radius: 50%;
  79. background: #fff3e0;
  80. color: #ff9800;
  81. font-size: 48rpx;
  82. font-weight: bold;
  83. margin-bottom: 24rpx;
  84. border: 2rpx solid #ffe0b2;
  85. }
  86. .warning-title {
  87. font-size: 30rpx;
  88. font-weight: bold;
  89. color: #333;
  90. margin-bottom: 20rpx;
  91. }
  92. .warning-text {
  93. font-size: 28rpx;
  94. color: #666;
  95. margin-bottom: 24rpx;
  96. line-height: 1.6;
  97. }
  98. .warning-list {
  99. width: 100%;
  100. }
  101. .warning-item {
  102. display: block;
  103. font-size: 28rpx;
  104. color: #666;
  105. line-height: 2.2;
  106. }
  107. .confirm-section {
  108. margin-top: 40rpx;
  109. padding-bottom: 40rpx;
  110. }
  111. .check-row {
  112. margin-bottom: 32rpx;
  113. }
  114. .check-label {
  115. display: flex;
  116. align-items: center;
  117. font-size: 28rpx;
  118. color: #666;
  119. }
  120. .delete-btn {
  121. width: 100%;
  122. height: 88rpx;
  123. background: #f44336;
  124. color: #fff;
  125. border: none;
  126. border-radius: 44rpx;
  127. font-size: 30rpx;
  128. font-weight: bold;
  129. line-height: 88rpx;
  130. &::after { border: none; }
  131. }
  132. .delete-btn[disabled] {
  133. background: #ccc;
  134. }
  135. </style>