[图片][图片]
wx.compressImage压缩图片,在苹果机上无效,甚至还比原图大点wx.chooseImage({ count: 1, sizeType: ['compressed'], sourceType: ['album', 'camera'], success: function(res) { console.log(res) var tempFilePaths = res.tempFilePaths; var sizeImg = res.tempFiles[0].size; console.log( '压缩前',sizeImg) wx.compressImage({ src: res.tempFiles[0].path, // 图片路径 quality: 86, // 压缩质量 success: function(res) { let tempFile = res.tempFilePath console.log("tempFile1", tempFile) wx.getFileInfo({ filePath: tempFile, success (res) { console.log("res", res) let picSize = res.size console.log("压缩后", picSize) // 150 (kb)=153600 (b) if( picSize <= 153600 ){ if(index == 1) { that.setData({ idCardFront: tempFilePaths }) } else { that.setData({ idCardBack: tempFilePaths }) } that.imageUpload(that, tempFilePaths, index); }else{ wx.showToast({ title: '上传图片过大,请上传不超过150kb的图片', icon:'none' }) } } }) }, fail: error => { console.log("error", error) } })
2020-12-25