cancelAccount.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view class="container">
  3. <view class="desc-box">
  4. <view class="desc-text">您正在申请广州市房地产中介协会会员中心小程序账户注销,为保障您的权益,我们再次提醒您:</view>
  5. <view class="desc-text">1、注销申请一旦提交,将无法撤销,且系统可能无法恢复相关数据,请您务必谨慎操作!我们将在您申请注销账号起15个工作日内完成与该账号相关的数据处理工作。</view>
  6. <view class="desc-text">2、账号注销7个工作日内,您无法通过相同手机号或身份证重新注册/登录广州市房地产中介协会会员中心小程序账号。</view>
  7. <view class="desc-text">3、如您在注销账号的过程中遇到任何问题,请拨打协会客服热线(020-66676400)与我们取得联系。</view>
  8. </view>
  9. <view class="form-box">
  10. <u-form :model="formData.form" ref="formRef" label-width="120" :label-style="{fontWeight: 'bold', fontSize: '26rpx'}">
  11. <u-form-item prop="phone">
  12. <view class="input-code">
  13. <view class="input">
  14. <u-input v-model="formData.form.phone" disabled :border="true" type="text" placeholder="请输入绑定手机号"/>
  15. </view>
  16. <view class="btn">
  17. <text class="form-item-text" @click="getCode">{{codeText}}</text>
  18. </view>
  19. </view>
  20. </u-form-item>
  21. <u-form-item prop="code">
  22. <u-input v-model="formData.form.code" :border="true" type="text" placeholder="请输入验证码"/>
  23. </u-form-item>
  24. </u-form>
  25. </view>
  26. <view class="bottom-box">
  27. <u-checkbox-group style="display: flex;justify-content: center;margin-bottom: 20rpx;">
  28. <u-checkbox v-model="cancelCheck" name="yes" shape="circle" label-size="26">我已阅读并同意&#x300A;会员中心小程序账号注销通知&#x300B;</u-checkbox>
  29. </u-checkbox-group>
  30. <u-button type="primary" shape="circle" @click="onSubmit">提交</u-button>
  31. </view>
  32. </view>
  33. </template>
  34. <script setup>
  35. import { ref, reactive } from 'vue'
  36. import { onShow, onReady } from '@dcloudio/uni-app'
  37. import { msgError, msgSuccess, showConfirm, msg } from '@/utils/common'
  38. import { useAuthStore } from '@/store/authStore'
  39. import {
  40. smsSend
  41. } from "@/api/login.js"
  42. import { unregister } from '@/api/setting.js'
  43. const authStore = useAuthStore()
  44. const formRef = ref()
  45. const formData = reactive({
  46. form: {
  47. phone: null,
  48. code: null,
  49. captchaUuid: null
  50. },
  51. rules: {
  52. phone: [
  53. {
  54. required: true,
  55. message: '请输入绑定手机号',
  56. // 可以单个或者同时写两个触发验证方式
  57. trigger: 'blur',
  58. }
  59. ],
  60. code: [
  61. {
  62. required: true,
  63. message: '请输入验证码',
  64. // 可以单个或者同时写两个触发验证方式
  65. trigger: 'blur',
  66. }
  67. ],
  68. }
  69. })
  70. const isAwaitCode = ref(false)
  71. const codeText = ref('获取验证码') // 59秒重新获取
  72. const cancelCheck = ref(false)
  73. function getCode() {
  74. let {phone} = formData.form
  75. if (!/^1[3-9]\d{9}$/.test(phone)) {
  76. msg("请输入正确的手机号");
  77. return;
  78. }
  79. if (!isAwaitCode.value) {
  80. smsSend({phone}).then(res => {
  81. if (res && res.data.captchaUuid) {
  82. formData.form.captchaUuid = res.data.captchaUuid
  83. isAwaitCode.value = true
  84. // 倒计时60秒后重新获取
  85. let time = 60
  86. codeText.value = `重新获取(${time > 10 ? time : '0' + time}s)`
  87. const timer = setInterval(() => {
  88. time--
  89. codeText.value = `重新获取(${time > 10 ? time : '0' + time}s)`
  90. if (time <= 0) {
  91. clearInterval(timer)
  92. codeText.value = '获取验证码'
  93. isAwaitCode.value = false
  94. }
  95. }, 1000)
  96. }
  97. })
  98. } else {
  99. msg('倒计时结束后再发送');
  100. }
  101. }
  102. function onSubmit() {
  103. formRef.value.validate((valid) => {
  104. if (valid) {
  105. if (!cancelCheck.value) {
  106. msg('请阅读并同意《会员中心小程序账号注销通知》')
  107. return
  108. }
  109. // 提交
  110. showConfirm('是否确认注销').then(res => {
  111. if (res.confirm) {
  112. const form = {
  113. captcha: formData.form.code,
  114. captchaUuid: formData.form.captchaUuid
  115. }
  116. uni.showLoading({
  117. title: "请稍候..."
  118. })
  119. unregister(form).then(res => {
  120. if (res && res.code === 0) {
  121. uni.hideLoading()
  122. authStore.clearAuthToken()
  123. authStore.cleanUserInfo()
  124. uni.reLaunch({
  125. url: '/pages/initial/initial?isCancelAccount=1'
  126. })
  127. }
  128. })
  129. }
  130. })
  131. }
  132. })
  133. }
  134. onReady(() => {
  135. formRef.value.setRules(formData.rules)
  136. })
  137. onShow(() => {
  138. formData.form.phone = authStore.userInfo.phone
  139. })
  140. </script>
  141. <style lang="scss" scoped>
  142. .container {
  143. height: 100vh;
  144. width: 100vw;
  145. background-color: $uni-bg-color;
  146. padding: 20rpx;
  147. .desc-box {
  148. padding: 20rpx 0;
  149. margin-bottom: 20rpx;
  150. .desc-text {
  151. text-indent: 2em;
  152. line-height: 60rpx;
  153. &:nth-child(1) {
  154. text-indent: 0em;
  155. }
  156. }
  157. }
  158. .form-box {
  159. padding: 20rpx 0;
  160. .input-code {
  161. display: flex;
  162. align-items: center;
  163. gap: 20rpx;
  164. .input {
  165. width: 70%;
  166. }
  167. .btn {
  168. width: 30%;
  169. text-align: center;
  170. }
  171. }
  172. }
  173. .bottom-box {
  174. margin-top: 50rpx;
  175. padding: 0 50rpx;
  176. }
  177. }
  178. </style>