收藏
回答

OCR调用报错9301002?

export const ocrAction = async (filePath: string) => {
    wx.showLoading({
        title: "正在处理",
    })

    // 将 tempFilePath 上传到 CDN 得到 url 将本地图片转base64
    let img_url = await tempFilePathToBase64(filePath)
    // let img_url = new wx.serviceMarket.CDN({
    //   type: 'filePath',
    //   filePath: filePath,
    // }).options.filePath
    console.log('%c 😐 [ img_url ]-510', 'font-size:15px; background:#7B479A; color:#4DAB55;', img_url, typeof img_url);

    // 调用服务市场接口 https://fuwu.weixin.qq.com/service/detail/000ce4cec24ca026d37900ed551415
    try {
        const res = await wx.serviceMarket.invokeService({
            api: "OcrAllInOne",
            service: "wx79ac3de8be320b71",
            data: {
                img_url: img_url,
                data_type: 2, // 1:二进制;2:base64字符串;3:图片url
                ocr_type: 10, // 1:身份证;2:银行卡;3:行驶证;4:驾驶证;7:营业执照;8:通用OCR ; 10: 车牌识别
            },
        })
        console.log('%c 😠 [ ocrAction res ]-699', 'font-size:15px; background:#4BCD23; color:#9B1033;', res);
        wx.hideLoading()
    } catch (e) {
        console.log('%c 🙌 [ ocrAction e ]-91', 'font-size:15px; background:#CEF45D; color:#7D8CF5;', e);
        wx.hideLoading()
        throw e
    }
}

回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容