diff --git a/src/views/ebiz/claims/ApplyInfo.vue b/src/views/ebiz/claims/ApplyInfo.vue index e21c775e3..43b822501 100644 --- a/src/views/ebiz/claims/ApplyInfo.vue +++ b/src/views/ebiz/claims/ApplyInfo.vue @@ -988,7 +988,7 @@ export default { this.userInfo.applyerCertiStartDate = '' this.$refs.certificateValidate.date = '' this.$refs.applyerCertiEndDate.date = '' - return this.$toast('16周岁以下的证件有效期为5年') + return this.$toast('证件有效期错误,16周岁以下的证件有效期为5年') } //年龄在16-25周岁之间 } else if (age >= 16 && age <= 25) { @@ -997,7 +997,7 @@ export default { this.userInfo.applyerCertiStartDate = '' this.$refs.certificateValidate.date = '' this.$refs.applyerCertiEndDate.date = '' - return this.$toast('16周岁~25周岁的证件有效期为10年') + return this.$toast('证件有效期错误,16周岁~25周岁的证件有效期为10年') } //年龄在26-45周岁之间 } else if (age >= 26 && age <= 45) { @@ -1006,7 +1006,7 @@ export default { this.userInfo.applyerCertiStartDate = '' this.$refs.certificateValidate.date = '' this.$refs.applyerCertiEndDate.date = '' - return this.$toast('26周岁~45周岁的证件有效期为20年') + return this.$toast('证件有效期错误,26周岁~45周岁的证件有效期为20年') } } else if (age >= 46 && age <= 65) { if ( @@ -1017,7 +1017,7 @@ export default { this.userInfo.applyerCertiStartDate = '' this.$refs.certificateValidate.date = '' this.$refs.applyerCertiEndDate.date = '' - return this.$toast('46周岁~65周岁的证件有效期为20年或为长期') + return this.$toast('证件有效期错误,46周岁~65周岁的证件有效期为20年或为长期') } } else if (age >= 66) { if (this.effectiveDateType !== true) { @@ -1025,7 +1025,7 @@ export default { this.userInfo.applyerCertiStartDate = '' this.$refs.certificateValidate.date = '' this.$refs.applyerCertiEndDate.date = '' - return this.$toast('年龄大于等于66周岁,证件有效期为长期') + return this.$toast('证件有效期错误,年龄大于等于66周岁,证件有效期为长期') } } // 证件号码规则校验 diff --git a/src/views/ebiz/claims/InsuredInfo.vue b/src/views/ebiz/claims/InsuredInfo.vue index 2167d2202..25ce2473d 100644 --- a/src/views/ebiz/claims/InsuredInfo.vue +++ b/src/views/ebiz/claims/InsuredInfo.vue @@ -326,21 +326,21 @@ export default { if (new Date(val).getFullYear() - new Date().getFullYear() > 5) { this.userInfo.certiTypeEndDate = '' this.$refs.certiTypeEndDate.date = '' - return this.$toast('16周岁以下的证件有效期为5年') + return this.$toast('证件有效期错误,16周岁以下的证件有效期为5年') } //年龄在16-25周岁之间 } else if (age >= 16 && age <= 25) { if (new Date(val).getFullYear() - new Date().getFullYear() > 10) { this.userInfo.certiTypeEndDate = '' this.$refs.certiTypeEndDate.date = '' - return this.$toast('16周岁~25周岁的证件有效期为10年') + return this.$toast('证件有效期错误,16周岁~25周岁的证件有效期为10年') } //年龄在26-45周岁之间 } else if (age >= 26 && age <= 45) { if (new Date(val).getFullYear() - new Date().getFullYear() > 20) { this.userInfo.certiTypeEndDate = '' this.$refs.certiTypeEndDate.date = '' - return this.$toast('26周岁~45周岁的证件有效期为20年') + return this.$toast('证件有效期错误,26周岁~45周岁的证件有效期为20年') } //此外的年龄段不支持 } @@ -588,28 +588,28 @@ export default { let age = utilsAge.getAge(this.userInfo.insuredBirthday, new Date()) //若证件为身份证——进行证件有效期校验 if (age < 46 && this.effectiveDateType) { - return this.$toast('年龄小于46周岁,证件有效期不能为长期') + return this.$toast('证件有效期错误,年龄小于46周岁,证件有效期不能为长期') } // 年龄小于16周岁 if (age <= 15) { if (Date.parse(this.userInfo.certiTypeEndDate) - Date.parse(new Date()) > Date.parse('1975-01-01')) { this.userInfo.certiTypeEndDate = '' this.$refs.certiTypeEndDate.date = '' - return this.$toast('16周岁以下的证件有效期为5年') + return this.$toast('证件有效期错误,16周岁以下的证件有效期为5年') } //年龄在16-25周岁之间 } else if (age >= 16 && age <= 25) { if (Date.parse(this.userInfo.certiTypeEndDate) - Date.parse(new Date()) > Date.parse('1980-01-01')) { this.userInfo.certiTypeEndDate = '' this.$refs.certiTypeEndDate.date = '' - return this.$toast('16周岁~25周岁的证件有效期为10年') + return this.$toast('证件有效期错误,16周岁~25周岁的证件有效期为10年') } //年龄在26-45周岁之间 } else if (age >= 26 && age <= 45) { if (Date.parse(this.userInfo.certiTypeEndDate) - Date.parse(new Date()) > Date.parse('1990-01-01')) { this.userInfo.certiTypeEndDate = '' this.$refs.certiTypeEndDate.date = '' - return this.$toast('26周岁~45周岁的证件有效期为20年') + return this.$toast('证件有效期错误,26周岁~45周岁的证件有效期为20年') } } /*else if (age >= 46 && age <= 65) { if ( diff --git a/src/views/ebiz/sale/AddBeneficiaryInfo.vue b/src/views/ebiz/sale/AddBeneficiaryInfo.vue index 7b43ea052..400768200 100644 --- a/src/views/ebiz/sale/AddBeneficiaryInfo.vue +++ b/src/views/ebiz/sale/AddBeneficiaryInfo.vue @@ -214,7 +214,11 @@ import idNoCheck from '@/assets/js/utils/idNoCheck' import { idToData } from './js/verification' import { selectComp } from './js/methods' // let relationToInsured = [{ id: 2, text: '配偶' }, { id: 3, text: '父母' }, { id: 4, text: '子女' }, { id: 5, text: '其他' }] -let relationToInsured = [{ id: 2, text: '配偶' }, { id: 3, text: '父母' }, { id: 4, text: '子女' }] +let relationToInsured = [ + { id: 2, text: '配偶' }, + { id: 3, text: '父母' }, + { id: 4, text: '子女' } +] export default { name: 'insuredInfo', @@ -310,7 +314,7 @@ export default { // intercept: '1' //是否拦截原生返回事件 1是 其他否 // }) window.appCallBack = this.appCallBack - if (localStorage.applicant == '1' || this.saleInsuredPersonInfo.relationToAppnt == '1' || this.saleInsuredPersonInfo.relationToAppnt == '5' ) { + if (localStorage.applicant == '1' || this.saleInsuredPersonInfo.relationToAppnt == '1' || this.saleInsuredPersonInfo.relationToAppnt == '5') { this.Insured = true } else { this.Insured = false @@ -408,7 +412,10 @@ export default { } else if (pickerType == '3') { this.columns = DataDictionary.degree } else if (pickerType == '4') { - this.columns = [{ id: 0, text: '有' }, { id: 1, text: '无' }] + this.columns = [ + { id: 0, text: '有' }, + { id: 1, text: '无' } + ] } else if (pickerType == '5') { this.columns = DataDictionary.taxIdentity } else if (pickerType == '6') { @@ -659,271 +666,274 @@ export default { // 页面跳转 let valid = await this.$validator.validate() // .then(valid => { - if (true === valid) { - // 受益人是被保险人的配偶 - if (this.userInfo.relationToInsured == '2') { - // 受益人与投保人都是被保险人的配偶时 - if (this.userInfo.relationToInsured == '2' && relationToAppnt == '2') { - if (this.userInfo.name != insuredDetail.name || this.userInfo.sex != insuredDetail.sex || this.userInfo.idNo != insuredDetail.idNo) { - return this.$toast('受益人数据不合法,请重新输入') - } - } - //与被保人关系是配偶 - let insuredInfo = this.saleInsuredPersonInfo - //如果投保人不是已婚 - if (insuredInfo.marriage != '1') { - return this.$toast('亲,受益人与被保险人关系为配偶,被保险人婚姻状况必须为已婚哦~') - } - //如果被保险人与投保人性别相同 - if (insuredInfo.sex == this.userInfo.sex) { - return this.$toast('额,受益人与被保险人关系为配偶,性别不能相同哦~') - } - - //如果性别男小于22岁 或者 性别女小于20岁 - if ((this.userInfo.sex == '0' && age < 22) || (this.userInfo.sex == '1' && age < 20)) { - return this.$toast('年龄与婚姻状况不符') + if (true === valid) { + // 受益人是被保险人的配偶 + if (this.userInfo.relationToInsured == '2') { + // 受益人与投保人都是被保险人的配偶时 + if (this.userInfo.relationToInsured == '2' && relationToAppnt == '2') { + if (this.userInfo.name != insuredDetail.name || this.userInfo.sex != insuredDetail.sex || this.userInfo.idNo != insuredDetail.idNo) { + return this.$toast('受益人数据不合法,请重新输入') } } + //与被保人关系是配偶 + let insuredInfo = this.saleInsuredPersonInfo + //如果投保人不是已婚 + if (insuredInfo.marriage != '1') { + return this.$toast('亲,受益人与被保险人关系为配偶,被保险人婚姻状况必须为已婚哦~') + } + //如果被保险人与投保人性别相同 + if (insuredInfo.sex == this.userInfo.sex) { + return this.$toast('额,受益人与被保险人关系为配偶,性别不能相同哦~') + } - // 受益人是被保险人的父母,被保险人是投保人的子女时 - if (this.userInfo.relationToInsured == '3' && relationToAppnt == '4') { - if (this.userInfo.sex == insuredDetail.sex) { - if (this.userInfo.name != insuredDetail.name || this.userInfo.idNo != insuredDetail.idNo) { - return this.$toast('受益人数据不合法,请重新输入') - } - } + //如果性别男小于22岁 或者 性别女小于20岁 + if ((this.userInfo.sex == '0' && age < 22) || (this.userInfo.sex == '1' && age < 20)) { + return this.$toast('年龄与婚姻状况不符') } - let insuredInfo = JSON.parse(localStorage.saleInsuredPersonInfo) - // 受益人与被保险人关系为父母时,受益人年龄必须大于被保险人年龄 - if (this.userInfo.relationToInsured == '3') { - if (age < insuredInfo.age) { - await this.$dialog.confirm({ - title: '提示', - message: '亲,请确认受益人与被保险人关系哦', - confirmButtonText: '继续填写', - cancelButtonText: '返回修改' - }) - } - } - // 受益人与被保险人关系为子女时,受益人年龄必须小于被保险人年龄 - if (this.userInfo.relationToInsured == '4') { - if (age > insuredInfo.age) { - await this.$dialog.confirm({ - title: '提示', - message: '亲,请确认受益人与被保险人关系哦', - confirmButtonText: '继续填写', - cancelButtonText: '返回修改' - }) - } - } - //如果证件类型是身份证 - if (this.userInfo.idType == '1') { - if (this.userInfo.nativeplace != '1') { - return this.$toast('证件类型”为“身份证,国籍必须为中国哦') - } - //校验性别是否与身份证号码位相符 - if (this.userInfo.idNo.length == '15') { - //15位身份证第15位是性别位, 奇男偶女 - let sexSign = this.userInfo.idNo.substr(14, 1) - if ((parseInt(sexSign) % 2 == 0 && this.userInfo.sex != 1) || (parseInt(sexSign) % 2 != 0 && this.userInfo.sex != 0)) { - return this.$toast('性别录入与身份证不符') - } - - //15位身份证第7-12位是生日位, 年月日 - let birthSign = this.userInfo.idNo.substr(6, 6) - if ( - this.userInfo.birthday.substr(2, 2) != birthSign.substr(0, 2) || - this.userInfo.birthday.substr(5, 2) != birthSign.substr(2, 2) || - this.userInfo.birthday.substr(8, 2) != birthSign.substr(4, 2) - ) { - return this.$toast('生日录入与身份证不符') - } - } else if (this.userInfo.idNo.length == '18') { - //18位身份证第17位是性别位, 奇男偶女 - let sexSign = this.userInfo.idNo.substr(16, 1) - if ((parseInt(sexSign) % 2 == 0 && this.userInfo.sex != 1) || (parseInt(sexSign) % 2 != 0 && this.userInfo.sex != 0)) { - return this.$toast('性别录入与身份证不符') - } - - //18位身份证第7-14位是生日位, 年月日 - let birthSign = this.userInfo.idNo.substr(6, 8) - if ( - this.userInfo.birthday.substr(0, 4) != birthSign.substr(0, 4) || - this.userInfo.birthday.substr(5, 2) != birthSign.substr(4, 2) || - this.userInfo.birthday.substr(8, 2) != birthSign.substr(6, 2) - ) { - return this.$toast('生日录入与身份证不符') - } - } - - // 证件号码规则校验 - if (!idNoCheck.isIdno(this.userInfo.idNo)) { - console.log('证件号码校验有误') - return this.$toast('您填写的证件号码有误') - } - - //年龄在0-15周岁之间 - if (age <= 15) { - if (Date.parse(this.userInfo.certiexpiredate) - Date.parse(new Date()) > Date.parse('1975-01-01')) { - this.userInfo.certiexpiredate = '' - this.$refs.certiexpiredate.date = '' - // this.effectiveDateTypeAble = true - return this.$toast('证件有效期不正常,未满16周岁的公民身份证有效期应小于等于5年') - } - //年龄在 16-25 周岁之间 - } else if (age >= 16 && age <= 25) { - if (Date.parse(this.userInfo.certiexpiredate) - Date.parse(new Date()) > Date.parse('1980-01-01')) { - this.userInfo.certiexpiredate = '' - this.$refs.certiexpiredate.date = '' - // this.effectiveDateTypeAble = true - return this.$toast('证件有效期不正常,16周岁至25周岁公民身份证有效期应小于等于10年') - } - //年龄在 26-45 周岁之间 - } else if (age >= 26 && age <= 45) { - if (Date.parse(this.userInfo.certiexpiredate) - Date.parse(new Date()) > Date.parse('1990-01-01')) { - this.userInfo.certiexpiredate = '' - this.$refs.certiexpiredate.date = '' - // this.effectiveDateTypeAble = true - return this.$toast('证件有效期不正常,26周岁至45周岁公民身份证有效期应小于等于20年') - } - } - //证件类型是户口本 - } else if (this.userInfo.idType == '2') { - if (age > 16) { - return this.$toast('客户年龄在16周岁以上,不能使用户口本作为有效证件') - } - // else if (this.userInfo.idNo.length != 18) { - // return this.$toast('户口本的证件号码长度应等于18位') - // } - //证件类型是出生证明 - } else if (this.userInfo.idType == '3') { - if (age >= 2) { - return this.$toast('客户年龄在2周岁及以上,不能使用出生证作为有效证件') - } - // else if (this.userInfo.idNo.length < 3) { - // return this.$toast('出生证须大于等于3个字符') - // } - //证件类型是护照 - } else if (this.userInfo.idType == '4') { - if (this.userInfo.nativeplace == '1') { - return this.$toast('“证件类型”为“外国人护照”,“国籍”不能选择为“中国”哦~') - } - } - - // else if (this.userInfo.idType == '4' && this.userInfo.idNo.length < 3) { - // return this.$toast('护照须大于等于3个字符') - // //证件是港澳居民通行证 - // } else if (this.userInfo.idType == '5') { - // if (this.userInfo.idNo.length != 9) { - // return this.$toast('证件类型为港澳居民通行证的,证件号码须为9位') - // } else if (!/^(H|M)[0-9]{8}$/.test(this.userInfo.idNo)) { - // return this.$toast('证件类型为港澳居民通行证的,证件号码首位字母为"H"/"M",证件号码第2位至第9位为阿拉伯数字') - // } - // //证件是台湾居民通行证 - // } else if (this.userInfo.idType == '6' && this.userInfo.idNo.length != 8) { - // return this.$toast('证件类型为台湾居民通行证的,证件号码须为8位数字') - // } - - // 通过国籍判断 证件是否符合要求 - // 如果是国籍选择中国大陆 - if (this.userInfo.nativeplace == '1') { - // “身份证”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证” - let obj = { - '1': true, - '5': true, - '6': true - } - let idType = this.userInfo.idType - // 通过年龄 判断证件是否符合要求 - // 小于2岁 - if (age < 2) { - // “出生证”,"户口本" - obj['2'] = true - obj['3'] = true - if (obj[idType] === undefined) { - return this.$toast('亲,国籍为中国,且未满2周岁儿童,证件类型必须“身份证”或“户口本”或“出生证”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证”') - } - } else if (age < 16) { - // 小于16岁 - // “户口本” - obj['2'] = true - if (obj[idType] === undefined) { - return this.$toast( - '亲,国籍为中国,且大于2周岁小于16周岁的未成年人,证件类型必须为“身份证”或“户口本”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证”' - ) - } - } else { - // 大于16岁 - if (obj[idType] === undefined) { - return this.$toast('亲,国籍为中国,证件类型必须为“身份证”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证”') - } - } - } else { - // 非大陆人员按外籍人员 - let obj = { - '4': true, - '8': true - } - let idType = this.userInfo.idType - if (obj[idType] === undefined) { - return this.$toast('亲,国籍为外籍,证件类型必须为护照或外国人永久居留身份证投保') - } - } - - - let beneficiaries = [] - if (localStorage.beneficiaryInfo) { - // 从 localStorage 取出数据 - beneficiaries = JSON.parse(localStorage.beneficiaryInfo) - // 收益份额不超过 100% - let ratio = 0 - beneficiaries.forEach(item => { - ratio += parseInt(item.bnfLot) - }) - ratio += parseInt(this.userInfo.bnfLot) - console.log(ratio) - if (ratio > 100) { - return this.$toast('受益份额有误,请重新输入~') - } - - if (this.userInfo.idNo != '') { - // 受益人不能重复添加 (证件号码为基准) - let isDbAdd = beneficiaries.some(item => { - return item.idNo == this.userInfo.idNo - }) - console.log(isDbAdd) - if (isDbAdd) { - return this.$toast('受益人不支持重复添加') - } - } - } else { - if (this.userInfo.bnfLot > 100) { - return this.$toast('受益份额不能超过100~') - } - } - - - beneficiaries.push(this.userInfo) - // console.log(beneficiaries) - // 保存 新增的受益人信息 以及页面跳转字段 - localStorage.beneficiaryInfo = JSON.stringify(beneficiaries) - localStorage.fromAddBeneficiaryInfo = true - if (this.userInfo.asAppntAddress == true) { - localStorage.applicant = '1' - } - this.$jump({ - flag: 'h5', - extra: { - url: location.origin + '/#/sale/beneficiary', - needRefresh: '1' - }, - routerInfo: { - path: '/sale/beneficiary' - } - }) - } else { - this.$toast(this.$validator.errors.all()[0]) } + + // 受益人是被保险人的父母,被保险人是投保人的子女时 + if (this.userInfo.relationToInsured == '3' && relationToAppnt == '4') { + if (this.userInfo.sex == insuredDetail.sex) { + if (this.userInfo.name != insuredDetail.name || this.userInfo.idNo != insuredDetail.idNo) { + return this.$toast('受益人数据不合法,请重新输入') + } + } + } + let insuredInfo = JSON.parse(localStorage.saleInsuredPersonInfo) + // 受益人与被保险人关系为父母时,受益人年龄必须大于被保险人年龄 + if (this.userInfo.relationToInsured == '3') { + if (age < insuredInfo.age) { + await this.$dialog.confirm({ + title: '提示', + message: '亲,请确认受益人与被保险人关系哦', + confirmButtonText: '继续填写', + cancelButtonText: '返回修改' + }) + } + } + // 受益人与被保险人关系为子女时,受益人年龄必须小于被保险人年龄 + if (this.userInfo.relationToInsured == '4') { + if (age > insuredInfo.age) { + await this.$dialog.confirm({ + title: '提示', + message: '亲,请确认受益人与被保险人关系哦', + confirmButtonText: '继续填写', + cancelButtonText: '返回修改' + }) + } + } + //如果证件类型是身份证 + if (this.userInfo.idType == '1') { + if (this.userInfo.nativeplace != '1') { + return this.$toast('证件类型”为“身份证,国籍必须为中国哦') + } + //校验性别是否与身份证号码位相符 + if (this.userInfo.idNo.length == '15') { + //15位身份证第15位是性别位, 奇男偶女 + let sexSign = this.userInfo.idNo.substr(14, 1) + if ((parseInt(sexSign) % 2 == 0 && this.userInfo.sex != 1) || (parseInt(sexSign) % 2 != 0 && this.userInfo.sex != 0)) { + return this.$toast('性别录入与身份证不符') + } + + //15位身份证第7-12位是生日位, 年月日 + let birthSign = this.userInfo.idNo.substr(6, 6) + if ( + this.userInfo.birthday.substr(2, 2) != birthSign.substr(0, 2) || + this.userInfo.birthday.substr(5, 2) != birthSign.substr(2, 2) || + this.userInfo.birthday.substr(8, 2) != birthSign.substr(4, 2) + ) { + return this.$toast('生日录入与身份证不符') + } + } else if (this.userInfo.idNo.length == '18') { + //18位身份证第17位是性别位, 奇男偶女 + let sexSign = this.userInfo.idNo.substr(16, 1) + if ((parseInt(sexSign) % 2 == 0 && this.userInfo.sex != 1) || (parseInt(sexSign) % 2 != 0 && this.userInfo.sex != 0)) { + return this.$toast('性别录入与身份证不符') + } + + //18位身份证第7-14位是生日位, 年月日 + let birthSign = this.userInfo.idNo.substr(6, 8) + if ( + this.userInfo.birthday.substr(0, 4) != birthSign.substr(0, 4) || + this.userInfo.birthday.substr(5, 2) != birthSign.substr(4, 2) || + this.userInfo.birthday.substr(8, 2) != birthSign.substr(6, 2) + ) { + return this.$toast('生日录入与身份证不符') + } + } + + // 证件号码规则校验 + if (!idNoCheck.isIdno(this.userInfo.idNo)) { + console.log('证件号码校验有误') + return this.$toast('您填写的证件号码有误') + } + //年龄在小于周岁(不含46周岁),证件有效期不能为长期 + if (age < 46 && this.userInfo.effectiveDateType == true) { + return this.$toast('证件有效期错误,年龄小于46周岁,证件有效期不能为长期') + } + //年龄在0-15周岁之间 + if (age <= 15) { + if (Date.parse(this.userInfo.certiexpiredate) - Date.parse(new Date()) > Date.parse('1975-01-01')) { + this.userInfo.certiexpiredate = '' + this.$refs.certiexpiredate.date = '' + // this.effectiveDateTypeAble = true + return this.$toast('证件有效期错误,未满16周岁的公民身份证有效期应小于等于5年') + } + //年龄在 16-25 周岁之间 + } else if (age >= 16 && age <= 25) { + if (Date.parse(this.userInfo.certiexpiredate) - Date.parse(new Date()) > Date.parse('1980-01-01')) { + this.userInfo.certiexpiredate = '' + this.$refs.certiexpiredate.date = '' + // this.effectiveDateTypeAble = true + return this.$toast('证件有效期错误,16周岁至25周岁公民身份证有效期应小于等于10年') + } + //年龄在 26-45 周岁之间 + } else if (age >= 26 && age <= 45) { + if (Date.parse(this.userInfo.certiexpiredate) - Date.parse(new Date()) > Date.parse('1990-01-01')) { + this.userInfo.certiexpiredate = '' + this.$refs.certiexpiredate.date = '' + // this.effectiveDateTypeAble = true + return this.$toast('证件有效期错误,26周岁至45周岁公民身份证有效期应小于等于20年') + } + } + //证件类型是户口本 + } else if (this.userInfo.idType == '2') { + if (age > 16) { + return this.$toast('客户年龄在16周岁以上,不能使用户口本作为有效证件') + } + // else if (this.userInfo.idNo.length != 18) { + // return this.$toast('户口本的证件号码长度应等于18位') + // } + //证件类型是出生证明 + } else if (this.userInfo.idType == '3') { + if (age >= 2) { + return this.$toast('客户年龄在2周岁及以上,不能使用出生证作为有效证件') + } + // else if (this.userInfo.idNo.length < 3) { + // return this.$toast('出生证须大于等于3个字符') + // } + //证件类型是护照 + } else if (this.userInfo.idType == '4') { + if (this.userInfo.nativeplace == '1') { + return this.$toast('“证件类型”为“外国人护照”,“国籍”不能选择为“中国”哦~') + } + } + + // else if (this.userInfo.idType == '4' && this.userInfo.idNo.length < 3) { + // return this.$toast('护照须大于等于3个字符') + // //证件是港澳居民通行证 + // } else if (this.userInfo.idType == '5') { + // if (this.userInfo.idNo.length != 9) { + // return this.$toast('证件类型为港澳居民通行证的,证件号码须为9位') + // } else if (!/^(H|M)[0-9]{8}$/.test(this.userInfo.idNo)) { + // return this.$toast('证件类型为港澳居民通行证的,证件号码首位字母为"H"/"M",证件号码第2位至第9位为阿拉伯数字') + // } + // //证件是台湾居民通行证 + // } else if (this.userInfo.idType == '6' && this.userInfo.idNo.length != 8) { + // return this.$toast('证件类型为台湾居民通行证的,证件号码须为8位数字') + // } + + // 通过国籍判断 证件是否符合要求 + // 如果是国籍选择中国大陆 + if (this.userInfo.nativeplace == '1') { + // “身份证”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证” + let obj = { + '1': true, + '5': true, + '6': true + } + let idType = this.userInfo.idType + // 通过年龄 判断证件是否符合要求 + // 小于2岁 + if (age < 2) { + // “出生证”,"户口本" + obj['2'] = true + obj['3'] = true + if (obj[idType] === undefined) { + return this.$toast( + '亲,国籍为中国,且未满2周岁儿童,证件类型必须“身份证”或“户口本”或“出生证”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证”' + ) + } + } else if (age < 16) { + // 小于16岁 + // “户口本” + obj['2'] = true + if (obj[idType] === undefined) { + return this.$toast( + '亲,国籍为中国,且大于2周岁小于16周岁的未成年人,证件类型必须为“身份证”或“户口本”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证”' + ) + } + } else { + // 大于16岁 + if (obj[idType] === undefined) { + return this.$toast('亲,国籍为中国,证件类型必须为“身份证”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证”') + } + } + } else { + // 非大陆人员按外籍人员 + let obj = { + '4': true, + '8': true + } + let idType = this.userInfo.idType + if (obj[idType] === undefined) { + return this.$toast('亲,国籍为外籍,证件类型必须为护照或外国人永久居留身份证投保') + } + } + + let beneficiaries = [] + if (localStorage.beneficiaryInfo) { + // 从 localStorage 取出数据 + beneficiaries = JSON.parse(localStorage.beneficiaryInfo) + // 收益份额不超过 100% + let ratio = 0 + beneficiaries.forEach(item => { + ratio += parseInt(item.bnfLot) + }) + ratio += parseInt(this.userInfo.bnfLot) + console.log(ratio) + if (ratio > 100) { + return this.$toast('受益份额有误,请重新输入~') + } + + if (this.userInfo.idNo != '') { + // 受益人不能重复添加 (证件号码为基准) + let isDbAdd = beneficiaries.some(item => { + return item.idNo == this.userInfo.idNo + }) + console.log(isDbAdd) + if (isDbAdd) { + return this.$toast('受益人不支持重复添加') + } + } + } else { + if (this.userInfo.bnfLot > 100) { + return this.$toast('受益份额不能超过100~') + } + } + + beneficiaries.push(this.userInfo) + // console.log(beneficiaries) + // 保存 新增的受益人信息 以及页面跳转字段 + localStorage.beneficiaryInfo = JSON.stringify(beneficiaries) + localStorage.fromAddBeneficiaryInfo = true + if (this.userInfo.asAppntAddress == true) { + localStorage.applicant = '1' + } + this.$jump({ + flag: 'h5', + extra: { + url: location.origin + '/#/sale/beneficiary', + needRefresh: '1' + }, + routerInfo: { + path: '/sale/beneficiary' + } + }) + } else { + this.$toast(this.$validator.errors.all()[0]) + } // }) }, // //区域选择 diff --git a/src/views/ebiz/sale/InsuredInfo.vue b/src/views/ebiz/sale/InsuredInfo.vue index 66b8415b6..ee307d47f 100644 --- a/src/views/ebiz/sale/InsuredInfo.vue +++ b/src/views/ebiz/sale/InsuredInfo.vue @@ -990,6 +990,10 @@ export default { return this.$toast('您填写的证件号码有误') } + //年龄在小于周岁(不含46周岁),证件有效期不能为长期 + if (age < 46 && this.userInfo.effectiveDateType == true) { + return this.$toast('证件有效期错误,年龄小于46周岁,证件有效期不能为长期') + } // 年龄在 16-25 周岁之间 if (age >= 16 && age <= 25) { console.log('年龄在16-25周岁之间') @@ -997,7 +1001,7 @@ export default { this.userInfo.certiexpiredate = '' this.$refs.certiexpiredate.date = '' this.effectiveDateTypeAble = true - return this.$toast('证件有效期不正常,16周岁至25周岁公民身份证有效期应小于等于10年') + return this.$toast('证件有效期错误,16周岁至25周岁公民身份证有效期应小于等于10年') } //年龄在 26-45 周岁之间 } else if (age >= 26 && age <= 45) { @@ -1006,7 +1010,7 @@ export default { this.userInfo.certiexpiredate = '' this.$refs.certiexpiredate.date = '' this.effectiveDateTypeAble = true - return this.$toast('证件有效期不正常,26周岁至45周岁公民身份证有效期应小于等于20年') + return this.$toast('证件有效期错误,26周岁至45周岁公民身份证有效期应小于等于20年') } } //证件类型是户口本 diff --git a/src/views/ebiz/sale/InsuredPerson.vue b/src/views/ebiz/sale/InsuredPerson.vue index a926053df..1deaab65e 100644 --- a/src/views/ebiz/sale/InsuredPerson.vue +++ b/src/views/ebiz/sale/InsuredPerson.vue @@ -1275,13 +1275,17 @@ export default { return this.$toast('您填写的证件号码有误') } console.log(age) + //年龄在小于周岁(不含46周岁),证件有效期不能为长期 + if (age < 46 && this.userInfo.effectiveDateType == true) { + return this.$toast('证件有效期错误,年龄小于46周岁,证件有效期不能为长期') + } //年龄在0-15周岁之间 if (age <= 15) { if (Date.parse(this.userInfo.certiexpiredate) - Date.parse(new Date()) > Date.parse('1975-01-01')) { this.userInfo.certiexpiredate = '' this.$refs.certiexpiredate.date = '' // this.effectiveDateTypeAble = true - return this.$toast('证件有效期不正常,未满16周岁的公民身份证有效期应小于等于5年') + return this.$toast('证件有效期错误,未满16周岁的公民身份证有效期应小于等于5年') } //年龄在 16-25 周岁之间 } else if (age >= 16 && age <= 25) { @@ -1289,7 +1293,7 @@ export default { this.userInfo.certiexpiredate = '' this.$refs.certiexpiredate.date = '' // this.effectiveDateTypeAble = true - return this.$toast('证件有效期不正常,16周岁至25周岁公民身份证有效期应小于等于10年') + return this.$toast('证件有效期错误,16周岁至25周岁公民身份证有效期应小于等于10年') } //年龄在 26-45 周岁之间 } else if (age >= 26 && age <= 45) { @@ -1297,7 +1301,7 @@ export default { this.userInfo.certiexpiredate = '' this.$refs.certiexpiredate.date = '' // this.effectiveDateTypeAble = true - return this.$toast('证件有效期不正常,26周岁至45周岁公民身份证有效期应小于等于20年') + return this.$toast('证件有效期错误,26周岁至45周岁公民身份证有效期应小于等于20年') } } //如果是身份证,且未成年,则与投保人关系必须是子女关系