使用页面的json
{
"usingComponents": {
"ocr-navigator": "plugin://ocr-plugin/ocr-navigator"
}
}
在app.json 文件上加入
"plugins": {
"ocr-plugin": {
"version": "3.0.3",
"provider": "wx4418e3e031e551be"
}
},
1.1 正面上传
<ocr-navigator bind:onSuccess="success" certificateType="idCard" opposite="{{false}}">
<image src="{{positive}}" mode="widthFix"></image>
</ocr-navigator>
1.2 反面上传
<ocr-navigator bind:onSuccess="success_up" certificateType="idCard" opposite="{{true}}">
<image src="{{other}}" mode="widthFix"></image>
</ocr-navigator>
1.3 js
//data数据
data: {
positive:'../../image/shenfen/zheng.png',
other:'../../image/shenfen/fan.png',
},
//上面
success(e){
console.log(e.detail.image_path)
}
//背面
success_up(e){
console.log(e.detail.image_path)
}
1.4 js 文件返回时上传到后端服务器
var url = api+'/modules/authFile/uploadFile'
var that = this;
wx.uploadFile({
url: url,
filePath: e.detail.image_path,
name: 'file',
header: {
'content-type': 'multipart/form-data'
},
success: function (res) {
console.log(res) //接口返回网络路径
var data = JSON.parse(res.data)
// that.data.picPaths.push(data['msg'])
// that.setData({
// // picPaths: that.data.picPaths
// })
// console.log(that.data.picPaths)
}
})