<view class="front_box" data-type="2" bindtap="bindUploadFile">
<image class="idcard_outline" src="{{frontPic}}"></image>
<view class="flex tip">
<image class="icon-cammer" src="{{imgUrl}}icon-cammer.jpg"></image>
<text>点击扫描身份证</text>
<text class="bold PingFangM">人像面</text>
</view>
bindUploadFile(e){
let that=this;
let type =e.currentTarget.dataset.type;
console.log(that.data.orderNo)
wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths
console.log(tempFilePaths)
let imgFormat = tempFilePaths[0].substring(tempFilePaths[0].lastIndexOf(".") + 1, tempFilePaths[0].length);
wx.getFileSystemManager().readFile({
filePath: res.tempFilePaths[0], //选择图片返回的相对路径
encoding: 'base64', //编码格式
success: ret => { //成功的回调
// console.log('data:image/png;base64,' + ret.data)
let param={
flag: "flag",
rqstType: 'AJAX',
channelNo: '23',
identifyNo: '1',
ocrType: '07',
imgType: imgFormat,
paramData: ret.data,
type: type,
orderNo: that.data.orderNo,
customType: '1',
contNo: that.data.orderNo
}
request({
url: 'OCR',
data: param
}).then(rest=>{
let data = JSON.parse(rest.MESSAGE);
wx.showToast({
title: data.message.value,
icon: 'none'
})
if(type==='2'){
if (data.cardsinfo){
that.setData({
'cardInfo.name': data.cardsinfo.card.item[1],
'cardInfo.sex': data.cardsinfo.card.item[2],
'cardInfo.birthday': data.cardsinfo.card.item[4],
'cardInfo.idNo': data.cardsinfo.card.item[6],
frontPic: tempFilePaths,
frontPicFlag: true
})
}
}else{
if (data.cardsinfo) {
that.setData({
'cardInfo.endDate': data.cardsinfo.card.item[4],
backPic: tempFilePaths,
backPicFlag: true
})
}
}
})
}
})
}
})
}
在wx.chooseImage 的时候打开相册,选择完成以后又跳回到相册中如何解决(没有报错,走的是success,我也没有再次调用接口),有时候会出现,有时候不会出现
bindUploadFile(e){ let that=this; if (that.data.onChoose) return this.data.onChoose = true .... wx.chooseImage完成之后将this.data.onChoose = false
可能是重复点击了
麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)