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

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

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