Commit fbfc9905 authored by 郭志伟's avatar 郭志伟

fix: 万家保险种添加生日校验;顾问问卷问题修复

parent d097ebb0
...@@ -222,3 +222,16 @@ export function getRealAge(strBirthday) { ...@@ -222,3 +222,16 @@ export function getRealAge(strBirthday) {
} }
return returnAge; //返回周岁年龄 return returnAge; //返回周岁年龄
} }
export function getBirthDate(idCard) {
let birthday = "";
if (idCard) {
if (idCard.length == 15) {
birthday = "19" + idCard.substr(6, 6);
} else if (idCard.length == 18) {
birthday = idCard.substr(6, 8);
}
birthday = birthday.replace(/(.{4})(.{2})/, "$1-$2-");
}
return birthday;
}
...@@ -175,7 +175,7 @@ export default { ...@@ -175,7 +175,7 @@ export default {
birthday: "1990-01-01", birthday: "1990-01-01",
socialSecurity: "", socialSecurity: "",
annualIncome: "10万", annualIncome: "10万",
loan: "房贷", loan: "贷款",
addressCode: "北京市,北京市", addressCode: "北京市,北京市",
questionType: "", questionType: "",
userName: "", userName: "",
...@@ -270,7 +270,7 @@ export default { ...@@ -270,7 +270,7 @@ export default {
], ],
// 贷款 // 贷款
loanOptions: [ loanOptions: [
"房贷", "贷款",
"1000元", "1000元",
"2000元", "2000元",
"3000元", "3000元",
...@@ -280,7 +280,7 @@ export default { ...@@ -280,7 +280,7 @@ export default {
"7000元", "7000元",
"8000元", "8000元",
"9000元", "9000元",
"1万元以上", "1万元",
"1万元以上" "1万元以上"
], ],
solveOptions: [ solveOptions: [
...@@ -300,8 +300,11 @@ export default { ...@@ -300,8 +300,11 @@ export default {
currentStep(val) { currentStep(val) {
this.$forceUpdate(); this.$forceUpdate();
if (val === 3) { if (val === 3) {
if (this.formData.annualIncome === "10万") {
this.setPickerDefaultVal("income", "10万", this.incomeOptions);
this.$refs["income"].refreshColumns(); this.$refs["income"].refreshColumns();
} }
}
if (val === 4) { if (val === 4) {
this.$refs["loan"].refreshColumns(); this.$refs["loan"].refreshColumns();
} }
...@@ -310,7 +313,6 @@ export default { ...@@ -310,7 +313,6 @@ export default {
} }
} }
}, },
mounted() {},
methods: { methods: {
nextQuestion() { nextQuestion() {
const { currentStep, stepTips, formData } = this; const { currentStep, stepTips, formData } = this;
...@@ -344,6 +346,15 @@ export default { ...@@ -344,6 +346,15 @@ export default {
} }
this.formData[type] = value; this.formData[type] = value;
}, },
setPickerDefaultVal(refName, value, options) {
setTimeout(() => {
const $picker = this.$refs[refName];
$picker.setColumnIndex(
0,
options.findIndex(item => item === value)
);
});
},
async onSubmit() { async onSubmit() {
const { formData } = this; const { formData } = this;
const { socialSecurity, gender } = formData; const { socialSecurity, gender } = formData;
......
...@@ -97,6 +97,7 @@ import localStorage from "@/service/localStorage"; ...@@ -97,6 +97,7 @@ import localStorage from "@/service/localStorage";
import Detail from "@/api/detail.zhongan.yiwai"; import Detail from "@/api/detail.zhongan.yiwai";
import { trail, list } from "@/api/product"; import { trail, list } from "@/api/product";
import { isIdNo } from "@/service/validation"; import { isIdNo } from "@/service/validation";
import { getRealAge, getBirthDate } from "@/service/utils";
export default { export default {
name: "GoodsDetail-AI", name: "GoodsDetail-AI",
...@@ -311,6 +312,26 @@ export default { ...@@ -311,6 +312,26 @@ export default {
delete this.subFormData.insuredUserInfo; delete this.subFormData.insuredUserInfo;
} }
}, },
getRealIdNo() {
const { relation, userInfoSecId: userId, idNo: idNoMask } = this.formData;
const { selfSecId: holderUserId, selfIdNo: holderIdNoMask } = this.formData;
let currentIdNo = !relation || relation === "1" ? holderIdNoMask : idNoMask;
const currentUserId = !relation || relation === "1" ? holderUserId : userId;
const familyList = this.$refs["insureForm"].familyList;
if (!currentIdNo) return "";
currentIdNo =
currentIdNo.indexOf("**") > -1
? familyList.find(item => item.userInfoSecId === currentUserId).idNo
: currentIdNo;
return currentIdNo;
},
checkAgeInRange() {
const currentIdNo = this.getRealIdNo();
if (!currentIdNo) return;
const birthday = getBirthDate(currentIdNo);
const realAge = getRealAge(birthday);
return realAge >= 18 && realAge <= 65;
},
async getDetail() { async getDetail() {
this.goodId = this.$route.query.id; this.goodId = this.$route.query.id;
const res = await list(); const res = await list();
...@@ -330,7 +351,8 @@ export default { ...@@ -330,7 +351,8 @@ export default {
let idNoWho = !relation || relation === "1" ? selfIdNo : idNo; let idNoWho = !relation || relation === "1" ? selfIdNo : idNo;
let idWho = !relation || relation === "1" ? selfSecId : userInfoSecId; let idWho = !relation || relation === "1" ? selfSecId : userInfoSecId;
idWho = idNoWho.indexOf("**") > -1 ? idWho || undefined : undefined; idWho = idNoWho.indexOf("**") > -1 ? idWho || undefined : undefined;
if (!idNoWho && !amountInsured) return; this.isCalPrice = this.checkAgeInRange();
if (!this.isCalPrice || (!idNoWho && !amountInsured)) return;
const _param = { const _param = {
productNo: this.goodId, productNo: this.goodId,
productUserInfo: { productUserInfo: {
......
...@@ -90,10 +90,12 @@ import ProtocolRead from "./modules/ProtocolRead"; ...@@ -90,10 +90,12 @@ import ProtocolRead from "./modules/ProtocolRead";
import NavTab from "./modules/NavTab"; import NavTab from "./modules/NavTab";
import detailLoginMixin from "./modules/detailLogin.mixin"; import detailLoginMixin from "./modules/detailLogin.mixin";
import fromNow from "date-fns/formatDistanceToNowStrict";
import localStorage from "@/service/localStorage"; import localStorage from "@/service/localStorage";
import Detail from "@/api/detail.huatai.zhongjixian"; import Detail from "@/api/detail.huatai.zhongjixian";
import { trail, list } from "@/api/product"; import { trail, list } from "@/api/product";
import { isIdNo } from "@/service/validation"; import { isIdNo } from "@/service/validation";
import { getRealAge, getBirthDate } from "@/service/utils";
export default { export default {
name: "GoodsDetail-CII", name: "GoodsDetail-CII",
...@@ -327,6 +329,26 @@ export default { ...@@ -327,6 +329,26 @@ export default {
nextStep() { nextStep() {
this.$router.push({ path: "/goods/inform" }); this.$router.push({ path: "/goods/inform" });
}, },
getRealIdNo() {
const { relation, userInfoSecId: userId, idNo: idNoMask } = this.formData;
const { selfSecId: holderUserId, selfIdNo: holderIdNoMask } = this.formData;
let currentIdNo = !relation || relation === "1" ? holderIdNoMask : idNoMask;
const currentUserId = !relation || relation === "1" ? holderUserId : userId;
const familyList = this.$refs["insureForm"].familyList;
if (!currentIdNo) return "";
currentIdNo =
currentIdNo.indexOf("**") > -1
? familyList.find(item => item.userInfoSecId === currentUserId).idNo
: currentIdNo;
return currentIdNo;
},
checkAgeInRange() {
const currentIdNo = this.getRealIdNo();
if (!currentIdNo) return;
const birthday = getBirthDate(currentIdNo);
const isOverMonth = birthday && parseInt(fromNow(new Date(birthday), { unit: "day" })) >= 30;
return isOverMonth && getRealAge(birthday) <= 50;
},
async getDetail() { async getDetail() {
this.goodId = this.$route.query.id; this.goodId = this.$route.query.id;
const res = await list(); const res = await list();
...@@ -353,7 +375,8 @@ export default { ...@@ -353,7 +375,8 @@ export default {
userInfoSecId userInfoSecId
} = this.formData; } = this.formData;
let idNoWho = !relation || relation === "1" ? selfIdNo : idNo; let idNoWho = !relation || relation === "1" ? selfIdNo : idNo;
if (!idNoWho || !payType) return; this.isCalPrice = this.checkAgeInRange();
if (!idNoWho || !payType || !this.isCalPrice) return;
const _param = { const _param = {
productNo: this.goodId, productNo: this.goodId,
productUserInfo: { productUserInfo: {
......
...@@ -90,8 +90,10 @@ import NavTab from "./modules/NavTab"; ...@@ -90,8 +90,10 @@ import NavTab from "./modules/NavTab";
import detailPayMixin from "./modules/detailPay.mixin"; import detailPayMixin from "./modules/detailPay.mixin";
import detailLoginMixin from "./modules/detailLogin.mixin"; import detailLoginMixin from "./modules/detailLogin.mixin";
import fromNow from "date-fns/formatDistanceToNowStrict";
import { trail, list } from "@/api/product"; import { trail, list } from "@/api/product";
import localStorage from "@/service/localStorage"; import localStorage from "@/service/localStorage";
import { getRealAge, getBirthDate } from "@/service/utils";
import Detail from "@/api/detail.taikang.yiliaobaozhang"; import Detail from "@/api/detail.taikang.yiliaobaozhang";
import { isIdNo } from "@/service/validation"; import { isIdNo } from "@/service/validation";
...@@ -219,7 +221,7 @@ export default { ...@@ -219,7 +221,7 @@ export default {
}, },
onSubmit() { onSubmit() {
if (!this.isCalPrice) { if (!this.isCalPrice) {
this.$notify({ type: "warn", message: "被保人年龄不在可投保范围,请仔细核对" }); this.$notify({ type: "warning", message: "被保人年龄不在可投保范围,请仔细核对" });
return; return;
} }
if (localStorage.get("mongoToken")) { if (localStorage.get("mongoToken")) {
...@@ -320,6 +322,26 @@ export default { ...@@ -320,6 +322,26 @@ export default {
delete this.subFormData.insuredUserInfo; delete this.subFormData.insuredUserInfo;
} }
}, },
getRealIdNo() {
const { relation, userInfoSecId: userId, idNo: idNoMask } = this.formData;
const { selfSecId: holderUserId, selfIdNo: holderIdNoMask } = this.formData;
let currentIdNo = !relation || relation === "1" ? holderIdNoMask : idNoMask;
const currentUserId = !relation || relation === "1" ? holderUserId : userId;
const familyList = this.$refs["insureForm"].familyList;
if (!currentIdNo) return "";
currentIdNo =
currentIdNo.indexOf("**") > -1
? familyList.find(item => item.userInfoSecId === currentUserId).idNo
: currentIdNo;
return currentIdNo;
},
checkAgeInRange() {
const currentIdNo = this.getRealIdNo();
if (!currentIdNo) return;
const birthday = getBirthDate(currentIdNo);
const isOverMonth = birthday && parseInt(fromNow(new Date(birthday), { unit: "day" })) >= 30;
return isOverMonth && getRealAge(birthday) <= 60;
},
async getDetail() { async getDetail() {
this.goodId = this.$route.query.id; this.goodId = this.$route.query.id;
const res = await list(); const res = await list();
...@@ -337,7 +359,8 @@ export default { ...@@ -337,7 +359,8 @@ export default {
let { price, subPrice } = this.headerInfo; let { price, subPrice } = this.headerInfo;
const { idNo, socialSecurity, payType, userInfoSecId, relation, selfIdNo } = this.formData; const { idNo, socialSecurity, payType, userInfoSecId, relation, selfIdNo } = this.formData;
let idNoWho = !relation || relation === "1" ? selfIdNo : idNo; let idNoWho = !relation || relation === "1" ? selfIdNo : idNo;
if (!idNoWho || !payType || !socialSecurity) return; this.isCalPrice = this.checkAgeInRange();
if (!idNoWho || !payType || !socialSecurity || !this.isCalPrice) return;
const _param = { const _param = {
productNo: this.goodId, productNo: this.goodId,
productUserInfo: { productUserInfo: {
......
...@@ -527,7 +527,7 @@ import autoSaveForm from "@/mixins/autoSaveForm.mixin"; ...@@ -527,7 +527,7 @@ import autoSaveForm from "@/mixins/autoSaveForm.mixin";
import liCalFee from "@/views/Goods/Detail/modules/liCalFee.mixin"; import liCalFee from "@/views/Goods/Detail/modules/liCalFee.mixin";
import { addDays, addYears, format as dateFormat } from "date-fns"; import { addDays, addYears, format as dateFormat } from "date-fns";
import debounce from "lodash/debounce"; import debounce from "lodash/debounce";
import { getRealAge } from "@/service/utils"; import { getRealAge, getBirthDate } from "@/service/utils";
import localStorage from "@/service/localStorage"; import localStorage from "@/service/localStorage";
import { mapState, mapActions } from "vuex"; import { mapState, mapActions } from "vuex";
import Detail from "@/api/detail.huagui.shouxian"; import Detail from "@/api/detail.huagui.shouxian";
...@@ -706,7 +706,7 @@ export default { ...@@ -706,7 +706,7 @@ export default {
age() { age() {
const currentIdNo = this.getRealIdNo(); const currentIdNo = this.getRealIdNo();
if (!currentIdNo) return; if (!currentIdNo) return;
const birthday = this.getBirthDate(currentIdNo); const birthday = getBirthDate(currentIdNo);
const userAge = birthday ? getRealAge(birthday) : ""; const userAge = birthday ? getRealAge(birthday) : "";
return isNaN(userAge) ? 18 : userAge; return isNaN(userAge) ? 18 : userAge;
}, },
...@@ -913,19 +913,6 @@ export default { ...@@ -913,19 +913,6 @@ export default {
} }
this.$forceUpdate(); this.$forceUpdate();
}, },
getBirthDate(idCard) {
let birthday = "";
if (idCard) {
if (idCard.length == 15) {
birthday = "19" + idCard.substr(6, 6);
} else if (idCard.length == 18) {
birthday = idCard.substr(6, 8);
}
birthday = birthday.replace(/(.{4})(.{2})/, "$1-$2-");
}
return birthday;
},
getRealIdNo() { getRealIdNo() {
const { relation, userInfoSecId: userId, idNo: idNoMask } = this.formData.insuredUserInfo; const { relation, userInfoSecId: userId, idNo: idNoMask } = this.formData.insuredUserInfo;
const { userInfoSecId: holderUserId, idNo: holderIdNoMask } = this.formData.holderUserInfo; const { userInfoSecId: holderUserId, idNo: holderIdNoMask } = this.formData.holderUserInfo;
...@@ -941,7 +928,7 @@ export default { ...@@ -941,7 +928,7 @@ export default {
setEffectiveDate: debounce(function() { setEffectiveDate: debounce(function() {
const currentIdNo = this.getRealIdNo(); const currentIdNo = this.getRealIdNo();
if (!currentIdNo) return; if (!currentIdNo) return;
const birthday = this.getBirthDate(currentIdNo); const birthday = getBirthDate(currentIdNo);
const birthdayArr = birthday.split("-"); const birthdayArr = birthday.split("-");
const currentdayArr = dateFormat(new Date(), "yyyy-MM-dd").split("-"); const currentdayArr = dateFormat(new Date(), "yyyy-MM-dd").split("-");
const nextDate = const nextDate =
...@@ -952,7 +939,7 @@ export default { ...@@ -952,7 +939,7 @@ export default {
}), }),
resetFormItemVal(key, val) { resetFormItemVal(key, val) {
const currentIdNo = this.getRealIdNo(); const currentIdNo = this.getRealIdNo();
const birthday = this.getBirthDate(currentIdNo); const birthday = getBirthDate(currentIdNo);
if (birthday && this.formData.productItem[key] === val && val) { if (birthday && this.formData.productItem[key] === val && val) {
switch (key) { switch (key) {
case "amountInsured": case "amountInsured":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment