From 653e1357aceee7fd30cd71309d2bec62b94554e7 Mon Sep 17 00:00:00 2001 From: Mrx <18278715334@163.com> Date: Sat, 28 Feb 2026 11:36:26 +0800 Subject: [PATCH] f --- src/views/Login.vue | 1 + src/views/Register.vue | 41 +++++++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/views/Login.vue b/src/views/Login.vue index 4ea60a4..25890c2 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -59,6 +59,7 @@ async function sendVerificationCode() { } } ); + } function startCountdown() { diff --git a/src/views/Register.vue b/src/views/Register.vue index ae160d7..20b1819 100644 --- a/src/views/Register.vue +++ b/src/views/Register.vue @@ -6,11 +6,13 @@ import { useAgentStore } from '@/stores/agentStore' import { useUserStore } from '@/stores/userStore' import { useRoute, useRouter } from 'vue-router' import useApiFetch from '@/composables/useApiFetch' +import { useAliyunCaptcha } from '@/composables/useAliyunCaptcha' const router = useRouter() const route = useRoute() const agentStore = useAgentStore() const userStore = useUserStore() +const { runWithCaptcha } = useAliyunCaptcha() const appName = import.meta.env.VITE_APP_NAME || '全能查'; const phoneNumber = ref('') @@ -84,25 +86,28 @@ async function sendVerificationCode() { return } - const { data, error } = await useApiFetch('auth/sendSms') - .post({ mobile: phoneNumber.value, actionType: 'agentApply' }) - .json() - - if (data.value && !error.value) { - if (data.value.code === 200) { - showToast({ message: "获取成功" }); - startCountdown() - // 聚焦到验证码输入框 - nextTick(() => { - const verificationCodeInput = document.getElementById('verificationCode'); - if (verificationCodeInput) { - verificationCodeInput.focus(); - } - }); - } else { - showToast(data.value.msg) + // 使用滑块验证码保护发送短信接口 + runWithCaptcha( + (captchaVerifyParam) => + useApiFetch('auth/sendSms') + .post({ mobile: phoneNumber.value, actionType: 'agentApply', captchaVerifyParam }) + .json(), + (res) => { + if (res.code === 200) { + showToast({ message: "获取成功" }); + startCountdown() + // 聚焦到验证码输入框 + nextTick(() => { + const verificationCodeInput = document.getElementById('verificationCode'); + if (verificationCodeInput) { + verificationCodeInput.focus(); + } + }); + } else { + showToast(res.msg || "获取验证码失败") + } } - } + ); } function startCountdown() {