chenjun

长图截取

... ... @@ -173,6 +173,8 @@ struct createImg {
if (picWidth && picHeight) {
if (picWidth / picHeight > 2/1) {
return 1; //横长图
} else if (picWidth/picHeight > 1/2 && picWidth/picHeight < 3/4) { //截取图片
return 4;
} else if (picWidth/picHeight < 1/2) {
return 2; //竖长图
} else {
... ... @@ -236,6 +238,25 @@ struct createImg {
}
}
} else if (this.getPicType(item.weight, item.height) === 4) {
GridCol({
span: this.onePicW > this.onePicH ? 12 : 8
}) {
Image(this.loadImg ? item.fullUrl : '')
.backgroundColor(0xf5f5f5)
// .aspectRatio(this.onePicW > this.onePicH ? 343 / 198 : 228 / 305)
.width('100%')
.autoResize(true)
.objectFit(ImageFit.Cover)
.autoResize(true)
.aspectRatio(3/4)
.borderRadius(this.caclImageRadius(index))
.opacity(!item.weight && !item.height ? 0 : 1)
.onComplete((event?) => {
this.onePicW = event?.width || 0;
this.onePicH = event?.height || 0;
})
}
} else {
GridCol({
span: this.onePicW > this.onePicH ? 12 : 8
... ...