iphone6 系统版本10 ,无法上传图片
发布于 6 年前 作者 qianchao 3468 次浏览 最后一次编辑是 5 年前 来自 问答
  • 点击上传图片,拍照上传,确认图片后,加载中然后就没有了,没有上传图片
  • 应该是打印出返回的data
"pages/upPoto/main"
  • 提供一个最简复现 Demo
data () {
return {
   imgMaxWidth: 1500,
   imgMaxHeight: 1500

  }

},


methods: {

    getSaoyiSao (id) {

        var taskid = Number(id)

        var that = this

        var FSM = wx.getFileSystemManager()

        wx.chooseImage({

          count: 1, // 默认9

          sizeType: ['compressed'], // 指定只能为压缩图,首先进行一次默认压缩

          sourceType: ['camera'], // 可以指定来源是相册还是相机,默认二者都有

          success: function (photo) {

            wx.getImageInfo({

              src: photo.tempFilePaths[0],

              success: function (res) {

                var imgHeight = 0

                var imgWidth = 0

                var containerRatio = that.imgMaxWidth / that.imgMaxHeight

                var imgRatio = res.width / res.height

                if (imgRatio > containerRatio) {

                  imgWidth = that.imgMaxWidth

                  imgHeight = that.imgMaxWidth / imgRatio

                } else if (imgRatio < containerRatio) {

                  imgHeight = that.imgMaxHeight

                  imgWidth = that.imgMaxHeight * imgRatio

                }

                that.cWidth = Math.min(imgWidth, res.width)

                that.cHeight = Math.min(imgHeight, res.height)

                var ctx = wx.createCanvasContext('canvas')

                ctx.drawImage(res.path, 0, 0, that.cWidth, that.cHeight)

                ctx.draw(false, setTimeout(function () {

                  wx.canvasToTempFilePath({

                    fileType: 'jpg',

                    canvasId: 'canvas',

                    destWidth: that.cWidth,

                    destHeight: that.cHeight,

                    success: function (res) {

                      FSM.readFile({

                        filePath: res.tempFilePath,

                        encoding: 'base64',

                        success: function (data) {

                         console.log(data)

                        }

                      })

                    },

                    fail: function (res) {

                      console.log(res.errMsg)

                    }

                  })

                }, 300))

              }

            })

          }

        })

      }

}

 

5 回复

真机测试看看报没报错

H5还是小程序?报错信息是什么?

请问解决了吗,我这边也碰到这个问题,好几个用户反馈,选了图片,显示压缩中,请稍后,然后就没有然后了,其中一个手机型号是华为P9

请大神们帮我看看,这个为什么iphone没有执行成功,可以拍照,确定照片,但是显示加载中,然后就什么都没有了

回到顶部