SingleColumn999Component.ets
6.13 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import { CompDTO, ContentDTO, VideoInfoDTO, } from 'wdBean';
import { BreakpointConstants } from 'wdConstant';
import { Logger } from 'wdKit';
import { PaperSingleColumn999CardView } from '../page/CardView';
import { EmptyComponent } from '../view/EmptyComponent';
const TAG = 'SingleColumn999Component';
/**
* 早晚报数据组件
*/
@Component
export struct SingleColumn999Component {
@StorageLink('currentBreakpoint') @Watch('watchCurrentBreakpoint') currentBreakpoint: string = BreakpointConstants.BREAKPOINT_XS;
@State compDTO: CompDTO = {
compStyle: 'compStyle3',
operDataList: [
{
newsTitle: '时政微观察丨从外贸“成绩单”看中国经济新亮色',
description: "description0",
coverUrl: 'https://cdnjdphoto.aikan.pdnews.cn/zhbj-20240116/image/content/a9028e7011bb440e94ba7c63d80b39b7.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg'
} as ContentDTO,
{
newsTitle: '画好强国建设、民族复兴的最大同心圆',
description: "description1",
coverUrl: "https://cdnjdphoto.aikan.pdnews.cn/sjbj-20240116/image/display/80351784d4da4fc08b8987ba45a7647f.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg",
} as ContentDTO,
{
newsTitle: '绿色“一带一路”十周年创新理念与实践案例',
description: "description2",
newsSummary: "共建“一带一路”倡议提出10年多来,在各方共同努力下,共建“一带一路”绿色发展取得积极进展,理念引领不断增强,交流机制不断完善,务实合作不断深化。",
coverUrl: "",
} as ContentDTO,
{
newsTitle: '瞭望 | 在深海聆听“幽灵粒子”',
description: "description3",
coverUrl: 'https://cdnjdphoto.aikan.pdnews.cn/zhbj-20240116/image/content/b77a3577594d4d24b84e7b2b20e38e41.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg'
} as ContentDTO,
{
newsTitle: '一图读懂|未来三年,长三角示范区安排了这些重大项目',
description: "description4",
coverUrl: "https://cdnjdphoto.aikan.pdnews.cn/zhbj-20240116/image/content/8d54ef1cbbe14ef08d6ab38f07867e4c.jpeg?x-oss-process=image/resize,w_550/quality,q_90/format,jpg",
} as ContentDTO,
{
newsTitle: '一头江豚的自述',
description: "description5",
newsSummary: "我是生活在长江里的一头江豚,是长江中唯一的水生哺乳动物,更是国家一级保护动物。但曾几何时,我和我的江中小伙伴出现了生存危机……直到有一天,我突然发现,打渔人变成护渔人,江水变清澈了,长江逐渐恢复了生机,我的家族数量上升到了1249头。当长江之水再一次悠悠流淌,我们相拥在清澈波光中起舞。长江,我的家园。",
coverUrl: "https://cdnjdphoto.aikan.pdnews.cn/sjbj-20240116/image/display/2ec7bccff2324b05ac4b6503d868a381.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg",
visitorComment: 10,
videoInfo: {
// clarity: 0,
// resolutionHeight: 0,
// resolutionWidth: 0,
videoDuration: "229",
videoLandScape: 1,
// videoType: 0,
videoUrl: "https://cdnjdout.aikan.pdnews.cn/zhbj-20240116/vod/content/output/c72f4170db2c4d34befa453f60d39a69_opt.mp4",
firstFrameImageUri: ""
} as VideoInfoDTO
} as ContentDTO,
{
newsTitle: '遇见习近平丨北京正在书写历史',
description: "description6",
coverUrl: "https://cdnjdphoto.aikan.pdnews.cn/zhbj-20240116/image/content/7c54d59b63844464a261dcbba82c7aed.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg",
} as ContentDTO
]
} as CompDTO
watchCurrentBreakpoint() {
Logger.info(TAG, `watchCurrentBreakpoint, this.currentBreakpoint: ${this.currentBreakpoint}`);
}
aboutToAppear() {
Logger.info(TAG, `aboutToAppear, beanList:${this.compDTO?.operDataList?.length}, currentBreakpoint:${this.currentBreakpoint}`);
}
aboutToDisappear() {
Logger.info(TAG, 'aboutToDisappear');
}
onPageShow() {
Logger.info(TAG, 'onPageShow');
}
onPageHide() {
Logger.info(TAG, 'onPageHide');
}
onBackPress() {
Logger.info(TAG, 'onBackPress');
}
@Builder
itemFooter(text: string) {
Text("已显示全部内容")
.width("100%")
.height(100)
.padding(9)
.fontColor(Color.White)
.fontSize($r('app.float.font_size_16'))
.fontWeight(FontWeight.Medium)
.textAlign(TextAlign.Center)
.align(Alignment.Bottom)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
build() {
if (this.compDTO && this.compDTO?.operDataList?.length > 0) {
List({ space: 2, initialIndex: 0 }) {
ListItemGroup({
// footer: this.itemFooter("")
}) {
ForEach(this.compDTO?.operDataList, (item: ContentDTO, index: number) => {
ListItem() {
this.buildPaperItem(item, index)
}
}, (item: ContentDTO, index: number) => JSON.stringify(item))
}
// .divider({ strokeWidth: 1, color: '#EFEFEF' }) // 每行之间的分界线
}
.width('100%')
.height("100%") // 必须设置height
// .margin({ left: $r('app.float.main_margin'), right: $r('app.float.main_margin') })
// .listDirection(Axis.Vertical) // 默认值:Axis.Vertical
// .lanes(this.buildLanes()) // 行/列数,一列 // 默认值:1
.cachedCount(2)
.sticky(StickyStyle.Header) // 吸顶
.scrollBar(BarState.Off)
.nestedScroll({
scrollForward: NestedScrollMode.PARENT_FIRST,
scrollBackward: NestedScrollMode.SELF_FIRST
})
} else {
EmptyComponent({ emptyHeight: 200 })
}
}
// public buildLanes(): number {
// return new BreakPointType({ xs: 1, sm: 1, md: 2, lg: 3 }).getValue(this.currentBreakpoint)
// }
/**
* 组件项
*
* @param programmeBean item 组件项
*/
@Builder
buildPaperItem(item: ContentDTO, index: number) {
PaperSingleColumn999CardView({
item: item,
index: index
})
}
}