收藏
回答

从相册选择的临时路径,解析不出来?

const invokeRes = await wx.serviceMarket.invokeService({

service: 'wx79ac3de8be320b71', // '固定为服务商OCR的appid,非小程序appid',

api: 'OcrAllInOne',

data: {

img_url: new wx.serviceMarket.CDN({

type:'filePath',

filePath: res.tempFilePaths[0]

}),

data_type: 3,

ocr_type: 1,

},

}).then(res => {

console.log('invokeService success', res)

idCard_address=res.data.idcard_res.address.text;

idCard_number = res.data.idcard_res.id.text;

}



提示这个错误,invokeService fail Error: invokeService:fail [object Object]

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

1 个回答

  • 圣殿骑士
    圣殿骑士
    2020-06-24

    你用的是第三方框架了吧。。。试试看源生的 wx.getImageInfo,美滋滋哦


    wx.getImageInfo({
              src: headUri || defaultHeadUri,//服务器返回的图片地址
              successfunction (res{
                //res.path是网络图片的本地地址
                let headImageLocal = res.path;
                app.globalData.tempWxHeader = res.path;  //将头像缓存在全局变量里
                canvasWxHeader(headImageLocal)
              },
              failfunction (res{
                //失败回调
                self.posterFail();
              }
            });
    


    saveImg() {
          let self = this;
          wx.canvasToTempFilePath({
            fileType'jpg',
            //quality: 0.8,
            canvasId'posterCanvas',
            success(res) => {
              console.log(res);
              self.setData({ canClosetrue });
              //保存图片
              wx.saveImageToPhotosAlbum({
                filePath: res.tempFilePath,
                successfunction (data{
                  wx.showToast({
                    title'已保存到相册',
                    icon'success',
                    duration2000
                  })
                  // setTimeout(() => {
                  //   self.setData({show: false})
                  // }, 6000);
                },
                failfunction (err{
                  console.log(err);
                  if (err.errMsg === "saveImageToPhotosAlbum:fail auth deny") {
                    console.log("当初用户拒绝,再次发起授权")
                    self.secondGetPhoteAuthor();
                  } else {
                    util.showToast("请截屏保存分享");
                  }
                },
                complete(res) {
                  wx.hideLoading();
                  console.log(res);
                }
              })
            },
            fail(res) {
              console.log(res);
            }
          }, this)
        },
    
    2020-06-24
    有用
    回复
登录 后发表内容
问题标签