cancelAccount.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <view class="cancel-account-container">
  3. <view class="header">账号注销</view>
  4. <view class="desc">注销账号将清空所有个人数据且无法恢复,是否确认注销?</view>
  5. <button class="submit-btn" type="warn" @click="submit">确认注销</button>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. methods: {
  11. submit() {
  12. uni.showModal({
  13. title: '确认注销',
  14. content: '注销后所有数据将无法恢复,是否继续?',
  15. success: (res) => {
  16. if (res.confirm) {
  17. uni.request({
  18. url: 'http://localhost:9527/api/cancelAccount',
  19. method: 'POST',
  20. data: { uid: uni.getStorageSync('uid') },
  21. success: (res) => {
  22. if (res.statusCode === 200 && res.data.code === 200) {
  23. uni.showToast({ title: '注销成功', icon: 'success' })
  24. setTimeout(() => {
  25. uni.clearStorageSync()
  26. uni.reLaunch({ url: '/pages/index/index' })
  27. }, 1000)
  28. } else {
  29. uni.showToast({ title: res.data.message || '注销失败', icon: 'none' })
  30. }
  31. }
  32. })
  33. }
  34. }
  35. })
  36. }
  37. }
  38. }
  39. </script>
  40. <style scoped>
  41. .cancel-account-container {
  42. min-height: 100vh;
  43. background: #f7f8fa;
  44. padding: 40rpx 0;
  45. display: flex;
  46. flex-direction: column;
  47. align-items: center;
  48. }
  49. .header {
  50. text-align: center;
  51. font-size: 36rpx;
  52. font-weight: bold;
  53. margin-bottom: 40rpx;
  54. background: #fff;
  55. padding: 32rpx 0;
  56. width: 100%;
  57. }
  58. .desc {
  59. font-size: 28rpx;
  60. color: #e74c3c;
  61. margin: 60rpx 0 40rpx 0;
  62. text-align: center;
  63. padding: 0 32rpx;
  64. }
  65. .submit-btn {
  66. width: 80%;
  67. background: #e74c3c;
  68. color: #fff;
  69. border-radius: 12rpx;
  70. font-size: 32rpx;
  71. margin-top: 16rpx;
  72. height: 80rpx;
  73. }
  74. </style>