陈剑华

Merge remote-tracking branch 'origin/main'

@@ -7,8 +7,7 @@ import { Card2Component } from './cardview/Card2Component'; @@ -7,8 +7,7 @@ import { Card2Component } from './cardview/Card2Component';
7 import { Card5Component } from './cardview/Card5Component'; 7 import { Card5Component } from './cardview/Card5Component';
8 import { AdvCardParser } from './cardViewAdv/AdvCardParser'; 8 import { AdvCardParser } from './cardViewAdv/AdvCardParser';
9 import { ZhCarouselLayout01 } from './compview/ZhCarouselLayout01'; 9 import { ZhCarouselLayout01 } from './compview/ZhCarouselLayout01';
10 -import { ZhGridLayout02 } from './compview/ZhGridLayout02';  
11 -import { ZhGridLayout02News } from './compview/ZhGridLayout02News'; 10 +import { CompNormalTitle } from './compview/CompNormalTitle';
12 import { ZhGridLayout02NewsContent } from './compview/ZhGridLayout02NewsContent'; 11 import { ZhGridLayout02NewsContent } from './compview/ZhGridLayout02NewsContent';
13 import { ZhGridLayout03 } from './compview/ZhGridLayout03'; 12 import { ZhGridLayout03 } from './compview/ZhGridLayout03';
14 import { ZhSingleColumn04 } from './compview/ZhSingleColumn04'; 13 import { ZhSingleColumn04 } from './compview/ZhSingleColumn04';
@@ -77,11 +76,11 @@ export struct CompParser { @@ -77,11 +76,11 @@ export struct CompParser {
77 Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 }) 76 Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
78 } else if (this.compDTO.compStyle === CompStyle.Zh_Grid_Layout_02) { //双列流小视频,一行两图卡 ->标题 77 } else if (this.compDTO.compStyle === CompStyle.Zh_Grid_Layout_02) { //双列流小视频,一行两图卡 ->标题
79 //ZhGridLayout02({ compDTO: this.compDTO }) 78 //ZhGridLayout02({ compDTO: this.compDTO })
80 - ZhGridLayout02News({ compDTO: this.compDTO }) 79 + CompNormalTitle({ compDTO: this.compDTO })
81 // Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 }) 80 // Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
82 } else if (this.compDTO.compStyle === CompStyle.Card_Comp_Zh_Grid_Layout_02) { //双列流小视频,一行两图卡 81 } else if (this.compDTO.compStyle === CompStyle.Card_Comp_Zh_Grid_Layout_02) { //双列流小视频,一行两图卡
83 82
84 - ZhGridLayout02NewsContent({ compDTO: this.compDTO,operDataList:this.compDTO.operDataList }) 83 + ZhGridLayout02NewsContent({ compDTO: this.compDTO, operDataList: this.compDTO.operDataList })
85 84
86 } else if (this.compDTO.compStyle === CompStyle.Zh_Grid_Layout_03) { 85 } else if (this.compDTO.compStyle === CompStyle.Zh_Grid_Layout_03) {
87 ZhGridLayout03({ compDTO: this.compDTO }) 86 ZhGridLayout03({ compDTO: this.compDTO })
@@ -7,11 +7,11 @@ import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; @@ -7,11 +7,11 @@ import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
7 7
8 8
9 /** 9 /**
10 - * 标题组件 10 + * 通用标题组件
11 * 11 *
12 */ 12 */
13 @Component 13 @Component
14 -export struct ZhGridLayout02News { 14 +export struct CompNormalTitle {
15 @State compDTO: CompDTO = new CompDTO 15 @State compDTO: CompDTO = new CompDTO
16 16
17 aboutToAppear() { 17 aboutToAppear() {
1 -import { CompDTO, ContentDTO, LiveRoomDataBean } from 'wdBean';  
2 -import { CommonConstants } from 'wdConstant/Index';  
3 -import { Logger } from 'wdKit/Index';  
4 -import { ProcessUtils } from 'wdRouter';  
5 -import PageViewModel from '../../viewmodel/PageViewModel';  
6 -import { onlyWifiLoadImg } from '../../utils/lazyloadImg';  
7 -  
8 -const TAG = 'Zh_Grid_Layout-02';  
9 -const FULL_PARENT: string = '100%';  
10 -let listSize: number = 2;  
11 -  
12 -/**  
13 - * 双图卡  
14 - * 枚举值Zh_Grid_Layout-02  
15 - * Zh_Grid_Layout-02  
16 - *  
17 - */  
18 -@Component  
19 -export struct ZhGridLayout02 {  
20 - @State compDTO: CompDTO = {} as CompDTO  
21 - @State operDataList: ContentDTO[] = []  
22 - @State loadImg: boolean = false;  
23 - @State liveRoomList: LiveRoomDataBean[] = []  
24 - currentPage = 1  
25 - pageSize = 12  
26 -  
27 - async aboutToAppear(): Promise<void> {  
28 - Logger.debug(TAG, 'aboutToAppear ' + this.compDTO.objectTitle)  
29 - this.currentPage = 1  
30 - PageViewModel.getLiveReviewUrl(this.currentPage, this.pageSize).then((liveReviewDTO) => {  
31 - this.operDataList = []  
32 - this.operDataList.push(...liveReviewDTO.list)  
33 - this.getLiveRoomDataInfo(this.operDataList)  
34 - })  
35 -  
36 - this.loadImg = await onlyWifiLoadImg();  
37 - }  
38 -  
39 - build() {  
40 - Column() {  
41 - Scroll() {  
42 - Column() {  
43 - Row() {  
44 - Image($r("app.media.redLine"))  
45 - .width(3)  
46 - .height(16)  
47 - .margin({ right: 4 })  
48 - Text(this.compDTO.objectTitle)  
49 - .fontSize($r("app.float.font_size_17"))  
50 - .fontColor($r("app.color.color_222222"))  
51 - .fontWeight(600)  
52 - }  
53 - .justifyContent(FlexAlign.Start)  
54 - .margin({ top: 16, bottom: 8 })  
55 - .width(CommonConstants.FULL_WIDTH)  
56 -  
57 - GridRow({  
58 - gutter: { x: 12, y: 13 },  
59 - columns: { sm: listSize, md: 2 },  
60 - breakpoints: { value: ['320vp', '520vp', '840vp'] }  
61 - }) {  
62 - ForEach(this.operDataList, (item: ContentDTO, index: number) => {  
63 - GridCol() {  
64 - this.buildItemCard(item);  
65 - }  
66 - })  
67 - }  
68 - }  
69 - }  
70 - .width("100%")  
71 - .height("100%")  
72 - // .layoutWeight(1)  
73 - .edgeEffect(EdgeEffect.None)  
74 - .scrollBar(BarState.Off)  
75 - .onReachStart(() => {  
76 - Logger.debug(TAG, 'onReachStart')  
77 - })  
78 - .onReachEnd(() => {  
79 - Logger.debug(TAG, 'onReachEnd')  
80 - this.addItems()  
81 - })  
82 - .nestedScroll({  
83 - scrollForward: NestedScrollMode.PARENT_FIRST,  
84 - scrollBackward: NestedScrollMode.SELF_FIRST  
85 - })  
86 - }  
87 - .width(CommonConstants.FULL_WIDTH)  
88 - // .width("100%")  
89 - .height("100%")  
90 - .padding({ left: 16, right: 16 })  
91 -  
92 - // .layoutWeight(1)  
93 -  
94 - }  
95 -  
96 - /**  
97 - * 组件项  
98 - *  
99 - * @param programmeBean item 组件项, 上面icon,下面标题  
100 - */  
101 - @Builder  
102 - buildItemCard(item: ContentDTO) {  
103 - Column() {  
104 - Stack({ alignContent: Alignment.BottomEnd }) {  
105 - Image(this.loadImg ? item.fullColumnImgUrls[0].url : '')  
106 - .backgroundColor(0xf5f5f5)  
107 - .width('100%')  
108 - .height(95)  
109 - .borderRadius(4)  
110 - if (this.getLiveRoomNumber(item).length > 0) {  
111 - Text(this.getLiveRoomNumber(item))  
112 - .fontSize('11vp')  
113 - .fontWeight(400)  
114 - .fontColor(Color.White)  
115 - .margin({  
116 - right: '5vp',  
117 - bottom: '5vp'  
118 - })  
119 - }  
120 - }  
121 -  
122 - Text(item.newsTitle)  
123 - .margin({top:'6'})  
124 - .fontSize(13)  
125 - .maxLines(2)  
126 - .textOverflow({ overflow: TextOverflow.Ellipsis })  
127 - }  
128 - .width('100%')  
129 - .onClick(() => {  
130 - ProcessUtils.processPage(item)  
131 - })  
132 - }  
133 -  
134 - // 获取评论数  
135 - async getLiveRoomDataInfo(list: ContentDTO[]) {  
136 - const reserveIds = this.getLiveDetailIds(list)  
137 - PageViewModel.getLiveRoomBatchInfo(reserveIds).then((result) => {  
138 - if (result && result.length > 0) {  
139 - this.liveRoomList.push(...result)  
140 - }  
141 - }).catch(() => {  
142 - })  
143 - }  
144 -  
145 - // 判断是否预约  
146 - getLiveRoomNumber(item: ContentDTO): string {  
147 - const objc = this.liveRoomList.find((element: LiveRoomDataBean) => {  
148 - return element.liveId.toString() == item.objectId  
149 - })  
150 - if (objc && objc.pv && objc.pv > 0) {  
151 - return this.computeShowNum(objc.pv)  
152 - }  
153 - return ''  
154 - }  
155 -  
156 - addItems() {  
157 - Logger.debug(TAG, 'addItems')  
158 - this.currentPage++  
159 - PageViewModel.getLiveReviewUrl(this.currentPage, this.pageSize).then((liveReviewDTO) => {  
160 - this.operDataList.push(...liveReviewDTO.list)  
161 - this.getLiveRoomDataInfo(this.operDataList)  
162 - Logger.debug(TAG, 'addItems after: ' + this.operDataList.length)  
163 - })  
164 - }  
165 -  
166 - private getLiveDetailIds(list: ContentDTO[]): string {  
167 - let idList: string[] = []  
168 - list.forEach(item => {  
169 - idList.push(item.objectId)  
170 - });  
171 - return idList.join(',')  
172 - }  
173 -  
174 - private computeShowNum(count: number): string {  
175 - if (count >= 10000) {  
176 - let num = (count / 10000).toFixed(1)  
177 - if (Number(num.substring(num.length - 1)) == 0) {  
178 - num = num.substring(0, num.length - 2)  
179 - }  
180 - return num + '万人参加'  
181 - }  
182 - return `${count}人参加`  
183 - }  
184 -}  
185 -  
186 -