Commit c87492dd authored by 李晓兵's avatar 李晓兵

'身份证识别结果'

parent 7f3cd95f
......@@ -46,29 +46,35 @@
<div class="upload-id-card">
<span>身份证照片上传</span>
<div class="upload-box">
<div @click="show()">
<div v-if="!idCardFront" @click="idCardshow('front')">
<img src="@/assets/userBind/front.png" >
<p>正面</p>
</div>
<div @click="show()">
<div v-if="idCardFront && !isApproved" @click="idCardshow('front')">
<img :src="idCardFront" style="width: 100%;height: 100%;margin: 0">
</div>
<div v-if="!idCardBack" @click="idCardshow('back')">
<img src="@/assets/userBind/back.png" >
<p>反面</p>
</div>
<div v-if="idCardBack && !isApproved" @click="idCardshow('back')">
<img :src="idCardBack" style="width: 100%;height: 100%;margin: 0">
</div>
</div>
</div>
<list-item :item-height="44" class="second-part">
<item>
<div slot="name" class="required">姓名</div>
<input
slot="content" :readonly="isApproved" v-model="baseInfo.bp_name" placeholder="上传身份证自动填充"
slot="content" v-model="baseInfo.bp_name" readonly placeholder="上传身份证自动填充"
class="auto" >
</item>
<item>
<div slot="name" class="required">身份证号码</div>
<input
slot="content"
:readonly="isApproved"
v-model="baseInfo.id_card_no"
readonly
placeholder="上传身份证自动填充"
class="auto"
>
......@@ -77,8 +83,8 @@
<div slot="name" class="required">户籍地址</div>
<input
slot="content"
:readonly="isApproved"
v-model="baseInfo.address_on_resident_booklit"
readonly
placeholder="上传身份证自动填充"
>
</item>
......@@ -262,6 +268,8 @@ export default {
invoice_kind: '',
user_phone: window.localStorage.user_phone,
},
idCardFront: '', // 身份证正面图片
idCardBack: '', // 身份证反面图片
}
},
watch: {
......@@ -364,19 +372,6 @@ export default {
window.localStorage.setItem('bp_name', vm.baseInfo.bp_name)
return res.bp_id
}
/* vm.hlsHttp.post(url, param).then(function (res) {
vm.hlsPopup.hideLoading()
if (res.result === 'S') {
vm.hlsPopup.showSuccess('保存成功')
vm.isSave = true
return res.bp_id
window.localStorage.setItem('user_id', res.bp_id)
window.sessionStorage.setItem('user_id', res.bp_id)
window.sessionStorage.setItem('bp_name', vm.baseInfo.bp_name)
window.localStorage.setItem('bp_name', vm.baseInfo.bp_name)
vm.getBankInfo()
}
}) */
},
async saveWord () {
let vm = this
......@@ -431,22 +426,21 @@ export default {
}
})
},
show () {
idCardshow (type) {
let vm = this
hlsPopup.showActionSheet({
titleText: '请选择照片',
buttonArray: ['拍照', '从相册取'],
callback: index => {
if (index === 0) {
vm.openCamera()
vm.openCamera(type)
} else {
vm.takePicture()
vm.takePicture(type)
}
},
})
},
openCamera () {
alert('相机')
openCamera (type) {
let vm = this
let cameraoptions = {
quality: 60,
......@@ -454,6 +448,7 @@ export default {
height: 1382,
}
let success = function (imgdata) {
type === 'front' ? vm.idCardFront = imgdata : vm.idCardBack = imgdata
vm.idCardIdentify(imgdata)
}
let error = function () {
......@@ -461,8 +456,7 @@ export default {
}
hlsUtil.openCamera(cameraoptions, success, error)
},
takePicture () {
alert('相册')
takePicture (type) {
let vm = this
var cameraoptions = {
quality: 70,
......@@ -471,6 +465,7 @@ export default {
maxCount: 1,
}
let success = function (imgUrl) {
type === 'front' ? vm.idCardFront = imgUrl[0] : vm.idCardBack = imgUrl[0]
vm.idCardIdentify(imgUrl[0])
}
let error = function () {
......@@ -480,13 +475,17 @@ export default {
},
// 身份证识别
idCardIdentify (fileUrl) {
alert('fileUrl '+ fileUrl)
let vm = this
hlsPopup.showLoading('正在识别')
let url = process.env.ocrPath + '/baidu/ocr/idCard'
hlsUtil.baiduOcr(fileUrl, url, function (res) {
hlsPopup.hideLoading()
alert('识别结果: '+ JSON.stringify(res))
let result = res.result.words_result
console.log('识别结果: ' + result)
console.log('姓名: '+ result.姓名.words)
vm.baseInfo.bp_name = result.姓名.words
vm.baseInfo.id_card_no = result.公民身份号码.words
vm.baseInfo.address_on_resident_booklit = result.住址.words
})
},
successCall () {
......
......@@ -279,7 +279,7 @@ export default {
saveToPhotoAlbum: window.localStorage.savePhoto || false,
correctOrientation: true,
}
$cordovaCamera.getPicture(options).then(onSuccess, onFail);
navigator.camera.getPicture(onSuccess, onFail, options)
} else {
window.hlsPopup.showLongCenter('参数有误!')
}
......
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