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

'身份证识别结果'

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