scan() {
let _this = this
wx.chooseImage({
count: 1,
success: async function(res) {
uni.showLoading({
title: '加载中',
mask: true
})
var tempImagePath = res.tempFilePaths
var fsm = wx.getFileSystemManager()
// console.log(fsm.readFileSync(tempImagePath[0],'base64'))
// console.log(res)
try {
const invokeRes = await wx.serviceMarket.invokeService({
service: 'wx79ac3de8be320b71',
api: 'OcrAllInOne',
data: {
// 需要一个HTTP URL 的文件
// img_url: res.tempFilePaths[0],
img_data: fsm.readFileSync(tempImagePath[0], 'base64'),
data_type: 2,
ocr_type: 1
},
})
uni.hideLoading()
// console.log('invokeService success', invokeRes)
_this.info.userName = invokeRes.data.idcard_res.name.text
_this.info.userNumber = invokeRes.data.idcard_res.id.text
console.log(invokeRes.data.idcard_res.name.text)
console.log(invokeRes.data.idcard_res.id.text)
} catch (err) {
uni.hideLoading()
console.error('invokeService fail', err)
_this.$refs.uToast.show({
title: err,
type: 'error',
})
}
},
fail: function(res) {},
complete: function(res) {},
})
},
调用微信orc识别 , 在微信开发者工具没问题,在ios端 报错
"operateWXData:fail data exceed max size","err_code":"0"