|
@@ -14,7 +14,7 @@
|
|
|
<u-input v-model="formData.form.phone" disabled :border="true" type="text" placeholder="请输入绑定手机号"/>
|
|
|
</view>
|
|
|
<view class="btn">
|
|
|
- <text class="form-item-text" @click="getCode">{{tips}}</text>
|
|
|
+ <text class="form-item-text" @click="getCode">{{codeText}}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</u-form-item>
|
|
@@ -34,12 +34,13 @@
|
|
|
|
|
|
<script setup>
|
|
|
import { ref, reactive } from 'vue'
|
|
|
- import { onLoad, onReady } from '@dcloudio/uni-app'
|
|
|
- import { msgError, msgSuccess, showConfirm } from '@/utils/common'
|
|
|
+ import { onShow, onReady } from '@dcloudio/uni-app'
|
|
|
+ import { msgError, msgSuccess, showConfirm, msg } from '@/utils/common'
|
|
|
import { useAuthStore } from '@/store/authStore'
|
|
|
import {
|
|
|
smsSend
|
|
|
} from "@/api/login.js"
|
|
|
+ import { unregister } from '@/api/setting.js'
|
|
|
|
|
|
const authStore = useAuthStore()
|
|
|
|
|
@@ -70,18 +71,31 @@
|
|
|
}
|
|
|
})
|
|
|
const isAwaitCode = ref(false)
|
|
|
- const tips = ref('获取验证码') // 59秒重新获取
|
|
|
+ const codeText = ref('获取验证码') // 59秒重新获取
|
|
|
const cancelCheck = ref(false)
|
|
|
function getCode() {
|
|
|
let {phone} = formData.form
|
|
|
+ if (!/^1[3-9]\d{9}$/.test(phone)) {
|
|
|
+ msg("请输入正确的手机号");
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (!isAwaitCode.value) {
|
|
|
smsSend({phone}).then(res => {
|
|
|
if (res && res.data.captchaUuid) {
|
|
|
formData.form.captchaUuid = res.data.captchaUuid
|
|
|
- isSendCode.value = true
|
|
|
- setTimeout(() => {
|
|
|
-
|
|
|
- }, 60 * 1000)
|
|
|
+ isAwaitCode.value = true
|
|
|
+ // 倒计时60秒后重新获取
|
|
|
+ let time = 60
|
|
|
+ codeText.value = `重新获取(${time > 10 ? time : '0' + time}s)`
|
|
|
+ const timer = setInterval(() => {
|
|
|
+ time--
|
|
|
+ codeText.value = `重新获取(${time > 10 ? time : '0' + time}s)`
|
|
|
+ if (time <= 0) {
|
|
|
+ clearInterval(timer)
|
|
|
+ codeText.value = '获取验证码'
|
|
|
+ isAwaitCode.value = false
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
@@ -92,13 +106,29 @@
|
|
|
function onSubmit() {
|
|
|
formRef.value.validate((valid) => {
|
|
|
if (valid) {
|
|
|
+ if (!cancelCheck.value) {
|
|
|
+ msg('请阅读并同意《会员中心小程序账号注销通知》')
|
|
|
+ return
|
|
|
+ }
|
|
|
// 提交
|
|
|
showConfirm('是否确认注销').then(res => {
|
|
|
if (res.confirm) {
|
|
|
- authStore.clearAuthToken()
|
|
|
- authStore.cleanUserInfo()
|
|
|
- uni.reLaunch({
|
|
|
- url: '/pages/initial/initial?isCancelAccount=1'
|
|
|
+ const form = {
|
|
|
+ captcha: formData.form.code,
|
|
|
+ captchaUuid: formData.form.captchaUuid
|
|
|
+ }
|
|
|
+ uni.showLoading({
|
|
|
+ title: "请稍候..."
|
|
|
+ })
|
|
|
+ unregister(form).then(res => {
|
|
|
+ if (res && res.code === 0) {
|
|
|
+ uni.hideLoading()
|
|
|
+ authStore.clearAuthToken()
|
|
|
+ authStore.cleanUserInfo()
|
|
|
+ uni.reLaunch({
|
|
|
+ url: '/pages/initial/initial?isCancelAccount=1'
|
|
|
+ })
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
})
|
|
@@ -109,9 +139,9 @@
|
|
|
onReady(() => {
|
|
|
formRef.value.setRules(formData.rules)
|
|
|
})
|
|
|
- onLoad(() => {
|
|
|
- formData.form.phone = authStore.phone
|
|
|
- })
|
|
|
+ onShow(() => {
|
|
|
+ formData.form.phone = authStore.userInfo.phone
|
|
|
+ })
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|