f
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
<input v-model="formData.mobile" id="mobile" type="tel" placeholder="请输入手机号"
|
||||
class="flex-1 border-none outline-none" @click="handleInputClick" />
|
||||
</div>
|
||||
<div class="flex items-center py-3 border-b border-gray-100">
|
||||
<div v-if="needVerificationCode" class="flex items-center py-3 border-b border-gray-100">
|
||||
<label for="verificationCode" class="w-20 font-medium text-gray-700">验证码</label>
|
||||
<input v-model="formData.verificationCode" id="verificationCode" placeholder="请输入验证码"
|
||||
maxlength="6" class="flex-1 border-none outline-none" @click="handleInputClick" />
|
||||
@@ -385,6 +385,11 @@ const isIdCardValid = computed(() => /^\d{17}[\dX]$/i.test(formData.idCard));
|
||||
|
||||
const isLoggedIn = computed(() => userStore.isLoggedIn);
|
||||
|
||||
// 是否需要短信验证码(marriage 产品使用拼图验证,不需要短信验证码)
|
||||
const needVerificationCode = computed(() => {
|
||||
return props.feature !== 'marriage';
|
||||
});
|
||||
|
||||
const buttonText = computed(() => {
|
||||
return isLoggedIn.value ? '立即查询' : '前往登录';
|
||||
});
|
||||
@@ -505,17 +510,25 @@ const isHasInput = (input) => {
|
||||
function handleBindSuccess() {
|
||||
if (pendingPayment.value) {
|
||||
pendingPayment.value = false;
|
||||
if (!needVerificationCode.value) {
|
||||
submitRequestWithCaptcha();
|
||||
} else {
|
||||
submitRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理登录成功的回调
|
||||
function handleLoginSuccess() {
|
||||
if (pendingPayment.value) {
|
||||
pendingPayment.value = false;
|
||||
if (!needVerificationCode.value) {
|
||||
submitRequestWithCaptcha();
|
||||
} else {
|
||||
submitRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理输入框点击事件
|
||||
const handleInputClick = async () => {
|
||||
@@ -555,6 +568,7 @@ function handleSubmit() {
|
||||
return;
|
||||
}
|
||||
|
||||
// 基本字段验证
|
||||
if (
|
||||
!validateField("name", formData.name, (v) => v, "请输入姓名") ||
|
||||
!validateField(
|
||||
@@ -568,25 +582,85 @@ function handleSubmit() {
|
||||
formData.idCard,
|
||||
(v) => isIdCardValid.value,
|
||||
"请输入有效的身份证号码"
|
||||
) ||
|
||||
!validateField(
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 短信验证码验证(仅非 marriage 产品需要)
|
||||
if (needVerificationCode.value) {
|
||||
if (!validateField(
|
||||
"verificationCode",
|
||||
formData.verificationCode,
|
||||
(v) => v,
|
||||
"请输入验证码"
|
||||
)
|
||||
) {
|
||||
)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 检查是否需要绑定手机号
|
||||
if (!userStore.mobile) {
|
||||
pendingPayment.value = true;
|
||||
dialogStore.openBindPhone();
|
||||
} else {
|
||||
// marriage 产品使用拼图验证
|
||||
if (!needVerificationCode.value) {
|
||||
submitRequestWithCaptcha();
|
||||
} else {
|
||||
submitRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getQueryApiUrl() {
|
||||
if (props.type === 'promotion') {
|
||||
return `/query/service_agent/${props.feature}`;
|
||||
}
|
||||
return `/query/service/${props.feature}`;
|
||||
}
|
||||
|
||||
function buildQueryRequestData(payload) {
|
||||
const reqStr = JSON.stringify(payload);
|
||||
const encodeData = aesEncrypt(reqStr, "ff83609b2b24fc73196aac3d3dfb874f");
|
||||
const requestData = { data: encodeData };
|
||||
if (props.type === 'promotion') {
|
||||
requestData.agent_identifier = props.linkIdentifier;
|
||||
}
|
||||
return requestData;
|
||||
}
|
||||
|
||||
function onQuerySuccess(res) {
|
||||
if (res?.code === 200 && res?.data) {
|
||||
queryId.value = res.data.id;
|
||||
if (props.type === 'promotion') {
|
||||
localStorage.setItem("token", res.data.accessToken);
|
||||
localStorage.setItem("refreshAfter", res.data.refreshAfter);
|
||||
localStorage.setItem("accessExpire", res.data.accessExpire);
|
||||
}
|
||||
showPayment.value = true;
|
||||
emit('submit-success', res.data);
|
||||
}
|
||||
}
|
||||
|
||||
// 不需要短信验证码的产品:点击查询时先弹出拼图验证,通过后携带 captcha_verify_param 请求
|
||||
function submitRequestWithCaptcha() {
|
||||
const apiUrl = getQueryApiUrl();
|
||||
runWithCaptcha(
|
||||
(captchaVerifyParam) => {
|
||||
const payload = {
|
||||
name: formData.name,
|
||||
id_card: formData.idCard,
|
||||
mobile: formData.mobile,
|
||||
captcha_verify_param: captchaVerifyParam
|
||||
};
|
||||
return useApiFetch(apiUrl).post(buildQueryRequestData(payload)).json();
|
||||
},
|
||||
(res) => {
|
||||
onQuerySuccess(res);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async function submitRequest() {
|
||||
const req = {
|
||||
@@ -595,37 +669,18 @@ async function submitRequest() {
|
||||
mobile: formData.mobile,
|
||||
code: formData.verificationCode
|
||||
};
|
||||
const reqStr = JSON.stringify(req);
|
||||
const encodeData = aesEncrypt(reqStr, "ff83609b2b24fc73196aac3d3dfb874f");
|
||||
|
||||
let apiUrl = '';
|
||||
let requestData = { data: encodeData };
|
||||
|
||||
if (props.type === 'promotion') {
|
||||
apiUrl = `/query/service_agent/${props.feature}`;
|
||||
requestData.agent_identifier = props.linkIdentifier;
|
||||
} else {
|
||||
apiUrl = `/query/service/${props.feature}`;
|
||||
}
|
||||
const requestData = buildQueryRequestData(req);
|
||||
const apiUrl = getQueryApiUrl();
|
||||
|
||||
const { data, error } = await useApiFetch(apiUrl)
|
||||
.post(requestData)
|
||||
.json();
|
||||
|
||||
if (data.value.code === 200) {
|
||||
queryId.value = data.value.data.id;
|
||||
|
||||
// 推广查询需要保存token
|
||||
if (props.type === 'promotion') {
|
||||
localStorage.setItem("token", data.value.data.accessToken);
|
||||
localStorage.setItem("refreshAfter", data.value.data.refreshAfter);
|
||||
localStorage.setItem("accessExpire", data.value.data.accessExpire);
|
||||
if (data.value?.code === 200) {
|
||||
onQuerySuccess(data.value);
|
||||
}
|
||||
}
|
||||
|
||||
showPayment.value = true;
|
||||
emit('submit-success', data.value.data);
|
||||
}
|
||||
}
|
||||
|
||||
async function sendVerificationCode() {
|
||||
if (isCountingDown.value || !isPhoneNumberValid.value) return;
|
||||
|
||||
@@ -149,12 +149,12 @@ const router = createRouter({
|
||||
component: () => import('@/views/AgentServiceAgreement.vue'),
|
||||
meta: { title: '信息技术服务合同' },
|
||||
},
|
||||
{
|
||||
path: '/inquire/marriage',
|
||||
name: 'inquire-marriage',
|
||||
component: () => import('@/views/Maintenance.vue'),
|
||||
meta: { title: '维护通知' },
|
||||
},
|
||||
// {
|
||||
// path: '/inquire/marriage',
|
||||
// name: 'inquire-marriage',
|
||||
// component: () => import('@/views/Maintenance.vue'),
|
||||
// meta: { title: '维护通知' },
|
||||
// },
|
||||
{
|
||||
path: '/inquire/:feature',
|
||||
name: 'inquire',
|
||||
|
||||
Reference in New Issue
Block a user