src: res.tempFilePaths[i],
success: function(img) {
that.compressImage(img.path);
},
fail: function(err) {}
});
}
} else {
uni.showToast({
title: this.staticinfo.tips[0],
icon: “none”
})
}
}
})
},
压缩图片 图文不能超过20Kb,并上传 that.uploadHead()
compressImage(img) {
var that = this
return new Promise((res) => {
var localPath = plus.io.convertAbsoluteFileSystem(img.replace(‘file://’, ‘’));
console.log(‘after’ + localPath);
// 压缩
plus.io.resolveLocalFileSystemURL(localPath, (entry) => {
entry.file((file) => { // 可通过entry对象操作图片
if (file.size > 20480) { // 压缩后size 大于20Kb
plus.zip.compressImage({
src: img,
quality: 0.5,
}, (event) => {