一、使用“微信OCR识别”
相关文档 https://fuwu.weixin.qq.com/service/detail/000ce4cec24ca026d37900ed551415
二、小程序使用代码
wx.serviceMarket.invokeService({
service: 'wx79ac3de8be320b71', // '固定为服务商OCR的appid,非小程序appid',
api: 'OcrAllInOne',
data: {
img_url: res.tempFiles[0].tempFilePath,// 本地文件可以wxwx.previewImage打开
data_type: 3,
ocr_type: 8,
},
}).then(res => {
console.log('invokeService success', res)
}).catch(err => {
console.error('invokeService fail', err)
})
三、报错
invokeService fail Error: invokeService:fail 9301010 consumption failure (requestId: MLwNPoKL6lIcPM8Q3ygankSL1ax8YRnPAkLAAvq2IpBlTD-iWhsXBlk8XZhJ5LL3QmY)
at WASubContext.js?t=wechat&s=1695093645282&v=2.19.4:2
at Generator.next (<anonymous>)
at o (WASubContext.js?t=wechat&s=1695093645282&v=2.19.4:2)
at s (WASubContext.js?t=wechat&s=1695093645282&v=2.19.4:2)(env: Windows,mp,1.06.2306020; lib: 2.19.4)
(anonymous) @ index.js? [sm]:91
Promise.catch (async)
success @ index.js? [sm]:90
va @ WASubContext.js?t=wechat&s=1695093645282&v=2.19.4:2
success @ WASubContext.js?t=wechat&s=1695093645282&v=2.19.4:2
u @ WASubContext.js?t=wechat&s=1695093645282&v=2.19.4:2
(anonymous) @ WASubContext.js?t=wechat&s=1695093645282&v=2.19.4:2
o @ WASubContext.js?t=wechat&s=1695093645282&v=2.19.4:2
(anonymous) @ WASubContext.js?t=wechat&s=1695093645282&v=2.19.4:2
v @ WASubContext.js?t=wechat&s=1695093645282&v=2.19.4:2
(anonymous) @ WASubContext.js?t=wechat&s=1695093645282&v=2.19.4:2
(anonymous) @ WAServiceMainContext.js:2
(anonymous) @ VM52 asdebug.js:1
C @ VM52 asdebug.js:1
(anonymous) @ VM52 asdebug.js:1
g @ VM52 asdebug.js:1
f @ VM52 asdebug.js:1
(anonymous) @ VM52 asdebug.js:1
_ws.onmessage @ VM52 asdebug.js:1