add
This commit is contained in:
@@ -126,10 +126,12 @@
|
||||
|
||||
<script setup name="UserResetPassword">
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useAliyunCaptcha } from '@/composables/useAliyunCaptcha'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
const router = useRouter()
|
||||
const userStore = useUserStore()
|
||||
const { runWithCaptcha } = useAliyunCaptcha()
|
||||
|
||||
// 表单数据
|
||||
const form = ref({
|
||||
@@ -157,17 +159,25 @@ const canSubmit = computed(() => {
|
||||
form.value.confirmNewPassword && form.value.confirmNewPassword === form.value.newPassword
|
||||
})
|
||||
|
||||
// 发送验证码
|
||||
// 发送验证码(先通过滑块再请求后端发码)
|
||||
const sendCode = async () => {
|
||||
if (!canSendCode.value) return
|
||||
|
||||
sendingCode.value = true
|
||||
try {
|
||||
const result = await userStore.sendCode(form.value.phone, 'reset_password')
|
||||
if (result.success) {
|
||||
ElMessage.success('验证码发送成功')
|
||||
startCountdown()
|
||||
}
|
||||
await runWithCaptcha(
|
||||
async (captchaVerifyParam) => {
|
||||
return await userStore.sendCode(form.value.phone, 'reset_password', captchaVerifyParam)
|
||||
},
|
||||
(res) => {
|
||||
if (res.success) {
|
||||
ElMessage.success('验证码发送成功')
|
||||
startCountdown()
|
||||
} else {
|
||||
ElMessage.error(res?.error?.message || '验证码发送失败')
|
||||
}
|
||||
}
|
||||
)
|
||||
} catch (error) {
|
||||
console.error('验证码发送失败:', error)
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user