wangliang_wd

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

... ... @@ -1045,6 +1045,7 @@ struct createImg {
@Prop loadImg: boolean = true;
@State onePicW: number = 0; // 只有一张图时候图片的宽度
@State onePicH: number = 0; // 只有一张图时候图片的高度
compWidth = (DisplayUtils.getDeviceWidth() - 32)
async aboutToAppear(): Promise<void> {
if (this.fullColumnImgUrls.length === 4) { // 为了使用栅格布局以便于占用三分之二的宽度,加一个占位
... ... @@ -1108,6 +1109,21 @@ struct createImg {
}
}
getPicHeight(picWidth: number, picHeight: number) {
//console.info(`cj2024 getPicType picWidth = ${picWidth} picHeight = ${picHeight} picWidth / picHeight = ${picWidth / picHeight}`)
if (picWidth && picHeight) {
let imageH = 305
let sizeH = this.compWidth * picHeight / picWidth
if (sizeH > imageH) {
return sizeH
}else {
return imageH
}
} else {
return 305; //普通图
}
}
@Builder
longPicTip(weight: number, height: number) {
if (weight / height > 2 || height / weight > 2){
... ... @@ -1216,7 +1232,7 @@ struct createImg {
// .aspectRatio(this.onePicW > this.onePicH ? 343 / 198 : 228 / 305)
.width('100%')
.constraintSize({
maxHeight: this.onePicW > this.onePicH ? 228 : 305
maxHeight: this.getPicHeight(this.onePicW,this.onePicH)
})
.autoResize(true)
.borderRadius(this.caclImageRadius(index))
... ...
... ... @@ -8,6 +8,7 @@ import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
import { InfomationCardClick } from '../../utils/infomationCardClick'
import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
import router from '@ohos.router'
import { DisplayUtils } from 'wdKit';
const TAG = 'Card19Component';
... ... @@ -137,6 +138,7 @@ struct createImg {
@Prop loadImg: boolean = true;
@State onePicW: number = 0; // 只有一张图时候图片的宽度
@State onePicH: number = 0; // 只有一张图时候图片的高度
compWidth = (DisplayUtils.getDeviceWidth() - 32)
async aboutToAppear(): Promise<void> {
if (this.fullColumnImgUrls.length === 4) { // 为了使用栅格布局以便于占用三分之二的宽度,加一个占位
... ... @@ -200,6 +202,21 @@ struct createImg {
}
}
getPicHeight(picWidth: number, picHeight: number) {
//console.info(`cj2024 getPicType picWidth = ${picWidth} picHeight = ${picHeight} picWidth / picHeight = ${picWidth / picHeight}`)
if (picWidth && picHeight) {
let imageH = 305
let sizeH = this.compWidth * picHeight / picWidth
if (sizeH > imageH) {
return sizeH
}else {
return imageH
}
} else {
return 305; //普通图
}
}
@Builder
longPicTip(weight: number, height: number) {
if (weight / height > 2 || height / weight > 2){
... ... @@ -327,7 +344,7 @@ struct createImg {
// .aspectRatio(this.onePicW > this.onePicH ? 343 / 198 : 228 / 305)
.width('100%')
.constraintSize({
maxHeight: this.onePicW > this.onePicH ? 228 : 305
maxHeight: this.getPicHeight(this.onePicW,this.onePicH)
})
.autoResize(true)
.borderRadius(this.caclImageRadius(index))
... ...