首页 > 其他分享 >获取图片(身份证)转base64

获取图片(身份证)转base64

时间:2023-01-07 14:11:19浏览次数:36  
标签:console log res base64 获取 let 身份证 gotResource

gotmgs(){
  let self = this
  wx.chooseMedia({
    count: 1,
    mediaType: ['image'],
    sourceType: ['album', 'camera'],
    maxDuration: 30,
    camera: 'back',
    success(res) {
      console.log(res)
      let gotResource = res.tempFiles[0].tempFilePath //获取到的拍照的身份信息
      console.log(gotResource)
      uni.compressImage({
        src: gotResource, // 图片路径
        quality: 80 ,// 压缩质量
        success:res=>{
          console.log("压缩正常")
          console.log(res)
          let gotResource = res.tempFilePath
          wx.getFileSystemManager().readFile({
            filePath: gotResource,
            encoding: "base64",
            success: res => {
              let image= res.data
              self.getInformationForHumen(image) //上传身份证的接口
            },
            fail: err => {
              console.log("转换base64失败")
            }
          })
        },
        fail:err=>{
          console.log("压缩失败")
        }

      })
    }
  })
},

标签:console,log,res,base64,获取,let,身份证,gotResource
From: https://www.cnblogs.com/yhxy/p/17032565.html

相关文章