ZhSingleColumn04.ets
2.94 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { CompDTO, ContentDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant';
import { ProcessUtils } from '../../utils/ProcessUtils';
const TAG = 'Zh_Single_Column-04';
/**
* 人民号主题卡
* 枚举值 Zh_Single_Column-04
*/
@Entry
@Component
export struct ZhSingleColumn04 {
@State compDTO: CompDTO = {} as CompDTO
operDataList: ContentDTO[] = [
// {newsTitle: "民检普法课堂:正当防卫是什么正当防卫是什么正当防卫是什么正当防卫是什么?", tagWord: 1} as ContentDTO,
// {newsTitle: "审批站”进菜市场 学才艺有云课堂", tagWord: 2} as ContentDTO,
]
aboutToAppear() {
this.operDataList = this.compDTO.operDataList;
}
build() {
Column() {
Row() {
Image($r("app.media.redLine"))
.width(3)
.height(16)
.margin({ right: 4 })
Text(this.compDTO.objectTitle)
.fontSize($r("app.float.font_size_17"))
.fontColor($r("app.color.color_222222"))
.fontWeight(600)
}
.width(CommonConstants.FULL_WIDTH)
.margin({ bottom: 10 })
Column() {
ForEach(this.operDataList, (item: ContentDTO) => {
this.rmhThemeItem(item)
})
}
}
.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')
})
}
@Builder
rmhThemeItem(item: ContentDTO) {
Row() {
Image($r('app.media.rmh_theme_book_icon'))
.width(12)
.margin({ left: 12, right: 8 })
Text(item.newsTitle)
.fontSizeColorWeight($r('app.float.font_size_12'), $r('app.color.color_222222'), 400)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.layoutWeight(1)
if (item.tagWord === 1) {
Text('热')
.padding(3)
.borderRadius(4)
.fontSizeColorWeight($r('app.float.vp_12'), '#F07E46', 500)
.backgroundColor('rgba(240, 126, 70, 0.2)')
.margin({ right: 18 })
} else if (item.tagWord === 2) {
Text('新')
.padding(3)
.borderRadius(4)
.fontSizeColorWeight($r('app.float.vp_12'), '#468DF0', 500)
.backgroundColor('rgba(70, 141, 240, 0.2)')
.margin({ right: 18 })
}
}
.width(CommonConstants.FULL_WIDTH)
.height(32)
.margin({ bottom: 4 })
.backgroundImage($r('app.media.rmh_theme_bg'))
.backgroundImageSize({ width: CommonConstants.FULL_WIDTH, height: CommonConstants.FULL_WIDTH })
.onClick(() => {
ProcessUtils.processPage(item)
})
}
}
@Extend(Text)
function fontSizeColorWeight(fontSize: Resource, fontColor: Resource | string,
fontWeight:
number) {
.fontSize(fontSize)
.fontColor(fontColor)
.fontWeight(fontWeight)
}