From 030ed260c11a3249b78d5690591ab79198e6235a Mon Sep 17 00:00:00 2001 From: Mrx <18278715334@163.com> Date: Sat, 28 Feb 2026 12:18:33 +0800 Subject: [PATCH] f --- src/components/AgentApplicationForm.vue | 32 ++++++++++---------- src/components/BindPhoneDialog.vue | 38 ++++++++++++----------- src/components/BindPhoneOnlyDialog.vue | 40 ++++++++++++++----------- src/components/RealNameAuthDialog.vue | 28 +++++++++-------- src/views/Register.vue | 39 +++++++++++++----------- vite.config.js | 4 +-- 6 files changed, 98 insertions(+), 83 deletions(-) diff --git a/src/components/AgentApplicationForm.vue b/src/components/AgentApplicationForm.vue index 96b1d4f..54c0dfc 100644 --- a/src/components/AgentApplicationForm.vue +++ b/src/components/AgentApplicationForm.vue @@ -126,7 +126,9 @@ const router = useRouter(); const show = defineModel("show"); import { useCascaderAreaData } from "@vant/area-data"; -import { showToast } from "vant"; // 引入 showToast 方法 +import { showToast } from "vant"; +import useApiFetch from "@/composables/useApiFetch"; +import { useAliyunCaptcha } from "@/composables/useAliyunCaptcha"; const emit = defineEmits(); // 确保 emit 可以正确使用 const props = defineProps({ isSelf: { @@ -148,6 +150,7 @@ const form = ref({ const showCascader = ref(false); const cascaderValue = ref(""); const options = useCascaderAreaData(); +const { runWithCaptcha } = useAliyunCaptcha(); const loadingSms = ref(false); // 控制验证码按钮的loading状态 const isCountingDown = ref(false); const isAgreed = ref(false); @@ -172,21 +175,20 @@ const getSmsCode = async () => { } loadingSms.value = true; - - const { data, error } = await useApiFetch("auth/sendSms") - .post({ mobile: form.value.mobile, actionType: "agentApply" }) - .json(); - - loadingSms.value = false; - - if (data.value && !error.value) { - if (data.value.code === 200) { - showToast({ message: "获取成功" }); - startCountdown(); // 启动倒计时 - } else { - showToast(data.value.msg); + runWithCaptcha( + (captchaVerifyParam) => useApiFetch("auth/sendSms") + .post({ mobile: form.value.mobile, actionType: "agentApply", captchaVerifyParam }) + .json(), + (result) => { + loadingSms.value = false; + if (result && result.code === 200) { + showToast({ message: "获取成功" }); + startCountdown(); + } else if (result) { + showToast(result.msg || "发送失败"); + } } - } + ); }; let timer = null; diff --git a/src/components/BindPhoneDialog.vue b/src/components/BindPhoneDialog.vue index e80dad7..eca52e2 100644 --- a/src/components/BindPhoneDialog.vue +++ b/src/components/BindPhoneDialog.vue @@ -6,6 +6,7 @@ import { useAgentStore } from "@/stores/agentStore"; import { useUserStore } from "@/stores/userStore"; import { showToast } from "vant"; import useApiFetch from "@/composables/useApiFetch"; +import { useAliyunCaptcha } from "@/composables/useAliyunCaptcha"; import { registerByInviteCode } from "@/api/agent"; const emit = defineEmits(['register-success']) @@ -14,6 +15,7 @@ const route = useRoute(); const dialogStore = useDialogStore(); const agentStore = useAgentStore(); const userStore = useUserStore(); +const { runWithCaptcha } = useAliyunCaptcha(); const phoneNumber = ref(""); const verificationCode = ref(""); const inviteCode = ref(""); @@ -80,25 +82,25 @@ async function sendVerificationCode() { return; } const actionType = hasAccount.value ? "bindMobile" : "agentApply"; - const { data, error } = await useApiFetch("auth/sendSms") - .post({ mobile: phoneNumber.value, actionType }) - .json(); - - if (data.value && !error.value) { - if (data.value.code === 200) { - showToast({ message: "获取成功" }); - startCountdown(); - // 聚焦到验证码输入框 - nextTick(() => { - const verificationCodeInput = document.getElementById('registerVerificationCode'); - if (verificationCodeInput) { - verificationCodeInput.focus(); - } - }); - } else { - showToast(data.value.msg); + runWithCaptcha( + (captchaVerifyParam) => useApiFetch("auth/sendSms") + .post({ mobile: phoneNumber.value, actionType, captchaVerifyParam }) + .json(), + (result) => { + if (result && result.code === 200) { + showToast({ message: "获取成功" }); + startCountdown(); + nextTick(() => { + const verificationCodeInput = document.getElementById('registerVerificationCode'); + if (verificationCodeInput) { + verificationCodeInput.focus(); + } + }); + } else if (result) { + showToast(result.msg || "发送失败"); + } } - } + ); } function startCountdown() { diff --git a/src/components/BindPhoneOnlyDialog.vue b/src/components/BindPhoneOnlyDialog.vue index 6cd93d9..a9fd1a0 100644 --- a/src/components/BindPhoneOnlyDialog.vue +++ b/src/components/BindPhoneOnlyDialog.vue @@ -1,12 +1,16 @@