f
This commit is contained in:
@@ -126,7 +126,9 @@
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const show = defineModel("show");
|
const show = defineModel("show");
|
||||||
import { useCascaderAreaData } from "@vant/area-data";
|
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 emit = defineEmits(); // 确保 emit 可以正确使用
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
isSelf: {
|
isSelf: {
|
||||||
@@ -148,6 +150,7 @@ const form = ref({
|
|||||||
const showCascader = ref(false);
|
const showCascader = ref(false);
|
||||||
const cascaderValue = ref("");
|
const cascaderValue = ref("");
|
||||||
const options = useCascaderAreaData();
|
const options = useCascaderAreaData();
|
||||||
|
const { runWithCaptcha } = useAliyunCaptcha();
|
||||||
const loadingSms = ref(false); // 控制验证码按钮的loading状态
|
const loadingSms = ref(false); // 控制验证码按钮的loading状态
|
||||||
const isCountingDown = ref(false);
|
const isCountingDown = ref(false);
|
||||||
const isAgreed = ref(false);
|
const isAgreed = ref(false);
|
||||||
@@ -172,21 +175,20 @@ const getSmsCode = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadingSms.value = true;
|
loadingSms.value = true;
|
||||||
|
runWithCaptcha(
|
||||||
const { data, error } = await useApiFetch("auth/sendSms")
|
(captchaVerifyParam) => useApiFetch("auth/sendSms")
|
||||||
.post({ mobile: form.value.mobile, actionType: "agentApply" })
|
.post({ mobile: form.value.mobile, actionType: "agentApply", captchaVerifyParam })
|
||||||
.json();
|
.json(),
|
||||||
|
(result) => {
|
||||||
loadingSms.value = false;
|
loadingSms.value = false;
|
||||||
|
if (result && result.code === 200) {
|
||||||
if (data.value && !error.value) {
|
showToast({ message: "获取成功" });
|
||||||
if (data.value.code === 200) {
|
startCountdown();
|
||||||
showToast({ message: "获取成功" });
|
} else if (result) {
|
||||||
startCountdown(); // 启动倒计时
|
showToast(result.msg || "发送失败");
|
||||||
} else {
|
}
|
||||||
showToast(data.value.msg);
|
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
};
|
};
|
||||||
let timer = null;
|
let timer = null;
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { useAgentStore } from "@/stores/agentStore";
|
|||||||
import { useUserStore } from "@/stores/userStore";
|
import { useUserStore } from "@/stores/userStore";
|
||||||
import { showToast } from "vant";
|
import { showToast } from "vant";
|
||||||
import useApiFetch from "@/composables/useApiFetch";
|
import useApiFetch from "@/composables/useApiFetch";
|
||||||
|
import { useAliyunCaptcha } from "@/composables/useAliyunCaptcha";
|
||||||
import { registerByInviteCode } from "@/api/agent";
|
import { registerByInviteCode } from "@/api/agent";
|
||||||
|
|
||||||
const emit = defineEmits(['register-success'])
|
const emit = defineEmits(['register-success'])
|
||||||
@@ -14,6 +15,7 @@ const route = useRoute();
|
|||||||
const dialogStore = useDialogStore();
|
const dialogStore = useDialogStore();
|
||||||
const agentStore = useAgentStore();
|
const agentStore = useAgentStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
const { runWithCaptcha } = useAliyunCaptcha();
|
||||||
const phoneNumber = ref("");
|
const phoneNumber = ref("");
|
||||||
const verificationCode = ref("");
|
const verificationCode = ref("");
|
||||||
const inviteCode = ref("");
|
const inviteCode = ref("");
|
||||||
@@ -80,25 +82,25 @@ async function sendVerificationCode() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const actionType = hasAccount.value ? "bindMobile" : "agentApply";
|
const actionType = hasAccount.value ? "bindMobile" : "agentApply";
|
||||||
const { data, error } = await useApiFetch("auth/sendSms")
|
runWithCaptcha(
|
||||||
.post({ mobile: phoneNumber.value, actionType })
|
(captchaVerifyParam) => useApiFetch("auth/sendSms")
|
||||||
.json();
|
.post({ mobile: phoneNumber.value, actionType, captchaVerifyParam })
|
||||||
|
.json(),
|
||||||
if (data.value && !error.value) {
|
(result) => {
|
||||||
if (data.value.code === 200) {
|
if (result && result.code === 200) {
|
||||||
showToast({ message: "获取成功" });
|
showToast({ message: "获取成功" });
|
||||||
startCountdown();
|
startCountdown();
|
||||||
// 聚焦到验证码输入框
|
nextTick(() => {
|
||||||
nextTick(() => {
|
const verificationCodeInput = document.getElementById('registerVerificationCode');
|
||||||
const verificationCodeInput = document.getElementById('registerVerificationCode');
|
if (verificationCodeInput) {
|
||||||
if (verificationCodeInput) {
|
verificationCodeInput.focus();
|
||||||
verificationCodeInput.focus();
|
}
|
||||||
}
|
});
|
||||||
});
|
} else if (result) {
|
||||||
} else {
|
showToast(result.msg || "发送失败");
|
||||||
showToast(data.value.msg);
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function startCountdown() {
|
function startCountdown() {
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, nextTick } from "vue";
|
import { ref, computed, nextTick } from "vue";
|
||||||
import { useDialogStore } from "@/stores/dialogStore";
|
import { useDialogStore } from "@/stores/dialogStore";
|
||||||
|
import { showToast } from "vant";
|
||||||
|
import useApiFetch from "@/composables/useApiFetch";
|
||||||
|
import { useAliyunCaptcha } from "@/composables/useAliyunCaptcha";
|
||||||
|
|
||||||
const emit = defineEmits(['bind-success'])
|
const emit = defineEmits(['bind-success'])
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const dialogStore = useDialogStore();
|
const dialogStore = useDialogStore();
|
||||||
const agentStore = useAgentStore();
|
const agentStore = useAgentStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
const { runWithCaptcha } = useAliyunCaptcha();
|
||||||
const phoneNumber = ref("");
|
const phoneNumber = ref("");
|
||||||
const verificationCode = ref("");
|
const verificationCode = ref("");
|
||||||
const isCountingDown = ref(false);
|
const isCountingDown = ref(false);
|
||||||
@@ -36,25 +40,25 @@ async function sendVerificationCode() {
|
|||||||
showToast({ message: "请输入有效的手机号" });
|
showToast({ message: "请输入有效的手机号" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { data, error } = await useApiFetch("auth/sendSms")
|
runWithCaptcha(
|
||||||
.post({ mobile: phoneNumber.value, actionType: "bindMobile" })
|
(captchaVerifyParam) => useApiFetch("auth/sendSms")
|
||||||
.json();
|
.post({ mobile: phoneNumber.value, actionType: "bindMobile", captchaVerifyParam })
|
||||||
|
.json(),
|
||||||
if (data.value && !error.value) {
|
(result) => {
|
||||||
if (data.value.code === 200) {
|
if (result && result.code === 200) {
|
||||||
showToast({ message: "获取成功" });
|
showToast({ message: "获取成功" });
|
||||||
startCountdown();
|
startCountdown();
|
||||||
// 聚焦到验证码输入框
|
nextTick(() => {
|
||||||
nextTick(() => {
|
const verificationCodeInput = document.getElementById('bindPhoneVerificationCode');
|
||||||
const verificationCodeInput = document.getElementById('bindPhoneVerificationCode');
|
if (verificationCodeInput) {
|
||||||
if (verificationCodeInput) {
|
verificationCodeInput.focus();
|
||||||
verificationCodeInput.focus();
|
}
|
||||||
}
|
});
|
||||||
});
|
} else if (result) {
|
||||||
} else {
|
showToast(result.msg || "发送失败");
|
||||||
showToast(data.value.msg);
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function startCountdown() {
|
function startCountdown() {
|
||||||
|
|||||||
@@ -6,11 +6,14 @@ import { useAgentStore } from "@/stores/agentStore";
|
|||||||
import { useUserStore } from "@/stores/userStore";
|
import { useUserStore } from "@/stores/userStore";
|
||||||
import { showToast } from "vant";
|
import { showToast } from "vant";
|
||||||
import { realNameAuth } from "@/api/agent";
|
import { realNameAuth } from "@/api/agent";
|
||||||
|
import useApiFetch from "@/composables/useApiFetch";
|
||||||
|
import { useAliyunCaptcha } from "@/composables/useAliyunCaptcha";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const dialogStore = useDialogStore();
|
const dialogStore = useDialogStore();
|
||||||
const agentStore = useAgentStore();
|
const agentStore = useAgentStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
const { runWithCaptcha } = useAliyunCaptcha();
|
||||||
// 表单数据
|
// 表单数据
|
||||||
const realName = ref("");
|
const realName = ref("");
|
||||||
const idCard = ref("");
|
const idCard = ref("");
|
||||||
@@ -52,25 +55,26 @@ const canSubmit = computed(() => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 发送验证码
|
// 发送验证码(使用阿里云滑块验证码防刷)
|
||||||
async function sendVerificationCode() {
|
async function sendVerificationCode() {
|
||||||
if (isCountingDown.value || !isPhoneNumberValid.value) return;
|
if (isCountingDown.value || !isPhoneNumberValid.value) return;
|
||||||
if (!isPhoneNumberValid.value) {
|
if (!isPhoneNumberValid.value) {
|
||||||
showToast({ message: "请输入有效的手机号" });
|
showToast({ message: "请输入有效的手机号" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { data, error } = await useApiFetch("auth/sendSms")
|
runWithCaptcha(
|
||||||
.post({ mobile: phoneNumber.value, actionType: "realName" })
|
(captchaVerifyParam) => useApiFetch("auth/sendSms")
|
||||||
.json();
|
.post({ mobile: phoneNumber.value, actionType: "realName", captchaVerifyParam })
|
||||||
|
.json(),
|
||||||
if (data.value && !error.value) {
|
(result) => {
|
||||||
if (data.value.code === 200) {
|
if (result && result.code === 200) {
|
||||||
showToast({ message: "获取成功" });
|
showToast({ message: "获取成功" });
|
||||||
startCountdown();
|
startCountdown();
|
||||||
} else {
|
} else if (result) {
|
||||||
showToast(data.value.msg);
|
showToast(result.msg || "发送失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function startCountdown() {
|
function startCountdown() {
|
||||||
|
|||||||
@@ -6,11 +6,13 @@ import { useAgentStore } from '@/stores/agentStore'
|
|||||||
import { useUserStore } from '@/stores/userStore'
|
import { useUserStore } from '@/stores/userStore'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import useApiFetch from '@/composables/useApiFetch'
|
import useApiFetch from '@/composables/useApiFetch'
|
||||||
|
import { useAliyunCaptcha } from '@/composables/useAliyunCaptcha'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const agentStore = useAgentStore()
|
const agentStore = useAgentStore()
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
|
const { runWithCaptcha } = useAliyunCaptcha()
|
||||||
|
|
||||||
const phoneNumber = ref('')
|
const phoneNumber = ref('')
|
||||||
const verificationCode = ref('')
|
const verificationCode = ref('')
|
||||||
@@ -69,25 +71,26 @@ async function sendVerificationCode() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data, error } = await useApiFetch('auth/sendSms')
|
// 使用阿里云滑块验证码保护发送短信接口
|
||||||
.post({ mobile: phoneNumber.value, actionType: 'agentApply' })
|
runWithCaptcha(
|
||||||
.json()
|
(captchaVerifyParam) => useApiFetch('auth/sendSms')
|
||||||
|
.post({ mobile: phoneNumber.value, actionType: 'agentApply', captchaVerifyParam })
|
||||||
if (data.value && !error.value) {
|
.json(),
|
||||||
if (data.value.code === 200) {
|
(result) => {
|
||||||
showToast({ message: "获取成功" });
|
if (result && result.code === 200) {
|
||||||
startCountdown()
|
showToast({ message: "获取成功" });
|
||||||
// 聚焦到验证码输入框
|
startCountdown();
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
const verificationCodeInput = document.getElementById('verificationCode');
|
const verificationCodeInput = document.getElementById('verificationCode');
|
||||||
if (verificationCodeInput) {
|
if (verificationCodeInput) {
|
||||||
verificationCodeInput.focus();
|
verificationCodeInput.focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else if (result) {
|
||||||
showToast(data.value.msg)
|
showToast(result.msg || "发送失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function startCountdown() {
|
function startCountdown() {
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ export default defineConfig({
|
|||||||
strictPort: true, // 如果端口被占用则抛出错误而不是使用下一个可用端口
|
strictPort: true, // 如果端口被占用则抛出错误而不是使用下一个可用端口
|
||||||
proxy: {
|
proxy: {
|
||||||
"/api/v1": {
|
"/api/v1": {
|
||||||
target: "http://127.0.0.1:8888", // 本地接口地址
|
// target: "http://127.0.0.1:8888", // 本地接口地址
|
||||||
// target: "https://www.onecha.cn", // 修改为带 www 的域名,避免 301 重定向
|
target: "https://www.onecha.cn", // 修改为带 www 的域名,避免 301 重定向
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path) => path, // 可选:确保路径不被修改
|
rewrite: (path) => path, // 可选:确保路径不被修改
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user