wangliang_wd

feat:优化人民号动态卡以及动态详情页图片展示

@@ -1045,6 +1045,7 @@ struct createImg { @@ -1045,6 +1045,7 @@ struct createImg {
1045 @Prop loadImg: boolean = true; 1045 @Prop loadImg: boolean = true;
1046 @State onePicW: number = 0; // 只有一张图时候图片的宽度 1046 @State onePicW: number = 0; // 只有一张图时候图片的宽度
1047 @State onePicH: number = 0; // 只有一张图时候图片的高度 1047 @State onePicH: number = 0; // 只有一张图时候图片的高度
  1048 + compWidth = (DisplayUtils.getDeviceWidth() - 32)
1048 1049
1049 async aboutToAppear(): Promise<void> { 1050 async aboutToAppear(): Promise<void> {
1050 if (this.fullColumnImgUrls.length === 4) { // 为了使用栅格布局以便于占用三分之二的宽度,加一个占位 1051 if (this.fullColumnImgUrls.length === 4) { // 为了使用栅格布局以便于占用三分之二的宽度,加一个占位
@@ -1108,6 +1109,21 @@ struct createImg { @@ -1108,6 +1109,21 @@ struct createImg {
1108 } 1109 }
1109 } 1110 }
1110 1111
  1112 + getPicHeight(picWidth: number, picHeight: number) {
  1113 + //console.info(`cj2024 getPicType picWidth = ${picWidth} picHeight = ${picHeight} picWidth / picHeight = ${picWidth / picHeight}`)
  1114 + if (picWidth && picHeight) {
  1115 + let imageH = 305
  1116 + let sizeH = this.compWidth * picHeight / picWidth
  1117 + if (sizeH > imageH) {
  1118 + return sizeH
  1119 + }else {
  1120 + return imageH
  1121 + }
  1122 + } else {
  1123 + return 305; //普通图
  1124 + }
  1125 + }
  1126 +
1111 @Builder 1127 @Builder
1112 longPicTip(weight: number, height: number) { 1128 longPicTip(weight: number, height: number) {
1113 if (weight / height > 2 || height / weight > 2){ 1129 if (weight / height > 2 || height / weight > 2){
@@ -1216,7 +1232,7 @@ struct createImg { @@ -1216,7 +1232,7 @@ struct createImg {
1216 // .aspectRatio(this.onePicW > this.onePicH ? 343 / 198 : 228 / 305) 1232 // .aspectRatio(this.onePicW > this.onePicH ? 343 / 198 : 228 / 305)
1217 .width('100%') 1233 .width('100%')
1218 .constraintSize({ 1234 .constraintSize({
1219 - maxHeight: this.onePicW > this.onePicH ? 228 : 305 1235 + maxHeight: this.getPicHeight(this.onePicW,this.onePicH)
1220 }) 1236 })
1221 .autoResize(true) 1237 .autoResize(true)
1222 .borderRadius(this.caclImageRadius(index)) 1238 .borderRadius(this.caclImageRadius(index))
@@ -8,6 +8,7 @@ import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; @@ -8,6 +8,7 @@ import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
8 import { InfomationCardClick } from '../../utils/infomationCardClick' 8 import { InfomationCardClick } from '../../utils/infomationCardClick'
9 import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed'; 9 import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
10 import router from '@ohos.router' 10 import router from '@ohos.router'
  11 +import { DisplayUtils } from 'wdKit';
11 12
12 const TAG = 'Card19Component'; 13 const TAG = 'Card19Component';
13 14
@@ -137,6 +138,7 @@ struct createImg { @@ -137,6 +138,7 @@ struct createImg {
137 @Prop loadImg: boolean = true; 138 @Prop loadImg: boolean = true;
138 @State onePicW: number = 0; // 只有一张图时候图片的宽度 139 @State onePicW: number = 0; // 只有一张图时候图片的宽度
139 @State onePicH: number = 0; // 只有一张图时候图片的高度 140 @State onePicH: number = 0; // 只有一张图时候图片的高度
  141 + compWidth = (DisplayUtils.getDeviceWidth() - 32)
140 142
141 async aboutToAppear(): Promise<void> { 143 async aboutToAppear(): Promise<void> {
142 if (this.fullColumnImgUrls.length === 4) { // 为了使用栅格布局以便于占用三分之二的宽度,加一个占位 144 if (this.fullColumnImgUrls.length === 4) { // 为了使用栅格布局以便于占用三分之二的宽度,加一个占位
@@ -200,6 +202,21 @@ struct createImg { @@ -200,6 +202,21 @@ struct createImg {
200 } 202 }
201 } 203 }
202 204
  205 + getPicHeight(picWidth: number, picHeight: number) {
  206 + //console.info(`cj2024 getPicType picWidth = ${picWidth} picHeight = ${picHeight} picWidth / picHeight = ${picWidth / picHeight}`)
  207 + if (picWidth && picHeight) {
  208 + let imageH = 305
  209 + let sizeH = this.compWidth * picHeight / picWidth
  210 + if (sizeH > imageH) {
  211 + return sizeH
  212 + }else {
  213 + return imageH
  214 + }
  215 + } else {
  216 + return 305; //普通图
  217 + }
  218 + }
  219 +
203 @Builder 220 @Builder
204 longPicTip(weight: number, height: number) { 221 longPicTip(weight: number, height: number) {
205 if (weight / height > 2 || height / weight > 2){ 222 if (weight / height > 2 || height / weight > 2){
@@ -327,7 +344,7 @@ struct createImg { @@ -327,7 +344,7 @@ struct createImg {
327 // .aspectRatio(this.onePicW > this.onePicH ? 343 / 198 : 228 / 305) 344 // .aspectRatio(this.onePicW > this.onePicH ? 343 / 198 : 228 / 305)
328 .width('100%') 345 .width('100%')
329 .constraintSize({ 346 .constraintSize({
330 - maxHeight: this.onePicW > this.onePicH ? 228 : 305 347 + maxHeight: this.getPicHeight(this.onePicW,this.onePicH)
331 }) 348 })
332 .autoResize(true) 349 .autoResize(true)
333 .borderRadius(this.caclImageRadius(index)) 350 .borderRadius(this.caclImageRadius(index))