f
This commit is contained in:
@@ -35,7 +35,7 @@
|
|||||||
<input v-model="formData.mobile" id="mobile" type="tel" placeholder="请输入手机号"
|
<input v-model="formData.mobile" id="mobile" type="tel" placeholder="请输入手机号"
|
||||||
class="flex-1 border-none outline-none" @click="handleInputClick" />
|
class="flex-1 border-none outline-none" @click="handleInputClick" />
|
||||||
</div>
|
</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>
|
<label for="verificationCode" class="w-20 font-medium text-gray-700">验证码</label>
|
||||||
<input v-model="formData.verificationCode" id="verificationCode" placeholder="请输入验证码"
|
<input v-model="formData.verificationCode" id="verificationCode" placeholder="请输入验证码"
|
||||||
maxlength="6" class="flex-1 border-none outline-none" @click="handleInputClick" />
|
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);
|
const isLoggedIn = computed(() => userStore.isLoggedIn);
|
||||||
|
|
||||||
|
// 是否需要短信验证码(marriage 产品使用拼图验证,不需要短信验证码)
|
||||||
|
const needVerificationCode = computed(() => {
|
||||||
|
return props.feature !== 'marriage';
|
||||||
|
});
|
||||||
|
|
||||||
const buttonText = computed(() => {
|
const buttonText = computed(() => {
|
||||||
return isLoggedIn.value ? '立即查询' : '前往登录';
|
return isLoggedIn.value ? '立即查询' : '前往登录';
|
||||||
});
|
});
|
||||||
@@ -505,7 +510,11 @@ const isHasInput = (input) => {
|
|||||||
function handleBindSuccess() {
|
function handleBindSuccess() {
|
||||||
if (pendingPayment.value) {
|
if (pendingPayment.value) {
|
||||||
pendingPayment.value = false;
|
pendingPayment.value = false;
|
||||||
submitRequest();
|
if (!needVerificationCode.value) {
|
||||||
|
submitRequestWithCaptcha();
|
||||||
|
} else {
|
||||||
|
submitRequest();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,7 +522,11 @@ function handleBindSuccess() {
|
|||||||
function handleLoginSuccess() {
|
function handleLoginSuccess() {
|
||||||
if (pendingPayment.value) {
|
if (pendingPayment.value) {
|
||||||
pendingPayment.value = false;
|
pendingPayment.value = false;
|
||||||
submitRequest();
|
if (!needVerificationCode.value) {
|
||||||
|
submitRequestWithCaptcha();
|
||||||
|
} else {
|
||||||
|
submitRequest();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -555,6 +568,7 @@ function handleSubmit() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 基本字段验证
|
||||||
if (
|
if (
|
||||||
!validateField("name", formData.name, (v) => v, "请输入姓名") ||
|
!validateField("name", formData.name, (v) => v, "请输入姓名") ||
|
||||||
!validateField(
|
!validateField(
|
||||||
@@ -568,15 +582,21 @@ function handleSubmit() {
|
|||||||
formData.idCard,
|
formData.idCard,
|
||||||
(v) => isIdCardValid.value,
|
(v) => isIdCardValid.value,
|
||||||
"请输入有效的身份证号码"
|
"请输入有效的身份证号码"
|
||||||
) ||
|
)
|
||||||
!validateField(
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 短信验证码验证(仅非 marriage 产品需要)
|
||||||
|
if (needVerificationCode.value) {
|
||||||
|
if (!validateField(
|
||||||
"verificationCode",
|
"verificationCode",
|
||||||
formData.verificationCode,
|
formData.verificationCode,
|
||||||
(v) => v,
|
(v) => v,
|
||||||
"请输入验证码"
|
"请输入验证码"
|
||||||
)
|
)) {
|
||||||
) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否需要绑定手机号
|
// 检查是否需要绑定手机号
|
||||||
@@ -584,10 +604,64 @@ function handleSubmit() {
|
|||||||
pendingPayment.value = true;
|
pendingPayment.value = true;
|
||||||
dialogStore.openBindPhone();
|
dialogStore.openBindPhone();
|
||||||
} else {
|
} else {
|
||||||
submitRequest();
|
// 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() {
|
async function submitRequest() {
|
||||||
const req = {
|
const req = {
|
||||||
name: formData.name,
|
name: formData.name,
|
||||||
@@ -595,38 +669,19 @@ async function submitRequest() {
|
|||||||
mobile: formData.mobile,
|
mobile: formData.mobile,
|
||||||
code: formData.verificationCode
|
code: formData.verificationCode
|
||||||
};
|
};
|
||||||
const reqStr = JSON.stringify(req);
|
const requestData = buildQueryRequestData(req);
|
||||||
const encodeData = aesEncrypt(reqStr, "ff83609b2b24fc73196aac3d3dfb874f");
|
const apiUrl = getQueryApiUrl();
|
||||||
|
|
||||||
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 { data, error } = await useApiFetch(apiUrl)
|
const { data, error } = await useApiFetch(apiUrl)
|
||||||
.post(requestData)
|
.post(requestData)
|
||||||
.json();
|
.json();
|
||||||
|
|
||||||
if (data.value.code === 200) {
|
if (data.value?.code === 200) {
|
||||||
queryId.value = data.value.data.id;
|
onQuerySuccess(data.value);
|
||||||
|
|
||||||
// 推广查询需要保存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);
|
|
||||||
}
|
|
||||||
|
|
||||||
showPayment.value = true;
|
|
||||||
emit('submit-success', data.value.data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function sendVerificationCode() {
|
async function sendVerificationCode() {
|
||||||
if (isCountingDown.value || !isPhoneNumberValid.value) return;
|
if (isCountingDown.value || !isPhoneNumberValid.value) return;
|
||||||
if (!isPhoneNumberValid.value) {
|
if (!isPhoneNumberValid.value) {
|
||||||
|
|||||||
@@ -149,12 +149,12 @@ const router = createRouter({
|
|||||||
component: () => import('@/views/AgentServiceAgreement.vue'),
|
component: () => import('@/views/AgentServiceAgreement.vue'),
|
||||||
meta: { title: '信息技术服务合同' },
|
meta: { title: '信息技术服务合同' },
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
path: '/inquire/marriage',
|
// path: '/inquire/marriage',
|
||||||
name: 'inquire-marriage',
|
// name: 'inquire-marriage',
|
||||||
component: () => import('@/views/Maintenance.vue'),
|
// component: () => import('@/views/Maintenance.vue'),
|
||||||
meta: { title: '维护通知' },
|
// meta: { title: '维护通知' },
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
path: '/inquire/:feature',
|
path: '/inquire/:feature',
|
||||||
name: 'inquire',
|
name: 'inquire',
|
||||||
|
|||||||
Reference in New Issue
Block a user