MinePageComponent.ets
5.85 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
import router from '@ohos.router';
import common from '@ohos.app.ability.common';
import MineFunctionModel from '../../viewmodel/MineFunctionModel';
const TAG = 'PageComponent';
/**
* 我的页面
*/
@Component
export struct MinePageComponent {
//是否是创作者
@State isActive:boolean = false
@State isLogin:boolean = true
@State icons:MineFunctionModel[] = []
scroller: Scroller = new Scroller()
private context = getContext(this) as common.UIAbilityContext
aboutToAppear(){
// TODO 获取用户信息
//初始化 icon
this.initIconDatas()
}
/**
* 初始化 icon
*/
initIconDatas(){
this.icons.push(new MineFunctionModel("评论",$r('app.media.mine_comment_icon')))
this.icons.push(new MineFunctionModel("关注",$r('app.media.mine_order_icon')))
this.icons.push(new MineFunctionModel("收藏",$r('app.media.mine_collect_icon')))
this.icons.push(new MineFunctionModel("历史",$r('app.media.mine_history_icon')))
this.icons.push(new MineFunctionModel("消息",$r('app.media.mine_msg_icon')))
this.icons.push(new MineFunctionModel("留言板",$r('app.media.mine_msgboard_icon')))
this.icons.push(new MineFunctionModel("预约",$r('app.media.mine_order_icon')))
}
build() {
Column(){
Stack({alignContent:Alignment.Top}){
Image($r('app.media.mine_head_bg'))
.setFullWidth()
.height('50%')
.objectFit(ImageFit.Auto)
this.TopUI()
}.setFullWidthAndHeight()
.backgroundColor($r('app.color.color_F5F5F5'))
}.setFullWidthAndHeight()
}
@Builder TopUI(){
Column(){
//头像层
this.HeaderUI()
//Grid 区域
this.GridUI()
//Card
this.CardUI()
//滑动区域
this.ScrollUI()
}
.padding({left:11,right:11})
.setFullWidthAndHeight()
}
@Builder HeaderUI(){
Row(){
//头像
Stack(){
Button({type:ButtonType.Circle})
.backgroundColor($r('app.color.white'))
.width(74)
.height(74)
Image($r('app.media.mine_head_icon'))
.width(70)
.height(70)
.objectFit(ImageFit.Cover)
.borderRadius(50)
}.width(74)
.height(74)
//昵称信息
Column(){
Row(){
Text("人民日报网友ABCDEF")
.fontColor($r('app.color.white'))
Image($r('app.media.mine_user_edit'))
.width(20)
.height(20)
}
Text("等级8")
.textAlign(TextAlign.Center)
.backgroundImage($r('app.media.mine_grade_bg'))
.backgroundImageSize({width:55})
.fontColor($r('app.color.white'))
.fontSize(12)
.width(40)
.margin({top:20})
}.alignItems(HorizontalAlign.Start)
.width(200)
.margin({left:10})
Blank()
Stack({alignContent:Alignment.Start}){
Text("签到")
.textAlign(TextAlign.Center)
.borderRadius({ topLeft:10,bottomLeft:10})
.width(50)
.fontColor($r('app.color.white'))
.backgroundColor($r('app.color.color_FFC460'))
.margin({left:20})
Image($r("app.media.mine_sign_icon"))
.width(30)
.height(30)
}.width(60)
}
.setFullWidth()
.margin({top:30})
}
@Builder GridUI(){
Column(){
Grid(){
ForEach(this.icons,(item:MineFunctionModel,index:number)=>{
GridItem(){
Row(){
Column(){
Image(item.imgSrc)
.width(30)
.height(30)
Text(`${item.msg}`)
.margin({top:2})
.fontColor($r('app.color.white'))
}
.alignItems(HorizontalAlign.Center)
.width('100%')
Blank()
.layoutWeight(1)
if(index % 4 < 3 && index != this.icons.length){
Text().backgroundColor($r('app.color.white'))
.width(2)
.height(15)
}
}
}.onClick(()=>{
console.log(index+"")
})
}, item => item)
}
.rowsTemplate('1fr 1fr')
.columnsTemplate('1fr 1fr 1fr 1fr')
// .columnsGap(10)
.height(140)
.margin({top:15 })
}
}
@Builder CardUI(){
Row(){
Stack(){
Image($r('app.media.mine_card_01'))
.width(170)
.objectFit(ImageFit.Auto)
Column(){
Text("积分商城")
.fontColor($r('app.color.color_FF2E0C'))
.width(120)
Text("华为MATE40手机")
.width(120)
.fontColor($r('app.color.color_FF2E0C'))
.fontSize(14)
.margin({top:3})
}.padding({left:20})
}.alignContent(Alignment.Start)
Stack(){
Image($r('app.media.mine_card_02'))
.width(170)
.objectFit(ImageFit.Auto)
Column(){
Text("数字藏品").fontColor($r('app.color.color_AD6000'))
.width(120)
Text("黑胶唱片NFT").width(120)
.fontColor($r('app.color.color_AD6000'))
.fontSize(14)
.margin({top:3})
}.padding({left:30})
}.alignContent(Alignment.Start)
}.width('100%')
.height(70)
}
@Builder ScrollUI(){
Scroll(this.scroller){
Column(){
}.height(600)
.setFullWidth()
.backgroundColor($r('app.color.white'))
}.setFullWidth()
.layoutWeight(1)
.scrollable(ScrollDirection.Vertical)
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None)
}
@Styles setFullWidthAndHeight(){
.width('100%')
.height('100%')
}
@Styles setFullWidth(){
.width('100%')
}
@Styles setFullHeight(){
.width('100%')
}
change(){
router.pushUrl({
url: 'pages/IndexPage',
params: {
}
}).catch((error: Error) => {
});
}
}