/*计算图片尺寸*/
function caculateImgSize(url) {
let max_width = 690;
let max_height = 600;
let results;
return new Promise((resolve, reject)=>{
uni.getImageInfo({
src: url,
success: function(res) {
let width = res.width;
let height = res.height;
let rate = width / height;
if (width > height) {
if (width <= max_width) {
results = {
"width": width,
"height": height
};
} else {
results = {
"width": width,
"height": width / rate
};
}
} else {
if (height <= max_height) {
results = {
"width": width,
"height": height
};
} else {
results = {
"width": height * rate,
"height": height
};
}
}
resolve(res)
},
fail: function(error){
reject(error)
}
})
})
}