chenjun

长图截取

@@ -173,6 +173,8 @@ struct createImg { @@ -173,6 +173,8 @@ struct createImg {
173 if (picWidth && picHeight) { 173 if (picWidth && picHeight) {
174 if (picWidth / picHeight > 2/1) { 174 if (picWidth / picHeight > 2/1) {
175 return 1; //横长图 175 return 1; //横长图
  176 + } else if (picWidth/picHeight > 1/2 && picWidth/picHeight < 3/4) { //截取图片
  177 + return 4;
176 } else if (picWidth/picHeight < 1/2) { 178 } else if (picWidth/picHeight < 1/2) {
177 return 2; //竖长图 179 return 2; //竖长图
178 } else { 180 } else {
@@ -236,6 +238,25 @@ struct createImg { @@ -236,6 +238,25 @@ struct createImg {
236 238
237 } 239 }
238 } 240 }
  241 + } else if (this.getPicType(item.weight, item.height) === 4) {
  242 + GridCol({
  243 + span: this.onePicW > this.onePicH ? 12 : 8
  244 + }) {
  245 + Image(this.loadImg ? item.fullUrl : '')
  246 + .backgroundColor(0xf5f5f5)
  247 + // .aspectRatio(this.onePicW > this.onePicH ? 343 / 198 : 228 / 305)
  248 + .width('100%')
  249 + .autoResize(true)
  250 + .objectFit(ImageFit.Cover)
  251 + .autoResize(true)
  252 + .aspectRatio(3/4)
  253 + .borderRadius(this.caclImageRadius(index))
  254 + .opacity(!item.weight && !item.height ? 0 : 1)
  255 + .onComplete((event?) => {
  256 + this.onePicW = event?.width || 0;
  257 + this.onePicH = event?.height || 0;
  258 + })
  259 + }
239 } else { 260 } else {
240 GridCol({ 261 GridCol({
241 span: this.onePicW > this.onePicH ? 12 : 8 262 span: this.onePicW > this.onePicH ? 12 : 8