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)
}
})
你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),以及提供下相关的图片。