CompParser.ets
2.93 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
import { CommonConstants, CompStyle } from 'wdConstant';
import { CompDTO } from '../repository/bean/CompDTO';
import { BannerComponent } from './view/BannerComponent';
import { LabelComponent } from './view/LabelComponent';
import { TitleAbbrComponent } from './view/TitleAbbrComponent';
import { TitleAllComponent } from './view/TitleAllComponent';
import {
HorizontalStrokeCardThreeTwoRadioForOneComponent
} from './view/HorizontalStrokeCardThreeTwoRadioForOneComponent';
import {
HorizontalStrokeCardThreeTwoRadioForMoreComponent
} from './view/HorizontalStrokeCardThreeTwoRadioForMoreComponent';
import { BigPicCardComponent } from './view/BigPicCardComponent';
import { TriPicCardComponent } from './view/TriPicCardComponent';
import { HeadPictureCardComponent } from './view/HeadPictureCardComponent';
import { LiveHorizontalCardComponent } from './view/LiveHorizontalCardComponent';
import { SmallVideoCardComponent } from './view/SmallVideoCardComponent';
import { SmallVideoCardHorComponent } from './view/SmallVideoCardHorComponent';
/**
* comp适配器.
*/
@Component
export struct CompParser {
compDTO: CompDTO = {} as CompDTO;
compIndex: number = 0;
build() {
this.componentBuilder(this.compDTO, this.compIndex);
}
@Builder
componentBuilder(compDTO: CompDTO, compIndex: number) {
if (compDTO.compStyle === CompStyle.Label_03) {
LabelComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === '11') {
TitleAbbrComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === '3') {
TitleAllComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Zh_Carousel_Layout_01) {
BannerComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === "2") {
BigPicCardComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === "4") {
TriPicCardComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Row_01 && compDTO.imageScale === 2 ) {
LiveHorizontalCardComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Row_01 && compDTO.imageScale === 3 ) {
if(compDTO.operDataList.length > 1){
HorizontalStrokeCardThreeTwoRadioForMoreComponent({ compDTO: compDTO })
}else{
HorizontalStrokeCardThreeTwoRadioForOneComponent({ compDTO: compDTO })
}
} else if (compDTO.compStyle === CompStyle.Zh_Single_Column_02) {
HeadPictureCardComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Row_02) {
if (compDTO.operDataList.length > 1) {
SmallVideoCardHorComponent({ compDTO: compDTO })
} else {
SmallVideoCardComponent({ compDTO: compDTO })
}
}
else {
// todo:组件未实现 / Component Not Implemented
Text(compDTO.compStyle)
.width(CommonConstants.FULL_PARENT)
.padding(10)
// .backgroundColor(Color.Brown) // 展示本页未实现的compStyle
}
}
}