This commit is contained in:
Mrx
2026-02-27 14:49:21 +08:00
parent 4db033c557
commit c9ef3f6f9c
12 changed files with 335 additions and 29 deletions

View File

@@ -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 {