From 918242b66439e2d1fc3974e6e78388134a1224f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=B3=E6=B6=9B?= Date: Wed, 10 Jun 2020 11:09:40 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=900610=E3=80=91=E8=AF=81=E4=BB=B6?= =?UTF-8?q?=E6=9C=89=E6=95=88=E6=9C=9F=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/js/utils/age.js | 3 +- src/views/ebiz/claims/InsuredInfo.vue | 70 +++++++++++++++++++++------ src/views/ebiz/sale/js/methods.js | 1 - 3 files changed, 56 insertions(+), 18 deletions(-) diff --git a/src/assets/js/utils/age.js b/src/assets/js/utils/age.js index 69eb43fbd..c5b3b24d8 100644 --- a/src/assets/js/utils/age.js +++ b/src/assets/js/utils/age.js @@ -6,7 +6,8 @@ export default { getAgeByBirth: function(value, today) { return this.getAgeByValue(value, today) }, - getAgeByValue: function(value, today) { + getAgeByValue: function(value = '', today) { + // value: 身份证号码获取的生日, today: 当前的时间 var b = value.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/) if (b == null) { return null diff --git a/src/views/ebiz/claims/InsuredInfo.vue b/src/views/ebiz/claims/InsuredInfo.vue index fe7fd475d..2bcefbadb 100644 --- a/src/views/ebiz/claims/InsuredInfo.vue +++ b/src/views/ebiz/claims/InsuredInfo.vue @@ -61,11 +61,13 @@ v-validate="certiexpiredateRequired ? 'required' : ''" required label="证件截止日期" + :minDate="new Date(new Date().getTime() + 24 * 60 * 60 * 1000)" + :maxDate="new Date('2060-12-31')" name="证件截止日期" :defaultDate="new Date()" :value.sync="userInfo.certiTypeEndDate" type="date" - @confirm="onEndDateConfirm($event, '1')" + @confirm="onEndDateConfirm" ref="certiTypeEndDate" :flag="true" > @@ -241,16 +243,14 @@ export default { }, created() { this.judge() - if(localStorage.businessNo && localStorage.claimsClear){ + if (localStorage.businessNo && localStorage.claimsClear) { this.init() localStorage.claimsClear = '' - }else{ + } else { localStorage.setItem('businessNo', '') } }, mounted() { - // localStorage.setItem('businessNo', '') - console.log('mounted ==', localStorage.businessNo) document.body.style.backgroundColor = '#fff' // 筛选按钮的点击事件 window.appCallBack = this.appCallBack @@ -263,24 +263,22 @@ export default { next() }, methods: { - init(){ + init() { if (localStorage.businessNo) { this.userInfo.businessNo = localStorage.businessNo } - let data = { - slaveStatus: this.slaveStatus, - businessNo: this.userInfo.businessNo - } + slaveStatus: this.slaveStatus, + businessNo: this.userInfo.businessNo + } query(data).then(res => { if (res.result == 0) { - console.log(res) this.userInfo = res.content.claimApplyInsuredReqDTO this.userInfo.province = this.userInfo.insuredProvince this.userInfo.city = this.userInfo.insuredCity this.userInfo.area = this.userInfo.insuredCounty this.areaName = getAreaName([{ code: this.userInfo.province }, { code: this.userInfo.city }, { code: this.userInfo.area }]) - } + } }) }, //判断是否由客户报案历史进入,客户信息反显 @@ -300,23 +298,62 @@ export default { } }, //校验证件截止日期 - onEndDateConfirm(val, type) { + onEndDateConfirm(val) { + // 判断身份证号码是否为空, 为空提示并返回 + if (this.userInfo.certiCode == '') { + this.userInfo.certiTypeEndDate = '' + this.$refs.certiTypeEndDate.date = '' + return this.$toast('请先填写证件号码') + } //如果已经勾选了长期 - if (this.userInfo.effectiveDateType) { + if (this.effectiveDateType) { //清空数据并返回 this.userInfo.certiTypeEndDate = '' this.$refs.certiTypeEndDate.date = '' return } + // 如果有效日期早与当前日期 if (Date.parse(val) < Date.parse(new Date())) { this.userInfo.certiTypeEndDate = '' this.$refs.certiTypeEndDate.date = '' return this.$toast('您的证件已过期') } + if (this.userInfo.certiType == '1') { + //获取年龄 + let age = utilsAge.getAge(this.userInfo.insuredBirthday, new Date()) + // 年龄小于16周岁 + if (age <= 15) { + if (new Date(val).getFullYear() - new Date().getFullYear() != 5) { + this.userInfo.certiTypeEndDate = '' + this.$refs.certiTypeEndDate.date = '' + 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年') + } + //年龄在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年') + } + //此外的年龄段不支持 + } else { + this.userInfo.certiTypeEndDate = '' + this.$refs.certiTypeEndDate.date = '' + return this.$toast('身份证不支持此年龄段') + } + } }, //失焦验证身份证 getRelatedData(val) { - if (this.userInfo.certiType != '1') { + // 判断是否是身份证类型和是否为空 + if (this.userInfo.certiType != '1' || !val) { return } //如果证件校验不通过,恢复默认值 @@ -326,6 +363,7 @@ export default { } this.effectiveDateType = false this.userInfo.certiIsLong = '0' + this.userInfo.insuredBirthday = idToData(val).birthday this.userInfo.insuredSex = idToData(val).sex this.effectiveDateTypeAble = idToData(val).age <= 45 }, @@ -391,7 +429,7 @@ export default { this.effectiveDateType = false this.userInfo.certiTypeEndDate = '' this.userInfo.certiIsLong = this.effectiveDateType ? '1' : '0' - let age = utilsAge.getAge(this.userInfo.certiCode, new Date()) + let age = utilsAge.getAge(this.userInfo.insuredBirthday, new Date()) this.effectiveDateTypeAble = age <= 45 } this.userInfo.certiType = value.id diff --git a/src/views/ebiz/sale/js/methods.js b/src/views/ebiz/sale/js/methods.js index da4406408..4bd82d6ba 100644 --- a/src/views/ebiz/sale/js/methods.js +++ b/src/views/ebiz/sale/js/methods.js @@ -52,7 +52,6 @@ function closeBtn(that) { * @param {*} type 1 投保人 2 被保险人 */ export function getIdentityInfo(that, data, type) { - console.log(data) // 正面 if (data.name && data.name != '待识别') { that.userInfo.name = data.name