ActivityItemComponent.ets
4.33 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
/**
* 搜索活动 展示组件
*/
import { ContentDTO } from 'wdBean/Index';
import { ProcessUtils } from 'wdRouter/Index';
@Component
export struct ActivityItemComponent {
@State contentDTO: ContentDTO = new ContentDTO();
build() {
Row() {
Stack(){
Image(this.contentDTO.coverUrl)
.width('207lpx')
.height('276lpx')
.objectFit(ImageFit.Auto)
.borderRadius('7lpx')
Row(){
Image(this.contentDTO.programType+"" === "1" ? $r('app.media.activity_is_start_icon') :$r('app.media.activity_not_begin_icon'))
.width('42lpx')
.height('35lpx')
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.Medium)
Text(this.contentDTO.programType+"" === "1" ? "进行中" :"未开始")
.fontColor($r('app.color.white'))
.fontSize('21lpx')
.fontWeight('400lpx')
.lineHeight('31lpx')
.textAlign(TextAlign.Center)
}.margin({right:'19lpx',bottom:'13lpx'})
}.alignContent(Alignment.BottomEnd)
Column() {
Row(){
// Text(){
// // backgroundColor 不生效
// Span(this.contentDTO.objectType == "new_collect" ? "征稿" : this.contentDTO.objectType == "vote" ? "投票":"")
// .fontColor($r('app.color.main_red'))
// .fontSize('23lpx')
// .fontWeight('400lpx')
// .lineHeight('31lpx')
// .padding({left:'10lpx',right:'10lpx',top:'6lpx',bottom:'6lpx'})
// .backgroundColor( "#FF0"/*$r('app.color.color_ED2800')*/)
// .borderRadius('10lpx')
// .margin({ right: '10lpx' })
//
// Span(this.contentDTO.newsTitle)
// .fontColor($r('app.color.color_222222'))
// .fontSize('33lpx')
// .fontWeight('400lpx')
// .lineHeight('48lpx')
// }.textAlign(TextAlign.Start)
// .maxLines(2)
// .textOverflow({ overflow: TextOverflow.Ellipsis })
//TODO 这里的样式(objectType) 只写了两个,其他的需要扩展
Text(this.contentDTO.objectType == "new_collect" ? "征稿" : this.contentDTO.objectType == "vote" ? "投票":"")
.fontColor($r('app.color.white'))
.fontSize('23lpx')
.fontWeight('400lpx')
.lineHeight('31lpx')
.textAlign(TextAlign.Center)
.padding({left:'10lpx',right:'10lpx',top:'6lpx',bottom:'6lpx'})
.backgroundColor( $r('app.color.color_ED2800'))
.borderRadius('10lpx')
.margin({ right: '10lpx' })
Text(this.contentDTO.newsTitle)
.fontColor($r('app.color.color_222222'))
.fontSize('33lpx')
.fontWeight('400lpx')
.lineHeight('48lpx')
.textAlign(TextAlign.Start)
.maxLines(2)
.layoutWeight(1)
}
.margin({ bottom: '15lpx' })
.alignItems(VerticalAlign.Top)
.width('100%')
Row() {
Image($r('app.media.time_icon'))
.width('27lpx')
.height('27lpx')
.objectFit(ImageFit.Auto)
.margin({ right: '4lpx' })
.interpolation(ImageInterpolation.Medium)
Text("时间:" + this.contentDTO.startTime.split(" ")[0] + "~" + this.contentDTO.endTime.split(" ")[0])
.fontColor($r('app.color.color_999999'))
.fontSize('23lpx')
.fontWeight('400lpx')
.lineHeight('31lpx')
}
Blank()
Text(this.contentDTO.programType+"" === "1" ? "立即参与" : "立即查看")
.fontColor($r('app.color.white'))
.fontSize('23lpx')
.fontWeight('500lpx')
.lineHeight('38lpx')
.width('154lpx')
.height('54lpx')
.textAlign(TextAlign.Center)
.backgroundColor(this.contentDTO.programType+"" == "1" ? $r('app.color.color_ED2800') : $r('app.color.color_F07E47'))
.borderRadius('6lpx')
}.alignItems(HorizontalAlign.Start)
.width('428lpx')
.height('276lpx')
}.height('330lpx')
.justifyContent(FlexAlign.SpaceBetween)
.width('100%')
.padding({left:'31lpx',right:'31lpx'})
.onClick(()=>{
ProcessUtils._gotoDefaultWeb(this.contentDTO.linkUrl)
})
}
}