收藏
回答

微信小程序调用云函数,实现OCR银行卡识别成功拿不到银行卡number,很疑惑?

 //选择图片
  chooseImage: function(callBack{
    let self = this;
    let type = "yinhangka"
    wx.chooseImage({
      count: 1,
      sizeType: ['compressed'],
      sourceType: ['camera''album'],
      success: function(res{
        let tempFilePath = res.tempFilePaths[0]
        let imgUrl = tempFilePath
        self.uploadImg(type,imgUrl)
        network.uploadFile(tempFilePath).then(res => {
          if (typeof callBack === 'function')
            callBack({
              tempFilePath,
              fjid: res.data.data.fjid
            })
        })
      }
    })
  },
/* 修改开始 */
  // 上传图片到云存储
  uploadImg(type, imgUrl) {
    let that = this
    wx.cloud.uploadFile({
      cloudPath: 'add/' + type + '.png',
      filePath: imgUrl, // 文件路径
      success: res => {
        console.log("上传成功", res.fileID)
        that.getImgUrl(type, res.fileID)
      },
      fail: err => {
        console.log("上传失败", err)
      }
    })
  },
  
  //获取云存储里的图片url
  getImgUrl(type, imgUrl) {
    let that = this
    wx.cloud.getTempFileURL({
      fileList: [imgUrl],
      success: res => {
      let imgUrl = res.fileList[0].tempFileURL
      console.log("获取图片url成功", imgUrl)
      that.shibie(type, imgUrl)
    },
      fail: err => {
        console.log("获取图片url失败", err)
      }
    })
  },
  
  //调用云函数,实现OCR识别
  shibie(type, imgUrl) {
    wx.cloud.callFunction({
      name: "add",
      data: {
        typetype,
        imgUrl: imgUrl
      },
      success(res) {
        console.log("识别成功", res)
      },
      fail(res) {
        console.log("识别失败", res)
      }
    })
  },

  //上传图片
  uploadCard: function(e{
    this.chooseImage(res => {
      var item = this.data.item
      item.src = res.tempFilePath
      this.setData({
        item: item
      })
      this.data.clxxItem = {
        fjid: res.fjid,
        cllx: item.cllx
      }
    })
  },

已经是成功调用了OCR的银行卡方法,就是拿不到number,这个是为什么呢,网上帖子发出来都有个number的:网上帖子截图如下

希望有大神帮忙解答下

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

2 个回答

  • *.小涛
    *.小涛
    2020-11-10

    大佬最后你怎么解决呢

    2020-11-10
    有用
    回复
  • Mr.Zhao
    Mr.Zhao
    2020-02-26

    你云函数没重新上传吧,你这个返回结果,是云函数模板的返回值,没必要犯这种错误吧

    2020-02-26
    有用
    回复 7
    • Jon信念
      Jon信念
      2020-02-26
      已经同步到云函数列表里了
      2020-02-26
      回复
    • Jon信念
      Jon信念
      2020-02-26
      我是在本地进行真机测试的,方法是已经成功调用。图片也能正常上传到云
      2020-02-26
      回复
    • Mr.Zhao
      Mr.Zhao
      2020-02-26回复Jon信念
      你点错了,是增量上传云函数或者部署云函数,skr
      2020-02-26
      回复
    • Mr.Zhao
      Mr.Zhao
      2020-02-26回复Jon信念
      也只是你本地调试而已,没有上传到云服务器上
      2020-02-26
      回复
    • Jon信念
      Jon信念
      2020-02-26
      你是指单个文件增量上传是吗
      2020-02-26
      回复
    查看更多(2)
登录 后发表内容
问题标签