This commit is contained in:
Mrx
2026-02-28 16:10:29 +08:00
parent 2c97f724f5
commit ced2cd04db
26 changed files with 1950 additions and 82 deletions

View File

@@ -1,12 +1,19 @@
<script setup>
import { ref, computed, nextTick } from "vue";
import { useDialogStore } from "@/stores/dialogStore";
import { useAgentStore } from "@/stores/agentStore";
import { useUserStore } from "@/stores/userStore";
import { useRouter } from "vue-router";
import { showToast } from "vant";
import useApiFetch from "@/composables/useApiFetch";
import { useAliyunCaptcha } from "@/composables/useAliyunCaptcha";
const emit = defineEmits(['bind-success'])
const router = useRouter();
const dialogStore = useDialogStore();
const agentStore = useAgentStore();
const userStore = useUserStore();
const { runWithCaptcha } = useAliyunCaptcha();
const appName = import.meta.env.VITE_APP_NAME || '真爱查';
const phoneNumber = ref("");
const verificationCode = ref("");
@@ -37,25 +44,29 @@ async function sendVerificationCode() {
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('bindPhoneVerificationCode');
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('bindPhoneVerificationCode');
if (verificationCodeInput) {
verificationCodeInput.focus();
}
});
} else {
showToast(res.msg);
}
}
}
);
}
function startCountdown() {