yangchenggong1_wd

desc:个人中心 UI 界面绘制

1 import router from '@ohos.router'; 1 import router from '@ohos.router';
2 import common from '@ohos.app.ability.common'; 2 import common from '@ohos.app.ability.common';
  3 +import MineFunctionModel from '../../viewmodel/MineFunctionModel';
3 const TAG = 'PageComponent'; 4 const TAG = 'PageComponent';
4 5
5 /** 6 /**
@@ -10,13 +11,31 @@ export struct MinePageComponent { @@ -10,13 +11,31 @@ export struct MinePageComponent {
10 //是否是创作者 11 //是否是创作者
11 @State isActive:boolean = false 12 @State isActive:boolean = false
12 @State isLogin:boolean = true 13 @State isLogin:boolean = true
  14 + @State icons:MineFunctionModel[] = []
  15 + scroller: Scroller = new Scroller()
13 16
14 private context = getContext(this) as common.UIAbilityContext 17 private context = getContext(this) as common.UIAbilityContext
15 18
16 aboutToAppear(){ 19 aboutToAppear(){
17 // TODO 获取用户信息 20 // TODO 获取用户信息
  21 + //初始化 icon
  22 + this.initIconDatas()
18 } 23 }
19 24
  25 + /**
  26 + * 初始化 icon
  27 + */
  28 + initIconDatas(){
  29 + this.icons.push(new MineFunctionModel("评论",$r('app.media.mine_comment_icon')))
  30 + this.icons.push(new MineFunctionModel("关注",$r('app.media.mine_order_icon')))
  31 + this.icons.push(new MineFunctionModel("收藏",$r('app.media.mine_collect_icon')))
  32 + this.icons.push(new MineFunctionModel("历史",$r('app.media.mine_history_icon')))
  33 + this.icons.push(new MineFunctionModel("消息",$r('app.media.mine_msg_icon')))
  34 + this.icons.push(new MineFunctionModel("留言板",$r('app.media.mine_msgboard_icon')))
  35 + this.icons.push(new MineFunctionModel("预约",$r('app.media.mine_order_icon')))
  36 + }
  37 +
  38 +
20 build() { 39 build() {
21 Column(){ 40 Column(){
22 Stack({alignContent:Alignment.Top}){ 41 Stack({alignContent:Alignment.Top}){
@@ -108,22 +127,88 @@ export struct MinePageComponent { @@ -108,22 +127,88 @@ export struct MinePageComponent {
108 127
109 @Builder GridUI(){ 128 @Builder GridUI(){
110 Column(){ 129 Column(){
  130 + Grid(){
  131 + ForEach(this.icons,(item:MineFunctionModel,index:number)=>{
  132 + GridItem(){
  133 + Row(){
  134 + Column(){
  135 + Image(item.imgSrc)
  136 + .width(30)
  137 + .height(30)
111 138
  139 + Text(`${item.msg}`)
  140 + .margin({top:2})
  141 + .fontColor($r('app.color.white'))
  142 + }
  143 + .alignItems(HorizontalAlign.Center)
  144 + .width('100%')
  145 + Blank()
  146 + .layoutWeight(1)
  147 + if(index % 4 < 3 && index != this.icons.length){
  148 + Text().backgroundColor($r('app.color.white'))
  149 + .width(2)
  150 + .height(15)
  151 + }
  152 + }
  153 + }.onClick(()=>{
  154 + console.log(index+"")
  155 + })
  156 + }, item => item)
  157 + }
  158 + .rowsTemplate('1fr 1fr')
  159 + .columnsTemplate('1fr 1fr 1fr 1fr')
  160 + // .columnsGap(10)
  161 + .height(140)
  162 + .margin({top:15 })
112 } 163 }
113 } 164 }
114 165
115 @Builder CardUI(){ 166 @Builder CardUI(){
116 Row(){ 167 Row(){
117 -  
118 - } 168 + Stack(){
  169 + Image($r('app.media.mine_card_01'))
  170 + .width(170)
  171 + .objectFit(ImageFit.Auto)
  172 + Column(){
  173 + Text("积分商城")
  174 + .fontColor($r('app.color.color_FF2E0C'))
  175 + .width(120)
  176 + Text("华为MATE40手机")
  177 + .width(120)
  178 + .fontColor($r('app.color.color_FF2E0C'))
  179 + .fontSize(14)
  180 + .margin({top:3})
  181 + }.padding({left:20})
  182 + }.alignContent(Alignment.Start)
  183 + Stack(){
  184 + Image($r('app.media.mine_card_02'))
  185 + .width(170)
  186 + .objectFit(ImageFit.Auto)
  187 + Column(){
  188 + Text("数字藏品").fontColor($r('app.color.color_AD6000'))
  189 + .width(120)
  190 + Text("黑胶唱片NFT").width(120)
  191 + .fontColor($r('app.color.color_AD6000'))
  192 + .fontSize(14)
  193 + .margin({top:3})
  194 + }.padding({left:30})
  195 + }.alignContent(Alignment.Start)
  196 + }.width('100%')
  197 + .height(70)
119 } 198 }
120 199
121 @Builder ScrollUI(){ 200 @Builder ScrollUI(){
  201 + Scroll(this.scroller){
122 Column(){ 202 Column(){
123 - Scroll(){  
124 203
125 - }  
126 - } 204 + }.height(600)
  205 + .setFullWidth()
  206 + .backgroundColor($r('app.color.white'))
  207 + }.setFullWidth()
  208 + .layoutWeight(1)
  209 + .scrollable(ScrollDirection.Vertical)
  210 + .scrollBar(BarState.Off)
  211 + .edgeEffect(EdgeEffect.None)
127 } 212 }
128 213
129 @Styles setFullWidthAndHeight(){ 214 @Styles setFullWidthAndHeight(){
  1 +
  2 +
  3 +export default class MineFunctionModel {
  4 + imgSrc:Resource
  5 + msg:string
  6 +
  7 + constructor(msg:string,imgSrc:Resource){
  8 + this.msg = msg
  9 + this.imgSrc = imgSrc
  10 + }
  11 +
  12 +}
@@ -55,6 +55,14 @@ @@ -55,6 +55,14 @@
55 { 55 {
56 "name": "color_FFC460", 56 "name": "color_FFC460",
57 "value": "#FFC460" 57 "value": "#FFC460"
  58 + },
  59 + {
  60 + "name": "color_FF2E0C",
  61 + "value": "#FF2E0C"
  62 + },
  63 + {
  64 + "name": "color_AD6000",
  65 + "value": "#AD6000"
58 } 66 }
59 ] 67 ]
60 } 68 }