身份证OCR校验之前端逻辑开发 --李婕煜

This commit is contained in:
li.jieyu@ebiz-digits.com
2021-07-30 16:40:41 +08:00
parent 412be99292
commit 8f7a940fd3
2 changed files with 104 additions and 2 deletions

View File

@@ -298,3 +298,13 @@ export function getBankCardSignState(data) {
data
})
}
// 身份证OCR识别
export function IDCardOCR(data) {
return request1({
url: getUrl('/customer/IDCardOCR', 1),
method: 'post',
data
})
}

View File

@@ -354,9 +354,11 @@
<script>
import DataDictionary from '@/assets/js/utils/data-dictionary'
import { Cell, CellGroup, Field, Uploader, RadioGroup, Radio, Dialog, Picker, Popup } from 'vant'
import { uploadImg, saveInformation, getOrderDetail } from '@/api/ebiz/sale/sale'
import { uploadImg, saveInformation, getOrderDetail, IDCardOCR } from '@/api/ebiz/sale/sale'
import config from '@/config'
import IndexBar from '@/components/ebiz/sale/IndexBar'
import utils from '../../../assets/js/business-common'
export default {
data() {
@@ -428,6 +430,7 @@ export default {
relationToAppnt: '',
changeCard: localStorage.changeCard,
salePageFlag: '7',
imageType: ''
}
},
created() {
@@ -981,6 +984,7 @@ export default {
subBusinessNo: that.saleInsuredInfo.appntId,
fileName: that.imgName,
}
this.imageType = imageInfoType
that.list.push(obj)
} else if (
that.type == 'fileListIdFrontInsured' ||
@@ -1056,7 +1060,7 @@ export default {
subBusinessNo: that.saleInsuredPersonInfo.insuredId,
fileName: that.imgName,
}
this.imageType = imageInfoType
that.list.push(obj)
} else if (that.type == 'fileListOther') {
// 是其他
@@ -1101,6 +1105,30 @@ export default {
// }
// that.list.push(obj)
}
let imgPath = res.path
if(that.type == 'fileListIdFront' || that.type == 'fileListIdBack' || that.type == 'fileLIstImg' ||
that.type == 'fileListIdFrontInsured' || that.type == 'fileListIdBackInsured' || that.type == 'fileLIstImgInsured'){
if(that.id == '1' && this.imageType == '1' && that.type == 'fileListIdFront'){
//投保人身份证正面
this.IDCardOCRValite(that.id, this.orderNo, imgPath, 'FRONT', 'appentFront')
}else if(that.id == '1' && this.imageType == '2' && that.type == 'fileListIdBack'){
//投保人身份证反面
this.IDCardOCRValite(that.id, this.orderNo, imgPath, 'BACK', 'appentBack')
}else if(that.id == '1' && this.imageType == '1' && that.type == 'fileListIdFrontInsured'){
//被保人身份证正面
this.IDCardOCRValite(that.id, this.orderNo, imgPath, 'FRONT', 'insuredFront')
}else if(that.id == '1' && this.imageType == '2' && that.type == 'fileListIdBackInsured'){
//被保人身份证反面
this.IDCardOCRValite(that.id, this.orderNo, imgPath, 'BACK', 'insuredBack')
}else {
//其他素材
this.IDCardOCRValite(that.id, this.orderNo, imgPath, "OTHER", '')
}
}
} else {
switch (that.type) {
case 'fileListIdFront':
@@ -1186,6 +1214,70 @@ export default {
this.$toast('请勾选确认销售人员已见证各证件原件并拍照上传')
}
},
IDCardOCRValite(idType, orderNo, imgPath, cardSide, flag){
let param = {
idType : idType,
orderNo : orderNo,
imgPath : imgPath,
cardSide : cardSide,
}
//调用身份证OCR识别
IDCardOCR(param).then((res) => {
if(res.result == '0'){
//如果识别的身份证信息与填写的不一致,进行提示
let isFlag = true;
//投保人身份证正面
if('appentFront' == flag){
this.saleInsuredInfo.sex = this.saleInsuredInfo.sex == '0'? '男' :'女'
res.birth = utils.formatDate(Date.parse(res.birth), 'yyyy-MM-dd')
if(this.saleInsuredInfo.name != res.name ||
this.saleInsuredInfo.sex != res.sex ||
this.saleInsuredInfo.birthday != res.birth ||
this.saleInsuredInfo.idNo != res.idNum
){
isFlag = false;
}
}
// else if('appentBack' == flag){
// //投保人身份证反面
// //"ValidDate": "2010.07.21-2020.07.21"
// res.validDate = res.validDate.split('-')[1].replace(/\./g,'-')
// if(this.saleInsuredInfo.certiexpiredate != res.validDate){
// isFlag = false;
// }
// }
else if('insuredFront' == flag){
this.saleInsuredPersonInfo.sex = this.saleInsuredPersonInfo.sex == '0'? '男' :'女'
res.birth = utils.formatDate(Date.parse(res.birth), 'yyyy-MM-dd')
//被保人身份证正面
if(this.saleInsuredPersonInfo.name != res.name ||
this.saleInsuredPersonInfo.sex != res.sex ||
this.saleInsuredPersonInfo.birthday != res.birth ||
this.saleInsuredPersonInfo.idNo != res.idNum
){
isFlag = false;
}
}
// else if('insuredBack' == flag){
// //被保人身份证反面
// //"ValidDate": "2010.07.21-2020.07.21"
// res.validDate = res.validDate.split('-')[1].replace(/\./g,'-')
// if(this.saleInsuredInfo.certiexpiredate != res.validDate){
// isFlag = false;
// }
// }
if(!isFlag){
this.$toast.clear()
this.$toast("上传的证件信息与录入的证件信息不一致,请核对修改并重新上传。")
}
}else{
this.$toast.clear()
this.$toast(res.resultMessage)
}
});
},
// 点击下一步
next() {
console.log(888)