This commit is contained in:
Mrx
2026-02-28 12:45:13 +08:00
parent 1934fb1789
commit 72bb706023
25 changed files with 2633 additions and 31 deletions

View File

@@ -1,10 +1,12 @@
<script setup>
import { ref, computed, nextTick } from "vue";
import { useDialogStore } from "@/stores/dialogStore";
import { useAliyunCaptcha } from "@/composables/useAliyunCaptcha";
const emit = defineEmits(['bind-success'])
const router = useRouter();
const dialogStore = useDialogStore();
const { runWithCaptcha } = useAliyunCaptcha();
const agentStore = useAgentStore();
const userStore = useUserStore();
const phoneNumber = ref("");
@@ -30,31 +32,30 @@ const canBind = computed(() => {
);
});
async function sendVerificationCode() {
function sendVerificationCode() {
if (isCountingDown.value || !isPhoneNumberValid.value) return;
if (!isPhoneNumberValid.value) {
showToast({ message: "请输入有效的手机号" });
return;
}
const { data, error } = await useApiFetch("auth/sendSms")
.post({ mobile: phoneNumber.value, actionType: "bindMobile" })
.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: "bindMobile", 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() {

View File

@@ -1,8 +1,11 @@
<script setup>
import { ref, computed } from "vue";
import { useDialogStore } from "@/stores/dialogStore";
import { useAliyunCaptcha } from "@/composables/useAliyunCaptcha";
const router = useRouter();
const dialogStore = useDialogStore();
const { runWithCaptcha } = useAliyunCaptcha();
const agentStore = useAgentStore();
const userStore = useUserStore();
import { showToast } from "vant";
@@ -48,24 +51,26 @@ const canSubmit = computed(() => {
});
// 发送验证码
async function sendVerificationCode() {
function sendVerificationCode() {
if (isCountingDown.value || !isPhoneNumberValid.value) return;
if (!isPhoneNumberValid.value) {
showToast({ message: "请输入有效的手机号" });
return;
}
const { data, error } = await useApiFetch("auth/sendSms")
.post({ mobile: phoneNumber.value, actionType: "realName" })
.json();
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: phoneNumber.value, actionType: "realName", captchaVerifyParam })
.json(),
(res) => {
if (res?.code === 200) {
showToast({ message: "获取成功" });
startCountdown();
} else {
showToast(res?.msg || "获取失败");
}
}
}
);
}
function startCountdown() {