陈剑华

fix: 18381 搜索结果页-无法加载出动态图片

@@ -112,6 +112,8 @@ interface picProps { @@ -112,6 +112,8 @@ interface picProps {
112 struct createImg { 112 struct createImg {
113 @Prop fullColumnImgUrls: FullColumnImgUrlDTO[] 113 @Prop fullColumnImgUrls: FullColumnImgUrlDTO[]
114 @State loadImg: boolean = false; 114 @State loadImg: boolean = false;
  115 + @State onePicW: number = 0; // 只有一张图时候图片的宽度
  116 + @State onePicH: number = 0; // 只有一张图时候图片的高度
115 117
116 async aboutToAppear(): Promise<void> { 118 async aboutToAppear(): Promise<void> {
117 if (this.fullColumnImgUrls.length === 4) { // 为了使用栅格布局以便于占用三分之二的宽度,加一个占位 119 if (this.fullColumnImgUrls.length === 4) { // 为了使用栅格布局以便于占用三分之二的宽度,加一个占位
@@ -177,7 +179,7 @@ struct createImg { @@ -177,7 +179,7 @@ struct createImg {
177 Image(this.loadImg ? item.fullUrl || item.url : '') 179 Image(this.loadImg ? item.fullUrl || item.url : '')
178 .backgroundColor(0xf5f5f5) 180 .backgroundColor(0xf5f5f5)
179 .width('100%') 181 .width('100%')
180 - .height(172) 182 + .height(198)
181 .autoResize(true) 183 .autoResize(true)
182 .borderRadius(this.caclImageRadius(index)) 184 .borderRadius(this.caclImageRadius(index))
183 } else if (this.getPicType(item.weight, item.height) === 2) { 185 } else if (this.getPicType(item.weight, item.height) === 2) {
@@ -215,14 +217,18 @@ struct createImg { @@ -215,14 +217,18 @@ struct createImg {
215 } 217 }
216 } else { 218 } else {
217 GridCol({ 219 GridCol({
218 - span: item.landscape === 1 ? 12 : 8 220 + span: this.onePicW > this.onePicH ? 12 : 8
219 }) { 221 }) {
220 Image(this.loadImg ? item.fullUrl : '') 222 Image(this.loadImg ? item.fullUrl : '')
221 .backgroundColor(0xf5f5f5) 223 .backgroundColor(0xf5f5f5)
222 - .aspectRatio(item.landscape === 1 ? 343 / 172 : 228 / 305) 224 + .aspectRatio(this.onePicW > this.onePicH ? 343 / 198 : 228 / 305)
223 .autoResize(true) 225 .autoResize(true)
224 .borderRadius(this.caclImageRadius(index)) 226 .borderRadius(this.caclImageRadius(index))
225 .opacity(!item.weight && !item.height ? 0 : 1) 227 .opacity(!item.weight && !item.height ? 0 : 1)
  228 + .onComplete((event?) => {
  229 + this.onePicW = event?.width || 0;
  230 + this.onePicH = event?.height || 0;
  231 + })
226 } 232 }
227 } 233 }
228 } else if (this.fullColumnImgUrls.length === 4) { 234 } else if (this.fullColumnImgUrls.length === 4) {