GFRS-2618【前端】新增津贴申请的基本信息页面的部分代码。提交人--张齐

This commit is contained in:
zhangqi1
2021-09-09 18:33:57 +08:00
parent f9a9a6e55e
commit c50af90a51
5 changed files with 337 additions and 241 deletions

View File

@@ -44,3 +44,18 @@ export function getAllowanceDetail(data) {
})
}
// <-- zhangqi 津贴申请与我的资料使用到的接口 begin -->
// 津贴申请-基本信息-保存
export function saveOrUpdateAllowanceUrl(data) {
return request({
url: getUrl('/agent/allowance/saveOrUpdateAllowance', 1),
method: 'post',
data
})
}
// <-- zhangqi 津贴申请与我的资料使用到的接口 end -->

View File

@@ -89,8 +89,8 @@ export default {
imgNoCheckedUrl: this.$assetsUrl + 'images/kmh/qmqr_n.png'
}
],
//localStorage.salePageFlag:控制导航是否可以直接跳转页面 1-投保人信息 2-被保人信息 3-选择产品 4-受益人信息 5-告知信息 6-账户信息 7-附件上传 8-签名确认
salePageFlag: Number(localStorage.salePageFlag)
//localStorage.allowancePageFlag:控制导航是否可以直接跳转页面 1-投保人信息 2-被保人信息 3-选择产品 4-受益人信息 5-告知信息 6-账户信息 7-附件上传 8-签名确认
allowancePageFlag: Number(localStorage.allowancePageFlag)
}
},
mounted() {
@@ -99,23 +99,23 @@ export default {
methods: {
changePage(pageIndex) {
let url = ''
//由 localStorage.salePageFlag 来控制是否可跳到指定页面
if (localStorage.salePageFlag == '-10' && pageIndex != 8) {
//由 localStorage.allowancePageFlag 来控制是否可跳到指定页面
if (localStorage.allowancePageFlag == '-10' && pageIndex != 8) {
this.$toast('已到达签名确认流程,不可以回到前面的流程')
}
if (Number(localStorage.salePageFlag) < Number(pageIndex)) return
if (Number(localStorage.allowancePageFlag) < Number(pageIndex)) return
switch (pageIndex) {
case 1: //跳到基本信息页面
url = `/allowance/application/BaseInfo?edit=1&salePageFlag=${pageIndex}`
url = `/allowance/application/BaseInfo?edit=1&allowancePageFlag=${pageIndex}`
break
case 2: //跳到账户信息页面
url = `/allowance/application/AccountInfo?edit=1&salePageFlag=${pageIndex}`
url = `/allowance/application/AccountInfo?edit=1&allowancePageFlag=${pageIndex}`
break
case 3: //跳到影像资料页面
url = `/allowance/application/AttachmentManagement?edit=1&salePageFlag=${pageIndex}`
url = `/allowance/application/AttachmentManagement?edit=1&allowancePageFlag=${pageIndex}`
break
case 4: //跳到签名确认页面
url = `/allowance/application/SignatureConfirmation?edit=1&salePageFlag=${pageIndex}`
url = `/allowance/application/SignatureConfirmation?edit=1&allowancePageFlag=${pageIndex}`
break
default:
break

View File

@@ -4,7 +4,7 @@
<index-bar></index-bar>
<van-cell-group class='mt10'>
<van-field
v-model='applicantInfo.jobNumber'
v-model='applicantInfo.agentCode'
v-validate="'required'"
readonly
required
@@ -58,11 +58,13 @@
@on-click="selectClick('1')"
></customer-picker>
<select-radio
:value.sync='enjoyUserInfo.role'
:value.sync='enjoyUserInfo.relationship'
required
:radios='enjoyUserInfo.roleRadio'
:radios='enjoyUserInfo.relationshipRadio'
label='享受人角色'
name='享受人角色'
:color='colorButton'
:type='typeButton'
v-validate="'required'"
></select-radio>
<van-field
@@ -74,7 +76,7 @@
name='享受人证件类型'
right-icon='arrow'
placeholder='请选择'
@click='toSelect("1")'
@click='toSelect("2")'
/>
<van-field
v-model='enjoyUserInfo.idNo'
@@ -97,6 +99,8 @@
:radios='enjoyUserInfo.sexRadio'
label='性别'
name='性别'
:color='colorButton'
:type='typeButton'
v-validate="'required'"
></select-radio>
<FieldDatePicter
@@ -111,7 +115,6 @@
ref='birthday'
></FieldDatePicter>
</van-cell-group>
<van-button type='danger' class='bottom-btn' @click='nextStep' v-no-more-click='1000'>下一步</van-button>
@@ -133,20 +136,24 @@ import IndexBar from '@/components/ebiz/allowance/application/IndexBar'
import { Field, CellGroup, Checkbox, Popup, Picker, Area, RadioGroup, Radio, Dialog } from 'vant'
import DataDictionary from '@/assets/js/utils/data-dictionary'
import utilsAge from '@/assets/js/utils/age'
import { selectComp, getIdentityInfo } from '../../sale/js/methods'
import { selectComp, getIdentityInfo } from '../js/methods'
import IdentityCardScan from '@/components/ebiz/sale/IdentityCardScan'
import { idToData } from '../../sale/js/verification'
import { idToData } from '../js/verification'
import CustomerPicker from '@/components/ebiz/customer/CustomerPicker'
import SelectRadio from '@/components/ebiz/SelectRadio'
import FieldDatePicter from '@/components/ebiz/FieldDatePicter'
import beforeDate from '@/assets/js/utils/getBeforeDate.js'
import idNoCheck from '@/assets/js/utils/idNoCheck'
import { getAgentInfo } from '@/api/ebiz/my/my.js'
import { getAllowanceDetail, saveOrUpdateAllowanceUrl } from '@/api/ebiz/allowance/allowance'
// import beforeDate from '@/assets/js/utils/getBeforeDate.js'
// import OccupationPicker from '@/components/ebiz/occipation/OccupationPicker'
// import areaList from '@/assets/js/utils/areaForSale'
// import areaLists from '@/assets/js/utils/areaNewForSale'
// import { saveOrUpdateOrderInfo, getAuthCode, getOrderDetail, getCompany } from '@/api/ebiz/sale/sale'
// import getAreaName from '@/assets/js/utils/getAreaNameForSale'
// import idNoCheck from '@/assets/js/utils/idNoCheck'
//
// import SearchField from '@/components/common/SearchField'
export default {
@@ -176,17 +183,17 @@ export default {
return {
// 定义存储申请人信息的对象
applicantInfo: {
jobNumber: '', // 申请人工号
name: '', // 申请人姓名
agentCode: '1', // 申请人工号
name: '1', // 申请人姓名
idType: '1', // 证件类型 (枚举值)
idNo: '' // 证件号码
},
// 定义存储享受人信息的对象
enjoyUserInfo: {
name: '', // 享受人姓名
role: '', // 享受人角色
// 享受人角色的选择项
roleRadio: [
relationship: '', // 享受人角色(与申请人的关系)
// 享受人角色(与申请人的关系)的选择项
relationshipRadio: [
{ value: '0', label: '父亲' },
{ value: '1', label: '母亲' }
],
@@ -198,19 +205,61 @@ export default {
],
idType: '1', // 证件类型 (枚举值)
idNo: '', // 证件号码
birthday: '',
maxDate: beforeDate.getBeforeYear(16)
birthday: ''
// 定义出生日子可选的最大日期
// 60表示60岁代表只能选择比60岁大的出生日期因为父母津贴功能贵司规定父母年龄需大于60岁才能领取津贴
// maxDate: beforeDate.getBeforeYear(60)
},
pickerType: '', // 定义当选择证件类型时为了区分填写的是申请人信息还是享受人信息的类型。1-申请人2-享受人
popupShow: false, // 定义控制显示或隐藏popup弹出层的变量
columns: [], // 定义popup弹出层中的数据集合
currentPopupIndex: '',
customerShowPicker: false,
isScan: false //是否显示证件扫描组件
isScan: false, //是否显示证件扫描组件
allowancePageFlag: '1',
colorButton: '#2E4591', // 定义享受人角色和性别选项的选项按钮的颜色
typeButton: 'default' // 定义享受人角色和性别选项的选项按钮的类型
}
},
created() {
if (this.$route.query.edit) {
const orderNo = this.$CacheUtils.getLocItem('orderNo')
getOrderDetail({ orderNo: orderNo }).then((res) => {
if (res.result == 0) {
//投保人信息返显
this.userInfo = res.orderDTO.appntDTO
this.setCustomerMarriage(res.orderDTO.appntDTO.marriage)
//是否长期
this.userInfo.effectiveDateType = res.orderDTO.appntDTO.effectiveDateType == 'false' ? false : true
//有无社保
this.userInfo.medical = res.orderDTO.appntDTO.medical
//设为联系地址
// this.userInfo.addressStatus = '0'
//证件类型
// this.userInfo.idType = '1'
//国家/地区
// this.userInfo.nativeplace = '1'
this.$utils.intLocalStorage(res)
if (this.$route.query.edit && !this.$route.query.salePageFlag) {
//如果从保单列表点击编辑按钮进入
this.salePageFlag = '1'
localStorage.setItem('salePageFlag', this.salePageFlag)
} else {
this.homeName = getAreaName([
{ code: res.orderDTO.appntDTO.homeProvince },
{ code: res.orderDTO.appntDTO.homeCity },
{ code: res.orderDTO.appntDTO.homeArea }
]) //获取联系地址
// this.census = getAreaName([{ code: res.orderDTO.appntDTO.householdProvince }, { code: res.orderDTO.appntDTO.householdCity }]) //获取户籍
}
}
})
} else {
localStorage.setItem('salePageFlag', this.salePageFlag)
this.$CacheUtils.setLocItem('saleInsuredInfo', '')
}
},
mounted() {
setTimeout(() => {
@@ -304,20 +353,10 @@ export default {
this.applicantInfo.idType = value.id
} else if (this.pickerType == '2') {
// 身份证号码不存在时赋默认值
if (!this.userInfo.idNo) {
this.userInfo.idNo = ''
if (!this.enjoyUserInfo.idNo) {
this.enjoyUserInfo.idNo = ''
}
//若身份证件类型为身份证,自动带入性别
let sexSign = this.userInfo.idNo.length == 18 ? this.userInfo.idNo.substr(16, 1) : this.userInfo.idNo.length == 15 ? this.userInfo.idNo.substr(14, 1) : ''
//18位身份证第17位是性别位, 奇男偶女;15位身份证第15位是性别位, 奇男偶女
if (sexSign) {
if (parseInt(sexSign) % 2 == 0) {
this.userInfo.sex = '1'
} else {
this.userInfo.sex = '0'
}
}
this.userInfo.idType = value.id
this.enjoyUserInfo.idType = value.id
}
},
@@ -339,17 +378,18 @@ export default {
})
// 将选择的享受人的数据,赋值给对应的变量
this.enjoyUserInfo.name = data.customerName // 享受人姓名
this.enjoyUserInfo.role = String(data.customerSex) // 享受人角色
this.enjoyUserInfo.relationship = String(data.customerSex) // 享受人角色(与申请人的关系)
this.enjoyUserInfo.idType = data.customerIdType // 享受人证件类型
this.enjoyUserInfo.idNo = data.customerIdNumber // 享受人证件号码
this.enjoyUserInfo.sex = String(data.customerSex) // 享受人性别
this.enjoyUserInfo.birthday = data.birthday // 享受人出生日期
this.getRelatedData(this.enjoyUserInfo.idNo)
this.getRelatedData(this.enjoyUserInfo.idNo) // 调用校验证件号码是否合规的方法
},
/**
* @Description:
* @params:
* @Description: 添加享受人证件号码后,失去焦点后触发的事件。此方法校验证件号码是否合规,
* @Description: 如果合规会自动填充享受人角色,性别,出生日期等信息
* @params: val--填写的证件号码
* @author:zhangqi
* @Date:2021-09-08
*/
@@ -359,12 +399,14 @@ export default {
}
//如果证件校验不通过,恢复默认值
if (idToData(val).text) {
;[this.enjoyUserInfo.idNo, this.enjoyUserInfo.sex] = ['', '0']
;[this.enjoyUserInfo.idNo, this.enjoyUserInfo.relationship, this.enjoyUserInfo.sex, this.enjoyUserInfo.birthday] = ['', '', '', '']
return this.$toast(idToData(val).text)
}
this.enjoyUserInfo.role = idToData(val).sex
} else {
// 如果合规会自动填充享受人角色,性别,出生日期等信息
this.enjoyUserInfo.relationship = idToData(val).sex // 性别男,表示的角色为父亲
this.enjoyUserInfo.sex = idToData(val).sex
this.enjoyUserInfo.birthday = idToData(val).birthday
}
},
/**
@@ -396,13 +438,18 @@ export default {
getIdentityInfo(this, data, '1')
},
/**
* @Description: 选择享受人出生日期时,点击确认按钮后,执行的方法,校验选择的日期不能晚于当前日期
* @params: val--选择的日期(年-月-日)
* @author:zhangqi
* @Date:2021-09-08
*/
onDateConfirm(val) {
//出生日期
//如果录入日期晚于当前日期
//判断录入日期是否晚于当前日期,因为录入日期不能晚于当前日期
if (Date.parse(val) > Date.parse(new Date())) {
this.enjoyUserInfo.birthday = ''
this.$refs.birthday.date = ''
return this.$toast('出生日期不晚于当日')
return this.$toast('出生日期不晚于当日')
}
},
@@ -416,215 +463,101 @@ export default {
let valid = await this.$validator.validate()
// .then(valid => {
if (true === valid) {
localStorage.chooseProductCodesNew = localStorage.chooseProductCodes
// 计算年龄
let age = utilsAge.getAge(this.userInfo.birthday, new Date())
// 如果是未成年人
// if (age < 18) {
// return this.$toast('投保人必须是具有民事行为能力且有固定职业和收入的自然人,请确定')
// }
//如果证件类型是身份证
if (this.userInfo.idType == '1') {
console.log('证件类型是身份证')
if (this.userInfo.nativeplace != '1') {
return this.$toast('证件类型”为“身份证,国籍必须为中国哦')
}
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 (this.applicantInfo.idType == '1') {
// 证件号码规则校验
if (!idNoCheck.isIdno(this.userInfo.idNo)) {
return this.$toast('您填写的证件号码有误')
}
//年龄在小于周岁不含46周岁证件有效期不能为长期
if (age < 46 && this.userInfo.effectiveDateType == true) {
return this.$toast('证件有效期错误年龄小于46周岁证件有效期不能为长期')
}
// 年龄在 16-25 周岁之间
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年')
if (!idNoCheck.isIdno(this.applicantInfo.idNo)) {
return this.$toast('您填写的申请人证件号码有误')
}
}
//证件类型是户口本
} else if (this.userInfo.idType == '2') {
if (age > 16) {
return this.$toast('客户年龄在16周岁以上不能使用户口本作为有效证件')
// 享受人的证件为身份证
if (this.enjoyUserInfo.idType == '1') {
// 证件号码规则校验
if (idNoCheck.isIdno(this.enjoyUserInfo.idNo)) {
// 根据身份证号校验选择的享受人性别18位身份证第17位是性别位, 奇男偶女
let sexSign = this.enjoyUserInfo.idNo.substr(16, 1)
if ((parseInt(sexSign) % 2 == 0 && this.enjoyUserInfo.sex != 1) || (parseInt(sexSign) % 2 != 0 && this.enjoyUserInfo.sex != 0)) {
return this.$toast('享受人性别与证件类型不一致,请修改。')
}
} else if (this.userInfo.idType == '3') {
if (age >= 2) {
return this.$toast('客户年龄在2周岁及以上不能使用出生证作为有效证件')
}
} else if (this.userInfo.idType == '4') {
if (this.userInfo.nativeplace == '1') {
return this.$toast('“证件类型”为“外国人护照”,“国籍”不能选择为“中国”哦~')
}
} else if (this.userInfo.idType == '5') {
console.log(this.userInfo.nativeplace, 'nativeplace')
if (this.userInfo.nativeplace != 2 && this.userInfo.nativeplace != 3) {
return this.$toast('“证件类型”为“港澳居民来往内地通行证”,“国籍”请选择“中国香港”或“中国澳门”哦~')
}
} else if (this.userInfo.idType == '6') {
if (this.userInfo.nativeplace != 4) {
return this.$toast('“证件类型”为“台湾居民来往大陆通行证”,“国籍”请选择“中国台湾”~')
}
} else if (this.userInfo.idType == '9') {
if (this.userInfo.nativeplace != 2 && this.userInfo.nativeplace != 3 && this.userInfo.nativeplace != 4) {
return this.$toast('“证件类型”为“港澳台居民居住证”,“国籍”请选择“中国香港”、“中国澳门”或“中国台湾”~')
}
}
// 投保人年龄必须大于等于16周岁哦
if (age < 16) {
return this.$toast('亲投保人年龄必须大于等于16周岁哦~')
}
//职业类型不能为 '一般学生'
if (this.userInfo.occupationCode == '2099907') {
this.userInfo.occupationName = ''
return this.$toast('学生不可以作为投保人,请更换投保人投保')
}
if (!this.userInfo.workcompany) {
this.userInfo.workcompany = '无'
}
if (this.userInfo.salarySource == '4') {
if (!this.userInfo.otherSalarySource) {
return this.$toast('请输入其它收入来源')
}
}
// 婚姻状况处理: 使用computed/watch可能会出现检测不到的情况
for (let status of DataDictionary.marriage) {
if (status.text === this.userInfo.marriageStatus) {
this.userInfo.marriage = status.id
}
}
/*
//如果是已婚
if ((this.userInfo.sex == '0' && age < 22) || (this.userInfo.sex == '1' && age < 20)) {
if (this.userInfo.marriage != '2') {
return this.$toast('投保人不符合国家婚姻法定年龄')
}
}
*/
// if (this.userInfo.marriage == '1') {
// if (this.userInfo.sex == '0' && age < 22) {
// return this.$toast('年龄与婚姻状况不符')
// } else if (this.userInfo.sex == '1' && age < 20) {
// return this.$toast('年龄与婚姻状况不符')
// }
// }
// 通过国籍判断 证件是否符合要求
// 如果是国籍选择中国大陆
if (Number(this.userInfo.nativeplace) <= 4) {
// “身份证”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证”
let obj = {
1: true,
5: true,
6: true,
9: 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周岁的未成年人证件类型必须为“身份证”或“户口本”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证”'
)
// 根据身份证号校验选择的享受人出生日期18位身份证第7-14位是生日位, 年月日
let birthSign = this.enjoyUserInfo.idNo.substr(6, 8)
if (
this.enjoyUserInfo.birthday.substr(0, 4) != birthSign.substr(0, 4) ||
this.enjoyUserInfo.birthday.substr(5, 2) != birthSign.substr(4, 2) ||
this.enjoyUserInfo.birthday.substr(8, 2) != birthSign.substr(6, 2)
) {
return this.$toast('享受人出生日期与证件类型不一致,请修改。')
}
} else {
// 大于16岁
if (obj[idType] === undefined) {
return this.$toast('亲,国籍为中国,证件类型必须为“身份证”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证”')
return this.$toast('您填写的享受人证件号码有误!')
}
}
} else {
// 非大陆人员按外籍人员
let obj = {
4: true,
8: true
// 判断当享受人角色为父亲,性别为女时,要进行提示
if (this.enjoyUserInfo.relationship == 0 && this.enjoyUserInfo.sex == 1) {
return this.$toast('享受人为父亲,性别不可为女,请修改。')
}
let idType = this.userInfo.idType
if (obj[idType] === undefined) {
return this.$toast('亲,国籍为外籍,证件类型必须为护照或外国人永久居留身份证投保')
// 判断当享受人角色为母亲,性别为男时,要进行提示
if (this.enjoyUserInfo.relationship == 1 && this.enjoyUserInfo.sex == 0) {
return this.$toast('享受人为母亲,性别不可为男,请修改。')
}
// 计算享受人年龄
let age = utilsAge.getAge(this.enjoyUserInfo.birthday, new Date())
// 享受人年龄需要满60周岁才能申请津贴
if (age < 60) {
return this.$toast('享受人需年满60周岁')
}
if (this.isAsync) {
if (
!this.userWorkcompanys.some((item) => {
return item.asscompanies == this.userInfo.workcompany
})
) {
if (
this.userWorkcompanys.some((item) => {
return item.asscompanies.search(this.userInfo.workcompany) != -1
})
) {
return this.$toast('请填写完整的协同单位名称')
}
return this.$toast('您选择的为非协同单位,请重新选择。')
}
}
this.infoUpdate()
// console.log('success')
// 调用保存当前录入的基本信息数据的方法
this.save()
} else {
return this.$toast(this.$validator.errors.all()[0])
}
// })
}
},
/**
* @Description: 保存当前录入的基本信息数据的方法
* @author:zhangqi
* @Date:2021-09-08
*/
save() {
let params = {
'allowanceDTO': {
'allowanceApplyDTO': this.applicantInfo,
'allowanceEnjoyDTO': this.enjoyUserInfo
}
}
let str = ''
saveOrUpdateAllowanceUrl(params).then(res => {
if (res.result == '0') {
if (this.$route.query.allowancePageFlag) {
str = 'edit=1&allowancePageFlag=2'
} else {
//如果从津贴申请列表编辑按钮或者新增津贴申请进入
localStorage.allowancePageFlag = '2'
}
// 跳转到账户信息页面
this.$jump({
flag: 'h5',
extra: {
url: location.origin + `/#/allowance/application/AccountInfo?${str}`
},
routerInfo: {
path: `/allowance/application/AccountInfo?${str}`
}
})
} else {
this.$toast(res.resultMessage)
}
}).catch(err => {
console.log(err)
})
}
},
computed: {},
watch: {}
}
</script>
<style lang='scss' scoped>
.insured-info-container {
/deep/ .van-checkbox {

View File

@@ -0,0 +1,94 @@
//点击弹出组件
export function selectComp(that, index, type = '') {
that.currentPopupIndex = index
let title = ''
if (index == 1) {
;[that.customerShowPicker, title] = [true, '父母列表']
} else if (index == 2) {
;[that.occupationShowPicker, title] = [true, '职业类别']
} else if (index == 3) {
if (type == '1') {
//投保人
localStorage.scanFromInsured = 'true'
} else if (type == '2') {
//被保险人
localStorage.scanFromInsured = 'false'
}
;[that.isScan, title] = [true, '身份证扫描']
}
setTimeout(() => {
that.$jump({
flag: 'navigation',
extra: {
title,
hiddenLeft: '1'
}
})
closeBtn(that)
}, 400)
}
// 关闭按钮的显示
function closeBtn(that) {
that.$jump({
flag: 'webview_right_button',
extra: {
btns: [
{
img: that.$assetsUrl + 'images/del-close.png',
route: { flag: '', extra: {} }
}
]
}
})
}
// 获取身份证扫描信息
/**
*
* @param {*} that 上下文
* @param {*} data 扫描数据
* @param {*} type 1 投保人 2 被保险人
*/
export function getIdentityInfo(that, data, type) {
// 正面
if (data.name && data.name != '待识别') {
that.userInfo.name = data.name
that.userInfo.idNo = data.idNo
that.userInfo.birthday = `${data.birthYear}-${data.birthMonth}-${data.birthDay}`
that.userInfo.sex = data.gender == '男' ? '0' : '1'
}
// 反面
if (data.startDate && data.startDate != '待识别') {
that.userInfo.certificateValidate = `${data.startDate.substr(0, 4)}-${data.startDate.substr(5, 2)}-${data.startDate.substr(8, 2)}`
//that.userInfo.certificateValidate = `${data.startDate.substr(0, 4)}-${data.startDate.substr(4, 2)}-${data.startDate.substr(6, 2)}`
// 是否为长期身份证
if (data.endDate != '长期') {
that.userInfo.certiexpiredate = `${data.endDate.substr(0, 4)}-${data.endDate.substr(5, 2)}-${data.endDate.substr(8, 2)}`
// that.userInfo.certiexpiredate = `${data.endDate.substr(0, 4)}-${data.endDate.substr(4, 2)}-${data.endDate.substr(6, 2)}`
that.effectiveDateTypeAble = true
that.idLimit = false
that.isRequired = true
} else {
// 勾选长期
that.userInfo.effectiveDateType = true
// 长期按钮不禁用
that.effectiveDateTypeAble = false
// 证件截止日期不需要校验
that.certiexpiredateRequired = false
//截止日期不可编辑
that.idLimit = true
that.isRequired = false
}
}
that.isScan = false
let title = type == '1' ? '投保人信息' : '被保险人信息'
that.$jump({
flag: 'navigation',
extra: {
title,
hiddenRight: '1'
}
})
}

View File

@@ -0,0 +1,54 @@
import changeFifteenToEighteen from '@/assets/js/utils/changeFifteenToEighteen'
import idNoCheck from '@/assets/js/utils/idNoCheck'
import utilsAge from '@/assets/js/utils/age'
//身份证带出出生日期,性别,年龄
export function idToData(idNo) {
//非空
if (!idNo.trim()) {
return {
text: '证件号码不能为空'
}
}
//如果是15位身份证号先转为18位
if (idNo.length == 15) {
idNo = changeFifteenToEighteen(idNo)
}
if (idNo.length != 18) {
return {
text: '亲居民身份证须为18位哦~'
}
}
// 证件号码规则校验
if (!idNoCheck.isIdno(idNo)) {
return {
text: '您填写的证件号码有误'
}
}
let birthday = getBirthById(idNo)
let age = utilsAge.getAge(birthday, new Date())
let sex = getSexById(idNo)
return {
birthday,
age,
sex
}
}
function getBirthById(idNo) {
// 获取生日
var year = idNo.substr(6, 4)
var month = idNo.substr(10, 2)
var day = idNo.substr(12, 2)
return year + '-' + month + '-' + day
}
function getSexById(idNo) {
// 获取性别
if (idNo.charAt(16) >= '0' && idNo.charAt(16) <= '9') {
if (parseInt(idNo.charAt(16)) % 2 == 0) {
return '1'
} else {
return '0'
}
}
}