diff --git a/index.html b/index.html index a4a568f..dd85210 100644 --- a/index.html +++ b/index.html @@ -176,11 +176,19 @@ + +
加载中
+
diff --git a/src/auto-imports.d.ts b/src/auto-imports.d.ts index 3a7330e..b965e9a 100644 --- a/src/auto-imports.d.ts +++ b/src/auto-imports.d.ts @@ -117,6 +117,7 @@ declare global { const useActiveElement: typeof import('@vueuse/core')['useActiveElement'] const useAgent: typeof import('./composables/useAgent.js')['useAgent'] const useAgentStore: typeof import('./stores/agentStore.js')['useAgentStore'] + const useAliyunCaptcha: typeof import('./composables/useAliyunCaptcha.js')['default'] const useAnimate: typeof import('@vueuse/core')['useAnimate'] const useApiFetch: typeof import('./composables/useApiFetch.js')['default'] const useArrayDifference: typeof import('@vueuse/core')['useArrayDifference'] diff --git a/src/components/AgentApplicationForm.vue b/src/components/AgentApplicationForm.vue index f99d571..0815d5c 100644 --- a/src/components/AgentApplicationForm.vue +++ b/src/components/AgentApplicationForm.vue @@ -122,6 +122,7 @@ const router = useRouter(); const show = defineModel("show"); import { useCascaderAreaData } from "@vant/area-data"; import { showToast } from "vant"; // 引入 showToast 方法 +import { useAliyunCaptcha } from "@/composables/useAliyunCaptcha"; const emit = defineEmits(); // 确保 emit 可以正确使用 const props = defineProps({ ancestor: { @@ -150,6 +151,7 @@ const loadingSms = ref(false); // 控制验证码按钮的loading状态 const isCountingDown = ref(false); const isAgreed = ref(false); const countdown = ref(60); +const { runWithCaptcha } = useAliyunCaptcha(); const onFinish = ({ selectedOptions }) => { showCascader.value = false; form.value.region = selectedOptions.map((option) => option.text).join("/"); @@ -171,20 +173,25 @@ 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); - } - } + await runWithCaptcha( + (captchaVerifyParam) => + useApiFetch("auth/sendSms") + .post({ + mobile: form.value.mobile, + actionType: "agentApply", + captchaVerifyParam, + }) + .json(), + (res) => { + loadingSms.value = false; + if (res.code === 200) { + showToast({ message: "获取成功" }); + startCountdown(); + } else { + showToast(res.msg || "获取失败"); + } + }, + ); }; let timer = null; diff --git a/src/components/BindPhoneDialog.vue b/src/components/BindPhoneDialog.vue index 0ce303e..fe0b366 100644 --- a/src/components/BindPhoneDialog.vue +++ b/src/components/BindPhoneDialog.vue @@ -1,6 +1,7 @@