Commit 765a3b41 authored by linwenqing's avatar linwenqing

refactor:身份证识别修改

parent 492d6bea
...@@ -79,7 +79,8 @@ export default { ...@@ -79,7 +79,8 @@ export default {
data() { data() {
return { return {
student: {}, student: {},
token: '', qiToken: '',
vToken: null,
} }
}, },
computed: { computed: {
...@@ -118,7 +119,11 @@ export default { ...@@ -118,7 +119,11 @@ export default {
}, },
onLoad() { onLoad() {
this.student = getApp().globalData.student this.student = getApp().globalData.student
this.token = getApp().globalData.qiNiuToken this.qiToken = getApp().globalData.qiNiuToken
this.vToken = this.vuex_token
},
onUnload() {
uni.hideLoading()
}, },
methods: { methods: {
submit() { submit() {
...@@ -148,19 +153,24 @@ export default { ...@@ -148,19 +153,24 @@ export default {
}) })
}, },
getFront() { getFront() {
let that = this
//身份证正面图片识别 //身份证正面图片识别
upload.getPhoto(2, this.token).then((res) => { upload.getPhoto(2, this.qiToken).then((res) => {
this.student.identityFrontPath = res.key this.student.identityFrontPath = res.key
uni.showLoading({
title: '识别中,请稍后',
})
this.$u.api this.$u.api
.getCertifyInfoByType('front', { .getCertifyInfoByType('front', {
url: process.uniEnv.qn_asset_url + res.key, url: process.uniEnv.qn_asset_url + res.key,
}) })
.then((res) => { .then((res) => {
console.log('识别结果', res) uni.hideLoading()
this.student.name = res.name this.student.name = res.name
this.student.identityNumber = res.number this.student.identityNumber = res.number
}) })
.catch((data) => { .catch((data) => {
uni.hideLoading()
this.student.name = '' this.student.name = ''
this.student.identityNumber = '' this.student.identityNumber = ''
this.$u.toast('识别身份证信息错误') this.$u.toast('识别身份证信息错误')
...@@ -169,17 +179,22 @@ export default { ...@@ -169,17 +179,22 @@ export default {
}, },
getBack() { getBack() {
//身份证反面图片识别 //身份证反面图片识别
upload.getPhoto(2, this.token).then((res) => { upload.getPhoto(2, this.qiToken).then((res) => {
this.student.identityBackPath = res.key this.student.identityBackPath = res.key
uni.showLoading({
title: '识别中,请稍后',
})
this.$u.api this.$u.api
.getCertifyInfoByType('back', { .getCertifyInfoByType('back', {
url: process.uniEnv.qn_asset_url + res.key, url: process.uniEnv.qn_asset_url + res.key,
}) })
.then((res) => { .then((res) => {
uni.hideLoading()
console.log('识别结果', res) console.log('识别结果', res)
this.student.certificateValidityDate = res.expire this.student.certificateValidityDate = res.expire
}) })
.catch((data) => { .catch((data) => {
uni.hideLoading()
this.student.certificateValidityDate = '' this.student.certificateValidityDate = ''
this.$u.toast('识别身份证信息错误') this.$u.toast('识别身份证信息错误')
}) })
......
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