MorningEveningPaperComponent.ets
9.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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
import router from '@ohos.router'
import { FrontLinkObject, MorningEveningPaperDTO } from 'wdBean'
// import { Logger } from 'wdKit';
// import PageViewModel from '../viewmodel/PageViewModel';
// import { PageComponent } from './page/PageComponent';
const TAG = 'MorningEveningPaperComponent';
@Entry
@Component
export struct MorningEveningPaperComponent {
@State currentTopNavSelectedIndex: number = 0;
paperPageId: string = '21549'
@State groupId: string = ''
@State message: string = 'Hello World'
@State morningEveningPaperDTO: MorningEveningPaperDTO = {
name: "新闻夜读",
topicInfo: {
frontLinkObject: {
coverSize: "599*798",
coverUrl: "https://cdnjdphoto.aikan.pdnews.cn/zhbj-20240116/image/content/9a91a96077174087852cf93c5e26acce.jpeg",
newsId: "30002086032",
newsRelId: 500000256225,
summary: "欧尔班多次明确反对欧盟此举。2023年底,匈牙利否决了欧盟对乌克兰的500亿欧元援助计划,认为欧盟不应向乌克兰提供更多资金,而应尽快结束俄乌冲突。因此,欧盟领导人在去年12月欧盟峰会上未能就该计划达成一致。欧尔班多次明确反对欧盟此举。2023年底,匈牙利否决了欧盟对乌克兰的500亿欧元援助计划,认为欧盟不应向乌克兰提供更多资金,而应尽快结束俄乌冲突。因此,欧盟领导人在去年12月欧盟峰会上未能就该计",
title: "匈牙利总理欧尔班妥协,阻碍欧盟向乌克兰援助的最后一个障碍被解"
},
title: "新闻夜读",
topicDate: "2024-01-16",
topicId: "10000002068",
}
} as MorningEveningPaperDTO
// @State morningEveningPaperDTO: MorningEveningPaperDTO = {} as MorningEveningPaperDTO
async aboutToAppear() {
console.info(TAG, `aboutToAppear`);
// let paperDTO = await PageViewModel.getMorningEveningPaperData(this.paperPageId)
// if (paperDTO) {
// this.morningEveningPaperDTO = paperDTO;
// if (paperDTO.groups && paperDTO.groups.length > 0) {
// this.groupId = paperDTO.groups[0].id + ''
// }
// Logger.info(TAG, `aboutToAppear, paperDTO is not empty`);
// }
}
build() {
Column() {
RelativeContainer() {
Image($r('app.media.icon_read_paper'))
.height($r('app.float.top_arrow_size'))
.width($r('app.float.top_arrow_size'))
.alignRules({
left: { anchor: "__container__", align: HorizontalAlign.Start },
center: { anchor: "__container__", align: VerticalAlign.Center }
})
.id('img_logo1')
Row() {
Text(this.morningEveningPaperDTO?.topicInfo?.title ?? "")
.fontSize(20)
.fontColor($r('app.color.white'))
.maxLines(1)
Text(this.morningEveningPaperDTO?.topicInfo?.topicDate ?? '')// Text('2024年\n1月16日')
.width(50)
.fontSize(12)
.fontColor($r('app.color.white'))
.maxLines(2)
Image($r('app.media.bg_event_status_end'))
.height($r('app.float.top_arrow_size'))
.width(100)
}
.alignItems(VerticalAlign.Bottom)
.alignRules({
left: { anchor: "img_logo1", align: HorizontalAlign.End },
center: { anchor: "__container__", align: VerticalAlign.Center } })
.id('row_paper_date')
Image($r('app.media.icon_close'))
.height($r('app.float.top_arrow_size'))
.width($r('app.float.top_arrow_size'))
.alignRules({
right: { anchor: "__container__", align: HorizontalAlign.End },
center: { anchor: "__container__", align: VerticalAlign.Center } })
.id('img_close')
.onClick((event: ClickEvent) => {
console.info(TAG, "img_close")
router.back()
})
Image($r('app.media.icon_share'))
.height($r('app.float.top_arrow_size'))
.width($r('app.float.top_arrow_size'))
.alignRules({
right: { anchor: "img_close", align: HorizontalAlign.Start },
center: { anchor: "__container__", align: VerticalAlign.Center } })
.id('img_share')
}
.margin({ left: $r('app.float.margin_16'), right: $r('app.float.margin_16') })
.height($r('app.float.top_bar_height'))
.backgroundColor(Color.Black)
List() {
ListItem() {
this.buildTopicInfoView(this.morningEveningPaperDTO?.topicInfo?.frontLinkObject)
}
ListItem() {
Row() {
Stack({ alignContent: Alignment.Start }) {
Image($r('app.media.listen_left_bg'))
.width('100%')
.height('100%')
.objectFit(ImageFit.Contain)
Image($r('app.media.icon_listen'))
.width(24)
.height(24)
.margin({ left: 10 })
.alignSelf(ItemAlign.Start)
Text('晚上好, 请收听今日新闻播报')
.fontSize(14)
.margin({ left: 50 })
.fontColor(Color.Black)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
.layoutWeight(1)
.height('100%')
Stack({ alignContent: Alignment.Center }) {
Image($r('app.media.listen_right_bg'))
.width('100%')
.height('100%')
.objectFit(ImageFit.Contain)
Image($r('app.media.ic_red_triangle'))
.width(24)
.height(24)
.margin({ left: 10 })// .alignSelf(ItemAlign.Center)
.objectFit(ImageFit.Contain)
}
// .aspectRatio(7 / 4)
.height('100%')
// .justifyContent(FlexAlign.Center)
// .width(94)
// .width(140)
.width('20%')
// .height(56)
.onClick(() => {
console.info(TAG, `onClick listen_right_bg`);
})
}
// .width('100%')
.height(56)
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.SpaceBetween)
// .backgroundColor(Color.Red)
}
ListItem() {
// PageComponent({
// currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
// navIndex: 0,
// pageId: '31320', //this.groupId,
// channelId: ''
// })
}.height(500)
}
// .backgroundColor('#FFF1F3F5')
// .backgroundColor(Color.Blue)
.margin({ left: 14, right: 14 })
// .alignListItem(ListItemAlign.Center)
}.width('100%')
// Row() {
// Column() {
// Text(this.message)
// .fontSize(50)
// .fontWeight(FontWeight.Bold)
// }
// .width('100%')
// }
// .height('100%')
}
/**
* 布局描述
*
* @param FrontLinkObject item 组件项
* @param index
*/
@Builder
buildTopicInfoView(item: FrontLinkObject) {
RelativeContainer() {
Image(item?.coverUrl)
.width("100%")
.height("100%")
.alignRules({
top: { anchor: '__container__', align: VerticalAlign.Top },
left: { anchor: '__container__', align: HorizontalAlign.Start }
})
.id('img_cover')
Row() {
Text("查看详情")
.fontSize(20)
.fontColor($r('app.color.white'))
.maxLines(1)
Image($r('app.media.more'))
.height($r('app.float.top_arrow_size'))
.width(20)
}
.margin({ top: 10 })
// .backgroundColor(Color.Red)
.alignRules({
left: { anchor: "__container__", align: HorizontalAlign.Start },
bottom: { anchor: "__container__", align: VerticalAlign.Bottom }
})
.id('row_detail')
Text(item?.summary ?? "")
.margin({ top: 10 })
.fontSize(14)
.fontColor($r('app.color.white'))
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.alignRules({
left: { anchor: "__container__", align: HorizontalAlign.Start },
bottom: { anchor: "row_detail", align: VerticalAlign.Top }
})
.id('txt_summary')
Text(item?.title ?? "")
.fontSize(24)
.fontColor($r('app.color.white'))
.maxLines(2)
.alignRules({
left: { anchor: "__container__", align: HorizontalAlign.Start },
bottom: { anchor: "txt_summary", align: VerticalAlign.Top }
})
.id('txt_title')
}
.width("100%")
.aspectRatio(3 / 4)
// .aspectRatio(1)
// .backgroundColor(Color.Orange)
// .hoverEffect(HoverEffect.Scale)
.onClick((event: ClickEvent) => {
console.info(TAG, `buildTopicInfoView onClick event`);
// let taskAction: Action = {
// type: 'JUMP_H5_BY_WEB_VIEW',
// params: {
// url: ConfigConstants.DETAIL_URL
// } as Params,
// };
// WDRouterRule.jumpWithAction(taskAction)
// let taskAction: Action = {
// type: 'JUMP_DETAIL_PAGE',
// params: {
// detailPageType: 7, // 沉浸式竖屏详情页
// contentID: '863556812'
// } as Params,
// };
// WDRouterRule.jumpWithAction(taskAction)
})
}
}