cancel.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <view>
  3. <view class="container">
  4. <view class="main">
  5. <image class="image" src="/static/static/images/cancellation.png"></image>
  6. <text selectable="false" space="false" decode="false">注销后,您将无法使用当前账号,相关数据也将删除无法找回。当前账户:{{ userInfo.userID }}</text>
  7. <view class="cancellation" @tap="handleCancellation"><view class="confirm-cancellation">确认注销</view></view>
  8. </view>
  9. </view>
  10. <view class="mask" v-if="toggle" @tap.stop="close">
  11. <view class="popup">
  12. <view class="popup-main"><text>确定要注销账户吗?</text></view>
  13. <view class="popup-footer">
  14. <button class="submit" @tap.stop="submit">注销</button>
  15. <button class="cancel" @tap.stop="close">取消</button>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. // miniprogram/pages/cancelaton/cancel.js
  23. import { cancellation } from '../../../utils/api';
  24. import logger from '../../../utils/logger';
  25. const app = getApp();
  26. export default {
  27. data() {
  28. return {
  29. userInfo: {},
  30. phone: '',
  31. toggle: false
  32. };
  33. },
  34. components: {},
  35. props: {},
  36. /**
  37. * 生命周期函数--监听页面加载
  38. */
  39. onLoad() {
  40. this.setData({
  41. userInfo: app.globalData.userProfile,
  42. phone: app.globalData.userInfo.phone
  43. });
  44. uni.setNavigationBarTitle({
  45. title: '注销账户'
  46. });
  47. },
  48. methods: {
  49. handleCancellation() {
  50. this.setData({
  51. toggle: true
  52. });
  53. },
  54. close() {
  55. this.setData({
  56. toggle: false
  57. });
  58. },
  59. submit() {
  60. logger.log('| TUI-User-Center | cancel | logout-cancellation');
  61. uni.$TUIKit.logout().then(() => {
  62. cancellation({}, res => {
  63. logger.log('| TUI-User-Center | cancel | cancellation |ok');
  64. if (res.data.errorCode === 0) {
  65. uni.getStorage({
  66. key: 'path',
  67. complete: () => {
  68. uni.clearStorage();
  69. app.globalData.resetLoginData();
  70. uni.redirectTo({
  71. url: '../../TUI-Login/login',
  72. success: () => {
  73. uni.showToast({
  74. title: ' 注销成功',
  75. icon: 'none'
  76. });
  77. }
  78. });
  79. this.close();
  80. }
  81. });
  82. }
  83. });
  84. });
  85. }
  86. }
  87. };
  88. </script>
  89. <style>
  90. @import './cancel.css';
  91. </style>