This commit is contained in:
Mrx
2026-02-28 11:36:26 +08:00
parent ca575800ba
commit 653e1357ac
2 changed files with 24 additions and 18 deletions

View File

@@ -59,6 +59,7 @@ async function sendVerificationCode() {
} }
} }
); );
} }
function startCountdown() { function startCountdown() {

View File

@@ -6,11 +6,13 @@ import { useAgentStore } from '@/stores/agentStore'
import { useUserStore } from '@/stores/userStore' import { useUserStore } from '@/stores/userStore'
import { useRoute, useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
import useApiFetch from '@/composables/useApiFetch' import useApiFetch from '@/composables/useApiFetch'
import { useAliyunCaptcha } from '@/composables/useAliyunCaptcha'
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
const agentStore = useAgentStore() const agentStore = useAgentStore()
const userStore = useUserStore() const userStore = useUserStore()
const { runWithCaptcha } = useAliyunCaptcha()
const appName = import.meta.env.VITE_APP_NAME || '全能查'; const appName = import.meta.env.VITE_APP_NAME || '全能查';
const phoneNumber = ref('') const phoneNumber = ref('')
@@ -84,25 +86,28 @@ async function sendVerificationCode() {
return return
} }
const { data, error } = await useApiFetch('auth/sendSms') // 使用滑块验证码保护发送短信接口
.post({ mobile: phoneNumber.value, actionType: 'agentApply' }) runWithCaptcha(
.json() (captchaVerifyParam) =>
useApiFetch('auth/sendSms')
if (data.value && !error.value) { .post({ mobile: phoneNumber.value, actionType: 'agentApply', captchaVerifyParam })
if (data.value.code === 200) { .json(),
showToast({ message: "获取成功" }); (res) => {
startCountdown() if (res.code === 200) {
// 聚焦到验证码输入框 showToast({ message: "获取成功" });
nextTick(() => { startCountdown()
const verificationCodeInput = document.getElementById('verificationCode'); // 聚焦到验证码输入框
if (verificationCodeInput) { nextTick(() => {
verificationCodeInput.focus(); const verificationCodeInput = document.getElementById('verificationCode');
} if (verificationCodeInput) {
}); verificationCodeInput.focus();
} else { }
showToast(data.value.msg) });
} else {
showToast(res.msg || "获取验证码失败")
}
} }
} );
} }
function startCountdown() { function startCountdown() {