公寓小程序端前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
873 B

export const ocrAction = async (filePath) => {
wx.showLoading({
title: '正在处理',
})
// TODO 将 tempFilePath 上传到 CDN 得到 url
let img_url = 'http://192.168.1.144:9000/mzjzf/身份反.jpg'
// 实现上传到 cdn 的代码, 将得到的 url 写到 img_url 中
// 调用服务市场接口 https://fuwu.weixin.qq.com/service/detail/000ce4cec24ca026d37900ed551415
try {
await wx.serviceMarket.invokeService({
api: 'OcrAllInOne',
service: 'wx79ac3de8be320b71',
data: {
img_url,
data_type: 3,
ocr_type: 1, // 详细见文档
}
})
wx.hideLoading()
} catch (e) {
wx.hideLoading()
throw e
}
}
export const takePhoto = async (tempFilePath) => {
if(tempFilePath){
return ocrAction(tempFilePath)
}
const filePath = await chooseImage()
return ocrAction(filePath)
}