//
function imageUtil(e) {
var imageSize = {};
var originalWidth = e.detail.width;//图片原始宽
var originalHeight = e.detail.height;//图片原始高
var originalScale = originalHeight/originalWidth;//图片高宽比
('originalWidth: ' + originalWidth)
('originalHeight: ' + originalHeight)
//获取屏幕宽高
({
success: function (res) {
var windowWidth = ;
var windowHeight = ;
var windowscale = windowHeight/windowWidth;//屏幕高宽比
('windowWidth: ' + windowWidth)
('windowHeight: ' + windowHeight)
if(originalScale < windowscale){//图片高宽比小于屏幕高宽比
//图片缩放后的宽为屏幕宽
= windowWidth;
= (windowWidth * originalHeight) / originalWidth;
}else{//图片高宽比大于屏幕高宽比
//图片缩放后的高为屏幕高
= windowHeight;
= (windowHeight * originalWidth) / originalHeight;
}
}
})
('缩放后的宽: ' + )
('缩放后的高: ' + )
return imageSize;
}
= {
imageUtil: imageUtil
}