Showing
8 changed files
with
152 additions
and
2 deletions
| 1 | +import router from '@ohos.router'; | ||
| 2 | +import common from '@ohos.app.ability.common'; | ||
| 1 | const TAG = 'PageComponent'; | 3 | const TAG = 'PageComponent'; |
| 2 | 4 | ||
| 3 | /** | 5 | /** |
| @@ -5,9 +7,146 @@ const TAG = 'PageComponent'; | @@ -5,9 +7,146 @@ const TAG = 'PageComponent'; | ||
| 5 | */ | 7 | */ |
| 6 | @Component | 8 | @Component |
| 7 | export struct MinePageComponent { | 9 | export struct MinePageComponent { |
| 8 | - // TODO 待完善 | 10 | + //是否是创作者 |
| 11 | + @State isActive:boolean = false | ||
| 12 | + @State isLogin:boolean = true | ||
| 13 | + | ||
| 14 | + private context = getContext(this) as common.UIAbilityContext | ||
| 15 | + | ||
| 16 | + aboutToAppear(){ | ||
| 17 | + // TODO 获取用户信息 | ||
| 18 | + } | ||
| 19 | + | ||
| 9 | build() { | 20 | build() { |
| 10 | - Text('我的页面') | 21 | + Column(){ |
| 22 | + Stack({alignContent:Alignment.Top}){ | ||
| 23 | + Image($r('app.media.mine_head_bg')) | ||
| 24 | + .setFullWidth() | ||
| 25 | + .height('50%') | ||
| 26 | + .objectFit(ImageFit.Auto) | ||
| 27 | + this.TopUI() | ||
| 28 | + }.setFullWidthAndHeight() | ||
| 29 | + .backgroundColor($r('app.color.color_F5F5F5')) | ||
| 30 | + }.setFullWidthAndHeight() | ||
| 31 | + | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + | ||
| 35 | + @Builder TopUI(){ | ||
| 36 | + Column(){ | ||
| 37 | + //头像层 | ||
| 38 | + this.HeaderUI() | ||
| 39 | + //Grid 区域 | ||
| 40 | + this.GridUI() | ||
| 41 | + //Card | ||
| 42 | + this.CardUI() | ||
| 43 | + //滑动区域 | ||
| 44 | + this.ScrollUI() | ||
| 45 | + } | ||
| 46 | + .padding({left:11,right:11}) | ||
| 47 | + .setFullWidthAndHeight() | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + @Builder HeaderUI(){ | ||
| 51 | + Row(){ | ||
| 52 | + //头像 | ||
| 53 | + Stack(){ | ||
| 54 | + Button({type:ButtonType.Circle}) | ||
| 55 | + .backgroundColor($r('app.color.white')) | ||
| 56 | + .width(74) | ||
| 57 | + .height(74) | ||
| 58 | + | ||
| 59 | + Image($r('app.media.mine_head_icon')) | ||
| 60 | + .width(70) | ||
| 61 | + .height(70) | ||
| 62 | + .objectFit(ImageFit.Cover) | ||
| 63 | + .borderRadius(50) | ||
| 64 | + }.width(74) | ||
| 65 | + .height(74) | ||
| 66 | + | ||
| 67 | + //昵称信息 | ||
| 68 | + Column(){ | ||
| 69 | + Row(){ | ||
| 70 | + Text("人民日报网友ABCDEF") | ||
| 71 | + .fontColor($r('app.color.white')) | ||
| 72 | + | ||
| 73 | + Image($r('app.media.mine_user_edit')) | ||
| 74 | + .width(20) | ||
| 75 | + .height(20) | ||
| 76 | + } | ||
| 77 | + Text("等级8") | ||
| 78 | + .textAlign(TextAlign.Center) | ||
| 79 | + .backgroundImage($r('app.media.mine_grade_bg')) | ||
| 80 | + .backgroundImageSize({width:55}) | ||
| 81 | + .fontColor($r('app.color.white')) | ||
| 82 | + .fontSize(12) | ||
| 83 | + .width(40) | ||
| 84 | + .margin({top:20}) | ||
| 85 | + }.alignItems(HorizontalAlign.Start) | ||
| 86 | + .width(200) | ||
| 87 | + .margin({left:10}) | ||
| 88 | + | ||
| 89 | + Blank() | ||
| 90 | + | ||
| 91 | + Stack({alignContent:Alignment.Start}){ | ||
| 92 | + Text("签到") | ||
| 93 | + .textAlign(TextAlign.Center) | ||
| 94 | + .borderRadius({ topLeft:10,bottomLeft:10}) | ||
| 95 | + .width(50) | ||
| 96 | + .fontColor($r('app.color.white')) | ||
| 97 | + .backgroundColor($r('app.color.color_FFC460')) | ||
| 98 | + .margin({left:20}) | ||
| 99 | + Image($r("app.media.mine_sign_icon")) | ||
| 100 | + .width(30) | ||
| 101 | + .height(30) | ||
| 102 | + }.width(60) | ||
| 103 | + | ||
| 104 | + } | ||
| 105 | + .setFullWidth() | ||
| 106 | + .margin({top:30}) | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + @Builder GridUI(){ | ||
| 110 | + Column(){ | ||
| 111 | + | ||
| 112 | + } | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + @Builder CardUI(){ | ||
| 116 | + Row(){ | ||
| 117 | + | ||
| 118 | + } | ||
| 11 | } | 119 | } |
| 120 | + | ||
| 121 | + @Builder ScrollUI(){ | ||
| 122 | + Column(){ | ||
| 123 | + Scroll(){ | ||
| 124 | + | ||
| 125 | + } | ||
| 126 | + } | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + @Styles setFullWidthAndHeight(){ | ||
| 130 | + .width('100%') | ||
| 131 | + .height('100%') | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + @Styles setFullWidth(){ | ||
| 135 | + .width('100%') | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + @Styles setFullHeight(){ | ||
| 139 | + .width('100%') | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + change(){ | ||
| 143 | + router.pushUrl({ | ||
| 144 | + url: 'pages/IndexPage', | ||
| 145 | + params: { | ||
| 146 | + } | ||
| 147 | + }).catch((error: Error) => { | ||
| 148 | + }); | ||
| 149 | + } | ||
| 150 | + | ||
| 12 | } | 151 | } |
| 13 | 152 |
| @@ -47,6 +47,14 @@ | @@ -47,6 +47,14 @@ | ||
| 47 | { | 47 | { |
| 48 | "name": "color_80000000", | 48 | "name": "color_80000000", |
| 49 | "value": "#80000000" | 49 | "value": "#80000000" |
| 50 | + }, | ||
| 51 | + { | ||
| 52 | + "name": "color_F5F5F5", | ||
| 53 | + "value": "#F5F5F5" | ||
| 54 | + }, | ||
| 55 | + { | ||
| 56 | + "name": "color_FFC460", | ||
| 57 | + "value": "#FFC460" | ||
| 50 | } | 58 | } |
| 51 | ] | 59 | ] |
| 52 | } | 60 | } |
661 Bytes
276 Bytes
| 1 | /** | 1 | /** |
| 2 | * 应用ability上下文管理类 | 2 | * 应用ability上下文管理类 |
| 3 | */ | 3 | */ |
| 4 | +import common from '@ohos.app.ability.common'; | ||
| 4 | export class AppContext { | 5 | export class AppContext { |
| 5 | private static sContext: Context; | 6 | private static sContext: Context; |
| 7 | + private context = getContext(this) as common.UIAbilityContext | ||
| 6 | 8 | ||
| 7 | public static init(abilityContext: Context) { | 9 | public static init(abilityContext: Context) { |
| 8 | this.sContext = abilityContext; | 10 | this.sContext = abilityContext; |
| @@ -11,4 +13,5 @@ export class AppContext { | @@ -11,4 +13,5 @@ export class AppContext { | ||
| 11 | public static getAbilityContext() { | 13 | public static getAbilityContext() { |
| 12 | return this.sContext; | 14 | return this.sContext; |
| 13 | } | 15 | } |
| 16 | + | ||
| 14 | } | 17 | } |
-
Please register or login to post a comment