CardAdvLongImageComponent.ets
2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//全标题 "appStyle":"2",
import { CompDTO } from 'wdBean';
import { CommonConstants, CompStyle } from 'wdConstant/Index';
import { ProcessUtils } from 'wdRouter';
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
import PageModel from '../../viewmodel/PageModel';
import { CardAdvBottom } from './CardAdvBottom';
const TAG: string = 'Card2Component';
/**
* @Description: 广告---长通栏广告 和 顶部长通栏广告
* @Author:
* @Email: liyubing@wondertek.com.cn
* @CreateDate:
* @UpdateRemark: 更新说明
* @Version: 1.0
*/
@Component
export struct CardAdvLongImageComponent {
@State compDTO: CompDTO = {} as CompDTO
@State haveTitle: boolean = true
pageModel: PageModel = new PageModel();
@State loadImg: boolean = false;
async aboutToAppear(): Promise<void> {
this.loadImg = await onlyWifiLoadImg();
this.haveTitle = this.compDTO.matInfo.advSubType === CompStyle.Card_Adv_7;
}
aboutToDisappear(): void {
}
build() {
Column() {
//新闻标题
if (this.haveTitle) {
Text(this.compDTO.matInfo.advTitle).width('100%').bottomTextStyle().margin({ bottom: 8, })
}
//长图
Image(this.loadImg ? this.compDTO.matInfo.matImageUrl[0] : '')
.backgroundColor(this.loadImg ? $r('app.color.color_B0B0B0') : 0xf5f5f5)
.width(CommonConstants.FULL_WIDTH)
.aspectRatio(343 / 96)
.borderRadius(4)
.borderWidth(0.5)
.borderColor($r('app.color.color_0D000000'))
CardAdvBottom({ pageModel: this.pageModel, compDTO:this.compDTO }).margin({
top: 8,
})
}
.width(CommonConstants.FULL_WIDTH)
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
top: $r('app.float.card_comp_pagePadding_tb'),
bottom: $r('app.float.card_comp_pagePadding_tb')
})
.onClick((event: ClickEvent) => {
ProcessUtils.openAdvDetail(this.compDTO.matInfo)
})
}
}
/*
标题样式
*/
@Extend(Text)
function bottomTextStyle() {
.fontSize('18fp')
.fontColor($r('app.color.color_222222'))
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
.align(Alignment.Start)
.lineHeight(25)
}