Showing
1 changed file
with
8 additions
and
9 deletions
| @@ -203,11 +203,9 @@ struct createImg { | @@ -203,11 +203,9 @@ struct createImg { | ||
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | getPicHeight(picWidth: number, picHeight: number) { | 205 | getPicHeight(picWidth: number, picHeight: number) { |
| 206 | - //console.info(`cj2024 getPicType picWidth = ${picWidth} picHeight = ${picHeight} picWidth / picHeight = ${picWidth / picHeight}`) | ||
| 207 | if (picWidth && picHeight) { | 206 | if (picWidth && picHeight) { |
| 208 | - let imageH = 305 | ||
| 209 | let sizeH = this.compWidth * picHeight / picWidth | 207 | let sizeH = this.compWidth * picHeight / picWidth |
| 210 | - return Math.max(sizeH,imageH) | 208 | + return picWidth/picHeight === 1 ? 228:sizeH |
| 211 | } else { | 209 | } else { |
| 212 | return 305; //普通图 | 210 | return 305; //普通图 |
| 213 | } | 211 | } |
| @@ -260,7 +258,7 @@ struct createImg { | @@ -260,7 +258,7 @@ struct createImg { | ||
| 260 | Image(this.loadImg ? item.url || item.fullUrl : '') | 258 | Image(this.loadImg ? item.url || item.fullUrl : '') |
| 261 | .backgroundColor(0xf5f5f5) | 259 | .backgroundColor(0xf5f5f5) |
| 262 | .width('100%') | 260 | .width('100%') |
| 263 | - .aspectRatio(16 / 9) | 261 | + .height(this.compWidth * 16 / 9) |
| 264 | .autoResize(true) | 262 | .autoResize(true) |
| 265 | .borderRadius(this.caclImageRadius(index)) | 263 | .borderRadius(this.caclImageRadius(index)) |
| 266 | .borderStyle(BorderStyle.Solid) | 264 | .borderStyle(BorderStyle.Solid) |
| @@ -268,6 +266,7 @@ struct createImg { | @@ -268,6 +266,7 @@ struct createImg { | ||
| 268 | .borderColor($r('app.color.color_0D000000')) | 266 | .borderColor($r('app.color.color_0D000000')) |
| 269 | } else if (this.getPicType(item.weight, item.height) === 2) { | 267 | } else if (this.getPicType(item.weight, item.height) === 2) { |
| 270 | Image(this.loadImg ? item.url || item.fullUrl : '') | 268 | Image(this.loadImg ? item.url || item.fullUrl : '') |
| 269 | + .backgroundColor(0xf5f5f5) | ||
| 271 | .width('100%') | 270 | .width('100%') |
| 272 | .height(305) | 271 | .height(305) |
| 273 | .autoResize(true) | 272 | .autoResize(true) |
| @@ -304,8 +303,7 @@ struct createImg { | @@ -304,8 +303,7 @@ struct createImg { | ||
| 304 | .width('100%') | 303 | .width('100%') |
| 305 | .autoResize(true) | 304 | .autoResize(true) |
| 306 | .objectFit(ImageFit.Cover) | 305 | .objectFit(ImageFit.Cover) |
| 307 | - .autoResize(true) | ||
| 308 | - .aspectRatio(3/4) | 306 | + .height(this.compWidth * 3 / 4) |
| 309 | .borderRadius(this.caclImageRadius(index)) | 307 | .borderRadius(this.caclImageRadius(index)) |
| 310 | .borderStyle(BorderStyle.Solid) | 308 | .borderStyle(BorderStyle.Solid) |
| 311 | .borderWidth(0.5) | 309 | .borderWidth(0.5) |
| @@ -339,9 +337,10 @@ struct createImg { | @@ -339,9 +337,10 @@ struct createImg { | ||
| 339 | .backgroundColor(0xf5f5f5) | 337 | .backgroundColor(0xf5f5f5) |
| 340 | // .aspectRatio(this.onePicW > this.onePicH ? 343 / 198 : 228 / 305) | 338 | // .aspectRatio(this.onePicW > this.onePicH ? 343 / 198 : 228 / 305) |
| 341 | .width('100%') | 339 | .width('100%') |
| 342 | - .constraintSize({ | ||
| 343 | - maxHeight: this.getPicHeight(this.onePicW,this.onePicH) | ||
| 344 | - }) | 340 | + .height(this.getPicHeight(item.weight,item.height)) |
| 341 | + // .constraintSize({ | ||
| 342 | + // maxHeight: this.getPicHeight(this.onePicW,this.onePicH) | ||
| 343 | + // }) | ||
| 345 | .autoResize(true) | 344 | .autoResize(true) |
| 346 | .borderRadius(this.caclImageRadius(index)) | 345 | .borderRadius(this.caclImageRadius(index)) |
| 347 | .borderStyle(BorderStyle.Solid) | 346 | .borderStyle(BorderStyle.Solid) |
-
Please register or login to post a comment