logout.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <view class="scroll-box bg-white">
  3. <view class="page-bottom-fixed">
  4. <block v-if="data_list_loding_status == 3">
  5. <view class="padding-main">
  6. <view class="">
  7. <mp-html :content="agreement_data.value" />
  8. </view>
  9. <view class="bottom-fixed padding-main oh bg-white">
  10. <button class="bg-gray br-gray cr-base round text-size fl" type="default" size="mini" hover-class="none" @tap="logout_submit_event">确认注销</button>
  11. <button class="bg-main br-main cr-white round text-size fr" type="default" size="mini" hover-class="none" @tap="logout_cancel_event">取消</button>
  12. </view>
  13. </view>
  14. </block>
  15. <!-- 错误提示 -->
  16. <component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. const app = getApp();
  22. import componentNoData from "../../components/no-data/no-data";
  23. export default {
  24. data() {
  25. return {
  26. data_list_loding_status: 1,
  27. data_list_loding_msg: '',
  28. agreement_data: {}
  29. }
  30. },
  31. components: {
  32. componentNoData
  33. },
  34. onShow() {
  35. // 数据加载
  36. this.init();
  37. },
  38. methods: {
  39. // 获取数据
  40. init() {
  41. var user = app.globalData.get_user_info(this, 'init');
  42. if (user != false) {
  43. // 用户未绑定用户则转到登录页面
  44. if (app.globalData.user_is_need_login(user)) {
  45. uni.redirectTo({
  46. url: "/pages/login/login?event_callback=init"
  47. });
  48. this.setData({
  49. data_list_loding_status: 0,
  50. data_list_loding_msg: '请先绑定手机'
  51. });
  52. return false;
  53. } else {
  54. this.get_data();
  55. }
  56. } else {
  57. this.setData({
  58. data_list_loding_status: 0,
  59. data_list_loding_msg: '请先登录'
  60. });
  61. }
  62. },
  63. // 获取数据
  64. get_data() {
  65. uni.request({
  66. url: app.globalData.get_request_url("index", "agreement"),
  67. method: 'POST',
  68. data: {document: 'userlogout'},
  69. dataType: 'json',
  70. success: res => {
  71. if(res.data.code == 0) {
  72. this.setData({
  73. data_list_loding_status: 3,
  74. agreement_data: res.data.data || {}
  75. });
  76. } else {
  77. this.setData({
  78. data_list_loding_status: 0,
  79. data_list_loding_msg: res.data.msg
  80. });
  81. }
  82. },
  83. fail: () => {
  84. this.setData({
  85. data_list_loding_status: 2,
  86. data_list_loding_msg: '服务器请求出错'
  87. });
  88. app.globalData.showToast('服务器请求出错');
  89. }
  90. });
  91. },
  92. // 注销提交
  93. logout_submit_event(e) {
  94. // 是否再次确认
  95. if(e != 0 && e != 1) {
  96. app.globalData.alert({
  97. msg: '账号注销后不可恢复、确定继续吗?',
  98. is_show_cancel: 1,
  99. object: this,
  100. method: 'logout_submit_event'
  101. });
  102. return false;
  103. }
  104. // 注销提交
  105. if(e == 1) {
  106. uni.showLoading({
  107. title: '处理中...'
  108. });
  109. uni.request({
  110. url: app.globalData.get_request_url('logout', 'safety'),
  111. method: 'POST',
  112. data: {},
  113. dataType: 'json',
  114. success: res => {
  115. uni.hideLoading();
  116. if(res.data.code == 0) {
  117. app.globalData.remove_user_cache_event();
  118. app.globalData.showToast(res.data.msg, 'success');
  119. setTimeout(function() {
  120. uni.switchTab({url: app.globalData.data.tabbar_pages[0]});
  121. }, 1500);
  122. } else {
  123. if (app.globalData.is_login_check(res.data)) {
  124. app.globalData.showToast(res.data.msg);
  125. } else {
  126. app.globalData.showToast('提交失败,请重试!');
  127. }
  128. }
  129. },
  130. fail: () => {
  131. uni.hideLoading();
  132. app.globalData.showToast('服务器请求出错');
  133. }
  134. });
  135. }
  136. },
  137. // 取消返回
  138. logout_cancel_event() {
  139. app.globalData.page_back_prev_event();
  140. }
  141. }
  142. }
  143. </script>
  144. <style>
  145. @import './logout.css';
  146. </style>