This commit is contained in:
Mrx
2026-02-28 12:18:33 +08:00
parent 576ab0c362
commit 030ed260c1
6 changed files with 98 additions and 83 deletions

View File

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