Showing
2 changed files
with
385 additions
and
349 deletions
| 1 | import router from '@ohos.router' | 1 | import router from '@ohos.router' |
| 2 | -import { StringUtils } from 'wdKit'; | 2 | +import { NetworkUtil, StringUtils } from 'wdKit'; |
| 3 | import { WDRouterPage, WDRouterRule } from 'wdRouter'; | 3 | import { WDRouterPage, WDRouterRule } from 'wdRouter'; |
| 4 | import { editModelParams } from '../model/EditInfoModel'; | 4 | import { editModelParams } from '../model/EditInfoModel'; |
| 5 | import { HomePageBottomCommentComponent } from '../components/mine/home/HomePageBottomCommentComponent'; | 5 | import { HomePageBottomCommentComponent } from '../components/mine/home/HomePageBottomCommentComponent'; |
| 6 | import { HomePageBottomFollowComponent } from '../components/mine/home/HomePageBottomFollowComponent'; | 6 | import { HomePageBottomFollowComponent } from '../components/mine/home/HomePageBottomFollowComponent'; |
| 7 | import MinePageDatasModel from '../model/MinePageDatasModel'; | 7 | import MinePageDatasModel from '../model/MinePageDatasModel'; |
| 8 | +import { EmptyComponent } from '../components/view/EmptyComponent'; | ||
| 9 | +import { CustomTitleUI } from '../components/reusable/CustomTitleUI'; | ||
| 8 | 10 | ||
| 9 | const TAG = "MineHomePage" | 11 | const TAG = "MineHomePage" |
| 10 | 12 | ||
| @@ -33,6 +35,7 @@ struct MineHomePage { | @@ -33,6 +35,7 @@ struct MineHomePage { | ||
| 33 | scroller: Scroller = new Scroller(); | 35 | scroller: Scroller = new Scroller(); |
| 34 | @State params:Record<string, string> = router.getParams() as Record<string, string>; | 36 | @State params:Record<string, string> = router.getParams() as Record<string, string>; |
| 35 | @State isCommentEnter:string = ""; | 37 | @State isCommentEnter:string = ""; |
| 38 | + @State isConnectNetwork : boolean = NetworkUtil.isNetConnected() | ||
| 36 | 39 | ||
| 37 | onPageShow(): void { | 40 | onPageShow(): void { |
| 38 | this.getUserInfo() | 41 | this.getUserInfo() |
| @@ -47,56 +50,57 @@ struct MineHomePage { | @@ -47,56 +50,57 @@ struct MineHomePage { | ||
| 47 | } | 50 | } |
| 48 | 51 | ||
| 49 | build() { | 52 | build() { |
| 50 | - Stack({ alignContent: Alignment.Top }){ | ||
| 51 | - Image($r('app.media.title_bg')) | ||
| 52 | - .width('100%') | ||
| 53 | - .height('355lpx') | ||
| 54 | - .objectFit(ImageFit.Cover) | ||
| 55 | - | ||
| 56 | - Column(){ | ||
| 57 | - Stack({ alignContent: Alignment.Top }){ | ||
| 58 | - this.MineHomeTitleTransparent() | ||
| 59 | - this.MineHomeTitleWhite() | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - Scroll(this.scroller) { | ||
| 63 | - Column() { | ||
| 64 | - //用户信息区域 | ||
| 65 | - Row() { | ||
| 66 | - Stack(){ | ||
| 67 | - Image(this.headPhotoUrl) | ||
| 68 | - .alt($r('app.media.default_head')) | ||
| 69 | - .width('115lpx') | ||
| 70 | - .height('115lpx') | ||
| 71 | - .objectFit(ImageFit.Auto) | ||
| 72 | - .clip(new Circle({ width: '115lpx', height: '115lpx' })) | ||
| 73 | - Image(this.levelHead) | ||
| 74 | - .width('165lpx') | ||
| 75 | - .height('165lpx') | ||
| 76 | - .objectFit(ImageFit.Auto) | ||
| 77 | - }.onClick(()=>{ | ||
| 78 | - let params = {'headPhotoUrl': this.headPhotoUrl} as Record<string, string>; | ||
| 79 | - WDRouterRule.jumpWithPage(WDRouterPage.showUserHeaderPage,params) | ||
| 80 | - }).width('165lpx') | ||
| 81 | - .height('165lpx') | 53 | + if(this.isConnectNetwork){ |
| 54 | + Stack({ alignContent: Alignment.Top }){ | ||
| 55 | + Image($r('app.media.title_bg')) | ||
| 56 | + .width('100%') | ||
| 57 | + .height('355lpx') | ||
| 58 | + .objectFit(ImageFit.Cover) | ||
| 59 | + | ||
| 60 | + Column(){ | ||
| 61 | + Stack({ alignContent: Alignment.Top }){ | ||
| 62 | + this.MineHomeTitleTransparent() | ||
| 63 | + this.MineHomeTitleWhite() | ||
| 64 | + } | ||
| 82 | 65 | ||
| 83 | - Column() { | ||
| 84 | - Row() { | ||
| 85 | - Text(`${this.userName}`) | ||
| 86 | - .fontColor($r('app.color.white')) | ||
| 87 | - .maxLines(1) | ||
| 88 | - .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 89 | - .fontSize('38lpx') | ||
| 90 | - .lineHeight('50lpx') | ||
| 91 | - .fontWeight('500lpx') | ||
| 92 | - .onClick(()=>{ | ||
| 93 | - let params: editModelParams = { | ||
| 94 | - editContent: this.userName | ||
| 95 | - } | ||
| 96 | - WDRouterRule.jumpWithPage(WDRouterPage.editUserNikeNamePage,params) | ||
| 97 | - }) | 66 | + Scroll(this.scroller) { |
| 67 | + Column() { | ||
| 68 | + //用户信息区域 | ||
| 69 | + Row() { | ||
| 70 | + Stack(){ | ||
| 71 | + Image(this.headPhotoUrl) | ||
| 72 | + .alt($r('app.media.default_head')) | ||
| 73 | + .width('115lpx') | ||
| 74 | + .height('115lpx') | ||
| 75 | + .objectFit(ImageFit.Auto) | ||
| 76 | + .clip(new Circle({ width: '115lpx', height: '115lpx' })) | ||
| 77 | + Image(this.levelHead) | ||
| 78 | + .width('165lpx') | ||
| 79 | + .height('165lpx') | ||
| 80 | + .objectFit(ImageFit.Auto) | ||
| 81 | + }.onClick(()=>{ | ||
| 82 | + let params = {'headPhotoUrl': this.headPhotoUrl} as Record<string, string>; | ||
| 83 | + WDRouterRule.jumpWithPage(WDRouterPage.showUserHeaderPage,params) | ||
| 84 | + }).width('165lpx') | ||
| 85 | + .height('165lpx') | ||
| 98 | 86 | ||
| 99 | - if(this.levelId>0){ | 87 | + Column() { |
| 88 | + Row() { | ||
| 89 | + Text(`${this.userName}`) | ||
| 90 | + .fontColor($r('app.color.white')) | ||
| 91 | + .maxLines(1) | ||
| 92 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 93 | + .fontSize('38lpx') | ||
| 94 | + .lineHeight('50lpx') | ||
| 95 | + .fontWeight('500lpx') | ||
| 96 | + .onClick(()=>{ | ||
| 97 | + let params: editModelParams = { | ||
| 98 | + editContent: this.userName | ||
| 99 | + } | ||
| 100 | + WDRouterRule.jumpWithPage(WDRouterPage.editUserNikeNamePage,params) | ||
| 101 | + }) | ||
| 102 | + | ||
| 103 | + if(this.levelId>0){ | ||
| 100 | Text(`等级${this.levelId}`) | 104 | Text(`等级${this.levelId}`) |
| 101 | .fontColor($r('app.color.color_ED2800')) | 105 | .fontColor($r('app.color.color_ED2800')) |
| 102 | .fontSize('23lpx') | 106 | .fontSize('23lpx') |
| @@ -106,161 +110,175 @@ struct MineHomePage { | @@ -106,161 +110,175 @@ struct MineHomePage { | ||
| 106 | .backgroundImageSize(ImageSize.Cover) | 110 | .backgroundImageSize(ImageSize.Cover) |
| 107 | .padding({left:"17lpx",right:"8lpx"}) | 111 | .padding({left:"17lpx",right:"8lpx"}) |
| 108 | .height('35lpx') | 112 | .height('35lpx') |
| 113 | + } | ||
| 114 | + | ||
| 115 | + Blank() | ||
| 116 | + }.width('507lpx') | ||
| 117 | + | ||
| 118 | + Row() { | ||
| 119 | + Row() { | ||
| 120 | + Text(`${this.browseNum}`) | ||
| 121 | + .textStyle() | ||
| 122 | + Text("阅读") | ||
| 123 | + .textStyle2() | ||
| 124 | + } | ||
| 125 | + .margin({ right: '15lpx' }) | ||
| 126 | + | ||
| 127 | + Divider() | ||
| 128 | + .height('19lpx') | ||
| 129 | + .width('2lpx') | ||
| 130 | + .color($r('app.color.white')) | ||
| 131 | + .vertical(true) | ||
| 132 | + .opacity(0.4) | ||
| 133 | + Row() { | ||
| 134 | + Text(`${this.commentNum}`) | ||
| 135 | + .textStyle() | ||
| 136 | + Text("评论") | ||
| 137 | + .textStyle2() | ||
| 138 | + }.margin({ right: '15lpx', left: '15lpx' }) | ||
| 139 | + | ||
| 140 | + Divider() | ||
| 141 | + .height('19lpx') | ||
| 142 | + .width('2lpx') | ||
| 143 | + .color($r('app.color.white')) | ||
| 144 | + .vertical(true) | ||
| 145 | + .opacity(0.4) | ||
| 146 | + Row() { | ||
| 147 | + Text(`${this.attentionNum}`) | ||
| 148 | + .textStyle() | ||
| 149 | + Text("关注") | ||
| 150 | + .textStyle2() | ||
| 151 | + }.margin({ left: '15lpx' }) | ||
| 152 | + }.margin({ top: '23lpx' }) | ||
| 153 | + }.alignItems(HorizontalAlign.Start) | ||
| 154 | + .margin({ left: StringUtils.isEmpty(this.levelHead)?'32lpx':"3lpx" }) | ||
| 155 | + } | ||
| 156 | + .onAreaChange((oldValue: Area, newValue: Area) => { | ||
| 157 | + if (this.firstPositionY === 0) { | ||
| 158 | + this.firstPositionY = newValue.globalPosition.y as number | ||
| 159 | + }else{ | ||
| 160 | + let persent = (this.firstPositionY - Number(newValue.globalPosition.y)) / (this.firstPositionY * 0.3) | ||
| 161 | + if(persent > 1){ | ||
| 162 | + persent = 1 | ||
| 109 | } | 163 | } |
| 164 | + this.tileOpacity = persent | ||
| 165 | + } | ||
| 166 | + }) | ||
| 167 | + .backgroundColor($r('app.color.color_transparent')) | ||
| 168 | + .height('184lpx') | ||
| 169 | + .width('100%') | ||
| 170 | + .padding({ left: '6lpx' }) | ||
| 110 | 171 | ||
| 111 | - Blank() | ||
| 112 | - }.width('507lpx') | ||
| 113 | 172 | ||
| 173 | + //用户简介区域 | ||
| 174 | + Column() { | ||
| 114 | Row() { | 175 | Row() { |
| 115 | - Row() { | ||
| 116 | - Text(`${this.browseNum}`) | ||
| 117 | - .textStyle() | ||
| 118 | - Text("阅读") | ||
| 119 | - .textStyle2() | 176 | + Text(this.isHasIntroduction?"简介:"+this.desc:this.desc) |
| 177 | + .fontSize('27lpx') | ||
| 178 | + .maxLines(3) | ||
| 179 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 180 | + .lineHeight('40lpx') | ||
| 181 | + .fontWeight('400lpx') | ||
| 182 | + .fontColor(this.isHasIntroduction?$r('app.color.color_222222'):$r('app.color.color_999999')) | ||
| 183 | + .textAlign(TextAlign.Start) | ||
| 184 | + .onClick(()=>{ | ||
| 185 | + let params: editModelParams = { | ||
| 186 | + editContent: this.isHasIntroduction?this.desc:'' | ||
| 187 | + } | ||
| 188 | + WDRouterRule.jumpWithPage(WDRouterPage.editUserIntroductionPage,params) | ||
| 189 | + }) | ||
| 190 | + if(!this.isHasIntroduction){ | ||
| 191 | + Image($r('app.media.user_info_edit_icon')) | ||
| 192 | + .width('27lpx') | ||
| 193 | + .height('27lpx') | ||
| 194 | + .interpolation(ImageInterpolation.High) | ||
| 195 | + .objectFit(ImageFit.Auto) | ||
| 120 | } | 196 | } |
| 121 | - .margin({ right: '15lpx' }) | ||
| 122 | - | ||
| 123 | - Divider() | ||
| 124 | - .height('19lpx') | ||
| 125 | - .width('2lpx') | ||
| 126 | - .color($r('app.color.white')) | ||
| 127 | - .vertical(true) | ||
| 128 | - .opacity(0.4) | ||
| 129 | - Row() { | ||
| 130 | - Text(`${this.commentNum}`) | ||
| 131 | - .textStyle() | ||
| 132 | - Text("评论") | ||
| 133 | - .textStyle2() | ||
| 134 | - }.margin({ right: '15lpx', left: '15lpx' }) | ||
| 135 | - | ||
| 136 | - Divider() | ||
| 137 | - .height('19lpx') | ||
| 138 | - .width('2lpx') | ||
| 139 | - .color($r('app.color.white')) | ||
| 140 | - .vertical(true) | ||
| 141 | - .opacity(0.4) | ||
| 142 | - Row() { | ||
| 143 | - Text(`${this.attentionNum}`) | ||
| 144 | - .textStyle() | ||
| 145 | - Text("关注") | ||
| 146 | - .textStyle2() | ||
| 147 | - }.margin({ left: '15lpx' }) | ||
| 148 | - }.margin({ top: '23lpx' }) | ||
| 149 | - }.alignItems(HorizontalAlign.Start) | ||
| 150 | - .margin({ left: StringUtils.isEmpty(this.levelHead)?'32lpx':"3lpx" }) | ||
| 151 | - } | ||
| 152 | - .onAreaChange((oldValue: Area, newValue: Area) => { | ||
| 153 | - if (this.firstPositionY === 0) { | ||
| 154 | - this.firstPositionY = newValue.globalPosition.y as number | ||
| 155 | - }else{ | ||
| 156 | - let persent = (this.firstPositionY - Number(newValue.globalPosition.y)) / (this.firstPositionY * 0.3) | ||
| 157 | - if(persent > 1){ | ||
| 158 | - persent = 1 | ||
| 159 | } | 197 | } |
| 160 | - this.tileOpacity = persent | ||
| 161 | - } | ||
| 162 | - }) | ||
| 163 | - .backgroundColor($r('app.color.color_transparent')) | ||
| 164 | - .height('184lpx') | ||
| 165 | - .width('100%') | ||
| 166 | - .padding({ left: '6lpx' }) | ||
| 167 | 198 | ||
| 168 | 199 | ||
| 169 | - //用户简介区域 | ||
| 170 | - Column() { | ||
| 171 | - Row() { | ||
| 172 | - Text(this.isHasIntroduction?"简介:"+this.desc:this.desc) | ||
| 173 | - .fontSize('27lpx') | ||
| 174 | - .maxLines(3) | ||
| 175 | - .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 176 | - .lineHeight('40lpx') | 200 | + Text(`来到人民日报${this.registerTimeForDay}天`) |
| 201 | + .fontSize('23lpx') | ||
| 202 | + .lineHeight('25lpx') | ||
| 177 | .fontWeight('400lpx') | 203 | .fontWeight('400lpx') |
| 178 | - .fontColor(this.isHasIntroduction?$r('app.color.color_222222'):$r('app.color.color_999999')) | 204 | + .fontColor($r('app.color.color_999999')) |
| 179 | .textAlign(TextAlign.Start) | 205 | .textAlign(TextAlign.Start) |
| 180 | - .onClick(()=>{ | ||
| 181 | - let params: editModelParams = { | ||
| 182 | - editContent: this.isHasIntroduction?this.desc:'' | ||
| 183 | - } | ||
| 184 | - WDRouterRule.jumpWithPage(WDRouterPage.editUserIntroductionPage,params) | ||
| 185 | - }) | ||
| 186 | - if(!this.isHasIntroduction){ | ||
| 187 | - Image($r('app.media.user_info_edit_icon')) | ||
| 188 | - .width('27lpx') | ||
| 189 | - .height('27lpx') | ||
| 190 | - .interpolation(ImageInterpolation.High) | ||
| 191 | - .objectFit(ImageFit.Auto) | ||
| 192 | - } | ||
| 193 | - } | 206 | + .margin({ top: '15lpx' }) |
| 194 | 207 | ||
| 195 | - | ||
| 196 | - Text(`来到人民日报${this.registerTimeForDay}天`) | ||
| 197 | - .fontSize('23lpx') | ||
| 198 | - .lineHeight('25lpx') | ||
| 199 | - .fontWeight('400lpx') | ||
| 200 | - .fontColor($r('app.color.color_999999')) | ||
| 201 | - .textAlign(TextAlign.Start) | ||
| 202 | - .margin({ top: '15lpx' }) | ||
| 203 | - | ||
| 204 | - }.padding({ left: '31lpx',right:'31lpx',top:'19lpx',bottom:'31lpx'}) | ||
| 205 | - .alignItems(HorizontalAlign.Start) | ||
| 206 | - .justifyContent(FlexAlign.Center) | ||
| 207 | - .width('100%') | ||
| 208 | - .backgroundColor($r('app.color.white')) | ||
| 209 | - //间隔符 | ||
| 210 | - | ||
| 211 | - Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx') | ||
| 212 | - | ||
| 213 | - //tab 页面 | ||
| 214 | - Stack({ alignContent: Alignment.Top }){ | ||
| 215 | - Tabs({controller: this.controller}) { | ||
| 216 | - TabContent() { | ||
| 217 | - HomePageBottomCommentComponent({commentNum:$commentNum}) | ||
| 218 | - } | ||
| 219 | - TabContent() { | ||
| 220 | - HomePageBottomFollowComponent() | ||
| 221 | - } | ||
| 222 | - } | 208 | + }.padding({ left: '31lpx',right:'31lpx',top:'19lpx',bottom:'31lpx'}) |
| 209 | + .alignItems(HorizontalAlign.Start) | ||
| 210 | + .justifyContent(FlexAlign.Center) | ||
| 211 | + .width('100%') | ||
| 223 | .backgroundColor($r('app.color.white')) | 212 | .backgroundColor($r('app.color.white')) |
| 224 | - .animationDuration(0) | ||
| 225 | - .onChange((index: number) => { | ||
| 226 | - this.currentIndex = index | ||
| 227 | - }) | ||
| 228 | - .vertical(false) | ||
| 229 | - .barHeight("77lpx") | 213 | + //间隔符 |
| 230 | 214 | ||
| 231 | - Column() { | ||
| 232 | - // 页签 | ||
| 233 | - Row({ space: 7 }) { | ||
| 234 | - Scroll() { | ||
| 235 | - Row() { | ||
| 236 | - this.TabBuilder(0,"评论") | ||
| 237 | - this.TabBuilder(1,"关注") | 215 | + Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx') |
| 216 | + | ||
| 217 | + //tab 页面 | ||
| 218 | + Stack({ alignContent: Alignment.Top }){ | ||
| 219 | + Tabs({controller: this.controller}) { | ||
| 220 | + TabContent() { | ||
| 221 | + HomePageBottomCommentComponent({commentNum:$commentNum}) | ||
| 222 | + } | ||
| 223 | + TabContent() { | ||
| 224 | + HomePageBottomFollowComponent() | ||
| 225 | + } | ||
| 226 | + } | ||
| 227 | + .backgroundColor($r('app.color.white')) | ||
| 228 | + .animationDuration(0) | ||
| 229 | + .onChange((index: number) => { | ||
| 230 | + this.currentIndex = index | ||
| 231 | + }) | ||
| 232 | + .vertical(false) | ||
| 233 | + .barHeight("77lpx") | ||
| 234 | + | ||
| 235 | + Column() { | ||
| 236 | + // 页签 | ||
| 237 | + Row({ space: 7 }) { | ||
| 238 | + Scroll() { | ||
| 239 | + Row() { | ||
| 240 | + this.TabBuilder(0,"评论") | ||
| 241 | + this.TabBuilder(1,"关注") | ||
| 242 | + } | ||
| 243 | + .justifyContent(FlexAlign.Start) | ||
| 238 | } | 244 | } |
| 239 | - .justifyContent(FlexAlign.Start) | 245 | + .align(Alignment.Start) |
| 246 | + .scrollable(ScrollDirection.Horizontal) | ||
| 247 | + .scrollBar(BarState.Off) | ||
| 248 | + .width('100%') | ||
| 249 | + .padding({left:'31lpx'}) | ||
| 240 | } | 250 | } |
| 241 | - .align(Alignment.Start) | ||
| 242 | - .scrollable(ScrollDirection.Horizontal) | ||
| 243 | - .scrollBar(BarState.Off) | 251 | + .alignItems(VerticalAlign.Bottom) |
| 244 | .width('100%') | 252 | .width('100%') |
| 245 | - .padding({left:'31lpx'}) | ||
| 246 | } | 253 | } |
| 247 | - .alignItems(VerticalAlign.Bottom) | 254 | + .backgroundColor($r('app.color.white')) |
| 255 | + .alignItems(HorizontalAlign.Start) | ||
| 248 | .width('100%') | 256 | .width('100%') |
| 257 | + .height('77lpx') | ||
| 249 | } | 258 | } |
| 250 | - .backgroundColor($r('app.color.white')) | ||
| 251 | - .alignItems(HorizontalAlign.Start) | ||
| 252 | - .width('100%') | ||
| 253 | - .height('77lpx') | ||
| 254 | - } | ||
| 255 | - }.width("100%") | 259 | + }.width("100%") |
| 260 | + } | ||
| 261 | + .edgeEffect(EdgeEffect.None) | ||
| 262 | + .scrollBar(BarState.Off) | ||
| 263 | + .width('100%') | ||
| 264 | + .layoutWeight(1) | ||
| 256 | } | 265 | } |
| 257 | - .edgeEffect(EdgeEffect.None) | ||
| 258 | - .scrollBar(BarState.Off) | ||
| 259 | - .width('100%') | ||
| 260 | - .layoutWeight(1) | 266 | + }.width('100%') |
| 267 | + .layoutWeight(1) | ||
| 268 | + }else{ | ||
| 269 | + Column(){ | ||
| 270 | + CustomTitleUI({ titleName: "" }) | ||
| 271 | + | ||
| 272 | + EmptyComponent({ emptyType: 1,emptyHeight:"100%" ,retry: () => { | ||
| 273 | + this.isConnectNetwork = NetworkUtil.isNetConnected() | ||
| 274 | + if(this.isConnectNetwork){ | ||
| 275 | + this.getUserInfo() | ||
| 276 | + } | ||
| 277 | + },}) | ||
| 278 | + .layoutWeight(1) | ||
| 279 | + .width('100%') | ||
| 261 | } | 280 | } |
| 262 | - }.width('100%') | ||
| 263 | - .layoutWeight(1) | 281 | + } |
| 264 | 282 | ||
| 265 | } | 283 | } |
| 266 | @Builder MineHomeTitleTransparent() { | 284 | @Builder MineHomeTitleTransparent() { |
| 1 | import router from '@ohos.router' | 1 | import router from '@ohos.router' |
| 2 | import { Params } from 'wdBean'; | 2 | import { Params } from 'wdBean'; |
| 3 | -import { StringUtils } from 'wdKit'; | 3 | +import { NetworkUtil, StringUtils } from 'wdKit'; |
| 4 | import { OtherHomePageBottomCommentComponent } from '../components/mine/home/OtherHomePageBottomCommentComponent'; | 4 | import { OtherHomePageBottomCommentComponent } from '../components/mine/home/OtherHomePageBottomCommentComponent'; |
| 5 | import { OtherHomePageBottomFollowComponent } from '../components/mine/home/OtherHomePageBottomFollowComponent'; | 5 | import { OtherHomePageBottomFollowComponent } from '../components/mine/home/OtherHomePageBottomFollowComponent'; |
| 6 | +import { CustomTitleUI } from '../components/reusable/CustomTitleUI'; | ||
| 7 | +import { EmptyComponent } from '../components/view/EmptyComponent'; | ||
| 6 | import MinePageDatasModel from '../model/MinePageDatasModel'; | 8 | import MinePageDatasModel from '../model/MinePageDatasModel'; |
| 7 | import { OtherUserDetailRequestItem } from '../viewmodel/OtherUserDetailRequestItem'; | 9 | import { OtherUserDetailRequestItem } from '../viewmodel/OtherUserDetailRequestItem'; |
| 8 | 10 | ||
| @@ -39,6 +41,7 @@ struct OtherNormalUserHomePage { | @@ -39,6 +41,7 @@ struct OtherNormalUserHomePage { | ||
| 39 | @State attentionNum:number = 0//关注数 | 41 | @State attentionNum:number = 0//关注数 |
| 40 | @State desc:string = "" | 42 | @State desc:string = "" |
| 41 | userType:string = "1" | 43 | userType:string = "1" |
| 44 | + @State isConnectNetwork : boolean = NetworkUtil.isNetConnected() | ||
| 42 | 45 | ||
| 43 | aboutToAppear(){ | 46 | aboutToAppear(){ |
| 44 | this.getUserInfo() | 47 | this.getUserInfo() |
| @@ -47,187 +50,202 @@ struct OtherNormalUserHomePage { | @@ -47,187 +50,202 @@ struct OtherNormalUserHomePage { | ||
| 47 | 50 | ||
| 48 | 51 | ||
| 49 | build() { | 52 | build() { |
| 50 | - Stack({ alignContent: Alignment.Top }){ | ||
| 51 | - Image($r('app.media.title_bg')) | ||
| 52 | - .width('100%') | ||
| 53 | - .height('355lpx') | ||
| 54 | - .objectFit(ImageFit.Cover) | 53 | + if(this.isConnectNetwork){ |
| 54 | + Stack({ alignContent: Alignment.Top }){ | ||
| 55 | + Image($r('app.media.title_bg')) | ||
| 56 | + .width('100%') | ||
| 57 | + .height('355lpx') | ||
| 58 | + .objectFit(ImageFit.Cover) | ||
| 59 | + | ||
| 60 | + Column(){ | ||
| 61 | + Stack({ alignContent: Alignment.Top }){ | ||
| 62 | + this.MineHomeTitleTransparent() | ||
| 63 | + this.MineHomeTitleWhite() | ||
| 64 | + } | ||
| 55 | 65 | ||
| 56 | - Column(){ | ||
| 57 | - Stack({ alignContent: Alignment.Top }){ | ||
| 58 | - this.MineHomeTitleTransparent() | ||
| 59 | - this.MineHomeTitleWhite() | ||
| 60 | - } | 66 | + Scroll() { |
| 67 | + Column() { | ||
| 68 | + //用户信息区域 | ||
| 69 | + Row() { | ||
| 70 | + Stack(){ | ||
| 71 | + Image(this.headPhotoUrl) | ||
| 72 | + .alt($r('app.media.default_head')) | ||
| 73 | + .width('115lpx') | ||
| 74 | + .height('115lpx') | ||
| 75 | + .objectFit(ImageFit.Cover) | ||
| 76 | + .clip(new Circle({ width: '115lpx', height: '115lpx' })) | ||
| 77 | + Image(this.levelHead) | ||
| 78 | + .width('165lpx') | ||
| 79 | + .height('165lpx') | ||
| 80 | + .objectFit(ImageFit.Cover) | ||
| 81 | + } | ||
| 61 | 82 | ||
| 62 | - Scroll() { | ||
| 63 | - Column() { | ||
| 64 | - //用户信息区域 | ||
| 65 | - Row() { | ||
| 66 | - Stack(){ | ||
| 67 | - Image(this.headPhotoUrl) | ||
| 68 | - .alt($r('app.media.default_head')) | ||
| 69 | - .width('115lpx') | ||
| 70 | - .height('115lpx') | ||
| 71 | - .objectFit(ImageFit.Cover) | ||
| 72 | - .clip(new Circle({ width: '115lpx', height: '115lpx' })) | ||
| 73 | - Image(this.levelHead) | ||
| 74 | - .width('165lpx') | ||
| 75 | - .height('165lpx') | ||
| 76 | - .objectFit(ImageFit.Cover) | ||
| 77 | - } | 83 | + Column() { |
| 84 | + Row() { | ||
| 85 | + Text(`${this.userName}`) | ||
| 86 | + .fontColor($r('app.color.white')) | ||
| 87 | + .maxLines(1) | ||
| 88 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 89 | + .fontSize('38lpx') | ||
| 90 | + .lineHeight('50lpx') | ||
| 91 | + .fontWeight('500lpx') | ||
| 92 | + | ||
| 93 | + if(this.levelId>0){ | ||
| 94 | + Text(`等级${this.levelId}`) | ||
| 95 | + .fontColor($r('app.color.color_ED2800')) | ||
| 96 | + .fontSize('23lpx') | ||
| 97 | + .fontWeight(500) | ||
| 98 | + .margin({ left: '10lpx' }) | ||
| 99 | + .backgroundImage($r("app.media.my_grade_bg")) | ||
| 100 | + .backgroundImageSize(ImageSize.Cover) | ||
| 101 | + .padding({left:"17lpx",right:"8lpx"}) | ||
| 102 | + .height('35lpx') | ||
| 103 | + } | ||
| 104 | + Blank() | ||
| 105 | + }.width('507lpx') | ||
| 78 | 106 | ||
| 79 | - Column() { | ||
| 80 | - Row() { | ||
| 81 | - Text(`${this.userName}`) | ||
| 82 | - .fontColor($r('app.color.white')) | ||
| 83 | - .maxLines(1) | ||
| 84 | - .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 85 | - .fontSize('38lpx') | ||
| 86 | - .lineHeight('50lpx') | ||
| 87 | - .fontWeight('500lpx') | ||
| 88 | - | ||
| 89 | - if(this.levelId>0){ | ||
| 90 | - Text(`等级${this.levelId}`) | ||
| 91 | - .fontColor($r('app.color.color_ED2800')) | ||
| 92 | - .fontSize('23lpx') | ||
| 93 | - .fontWeight(500) | ||
| 94 | - .margin({ left: '10lpx' }) | ||
| 95 | - .backgroundImage($r("app.media.my_grade_bg")) | ||
| 96 | - .backgroundImageSize(ImageSize.Cover) | ||
| 97 | - .padding({left:"17lpx",right:"8lpx"}) | ||
| 98 | - .height('35lpx') | 107 | + Row() { |
| 108 | + Row() { | ||
| 109 | + Text(`${this.browseNum}`) | ||
| 110 | + .textStyle() | ||
| 111 | + Text("阅读") | ||
| 112 | + .textStyle2() | ||
| 113 | + } | ||
| 114 | + .margin({ right: '15lpx' }) | ||
| 115 | + | ||
| 116 | + Divider() | ||
| 117 | + .height('19lpx') | ||
| 118 | + .width('2lpx') | ||
| 119 | + .color($r('app.color.white')) | ||
| 120 | + .vertical(true) | ||
| 121 | + .opacity(0.4) | ||
| 122 | + Row() { | ||
| 123 | + Text(`${this.commentNum}`) | ||
| 124 | + .textStyle() | ||
| 125 | + Text("评论") | ||
| 126 | + .textStyle2() | ||
| 127 | + }.margin({ right: '15lpx', left: '15lpx' }) | ||
| 128 | + | ||
| 129 | + Divider() | ||
| 130 | + .height('19lpx') | ||
| 131 | + .width('2lpx') | ||
| 132 | + .color($r('app.color.white')) | ||
| 133 | + .vertical(true) | ||
| 134 | + .opacity(0.4) | ||
| 135 | + Row() { | ||
| 136 | + Text(`${this.attentionNum}`) | ||
| 137 | + .textStyle() | ||
| 138 | + Text("关注") | ||
| 139 | + .textStyle2() | ||
| 140 | + }.margin({ left: '15lpx' }) | ||
| 141 | + }.margin({ top: '23lpx' }) | ||
| 142 | + }.alignItems(HorizontalAlign.Start) | ||
| 143 | + .margin({ left: StringUtils.isEmpty(this.levelHead)?'32lpx':"3lpx" }) | ||
| 144 | + } | ||
| 145 | + .onAreaChange((oldValue: Area, newValue: Area) => { | ||
| 146 | + if (this.firstPositionY === 0) { | ||
| 147 | + this.firstPositionY = newValue.globalPosition.y as number | ||
| 148 | + }else{ | ||
| 149 | + let persent = (this.firstPositionY - Number(newValue.globalPosition.y)) / (this.firstPositionY * 0.3) | ||
| 150 | + if(persent > 1){ | ||
| 151 | + persent = 1 | ||
| 99 | } | 152 | } |
| 100 | - Blank() | ||
| 101 | - }.width('507lpx') | 153 | + this.tileOpacity = persent |
| 154 | + } | ||
| 155 | + }) | ||
| 156 | + .backgroundColor($r('app.color.color_transparent')) | ||
| 157 | + .height('184lpx') | ||
| 158 | + .width('100%') | ||
| 159 | + .padding({ left: '6lpx' }) | ||
| 102 | 160 | ||
| 103 | - Row() { | 161 | + //用户简介区域 |
| 162 | + if(StringUtils.isNotEmpty(this.desc)){ | ||
| 163 | + Column() { | ||
| 104 | Row() { | 164 | Row() { |
| 105 | - Text(`${this.browseNum}`) | ||
| 106 | - .textStyle() | ||
| 107 | - Text("阅读") | ||
| 108 | - .textStyle2() | 165 | + Text(this.desc) |
| 166 | + .fontSize('27lpx') | ||
| 167 | + .maxLines(3) | ||
| 168 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 169 | + .lineHeight('40lpx') | ||
| 170 | + .fontWeight('400lpx') | ||
| 171 | + .fontColor($r('app.color.color_222222')) | ||
| 172 | + .textAlign(TextAlign.Start) | ||
| 173 | + | ||
| 109 | } | 174 | } |
| 110 | - .margin({ right: '15lpx' }) | ||
| 111 | - | ||
| 112 | - Divider() | ||
| 113 | - .height('19lpx') | ||
| 114 | - .width('2lpx') | ||
| 115 | - .color($r('app.color.white')) | ||
| 116 | - .vertical(true) | ||
| 117 | - .opacity(0.4) | ||
| 118 | - Row() { | ||
| 119 | - Text(`${this.commentNum}`) | ||
| 120 | - .textStyle() | ||
| 121 | - Text("评论") | ||
| 122 | - .textStyle2() | ||
| 123 | - }.margin({ right: '15lpx', left: '15lpx' }) | ||
| 124 | - | ||
| 125 | - Divider() | ||
| 126 | - .height('19lpx') | ||
| 127 | - .width('2lpx') | ||
| 128 | - .color($r('app.color.white')) | ||
| 129 | - .vertical(true) | ||
| 130 | - .opacity(0.4) | ||
| 131 | - Row() { | ||
| 132 | - Text(`${this.attentionNum}`) | ||
| 133 | - .textStyle() | ||
| 134 | - Text("关注") | ||
| 135 | - .textStyle2() | ||
| 136 | - }.margin({ left: '15lpx' }) | ||
| 137 | - }.margin({ top: '23lpx' }) | ||
| 138 | - }.alignItems(HorizontalAlign.Start) | ||
| 139 | - .margin({ left: StringUtils.isEmpty(this.levelHead)?'32lpx':"3lpx" }) | ||
| 140 | - } | ||
| 141 | - .onAreaChange((oldValue: Area, newValue: Area) => { | ||
| 142 | - if (this.firstPositionY === 0) { | ||
| 143 | - this.firstPositionY = newValue.globalPosition.y as number | ||
| 144 | - }else{ | ||
| 145 | - let persent = (this.firstPositionY - Number(newValue.globalPosition.y)) / (this.firstPositionY * 0.3) | ||
| 146 | - if(persent > 1){ | ||
| 147 | - persent = 1 | ||
| 148 | - } | ||
| 149 | - this.tileOpacity = persent | 175 | + }.padding({ left: '31lpx',right:'31lpx',top:'19lpx',bottom:'31lpx'}) |
| 176 | + .alignItems(HorizontalAlign.Start) | ||
| 177 | + .justifyContent(FlexAlign.Center) | ||
| 178 | + .width('100%') | ||
| 179 | + .backgroundColor($r('app.color.white')) | ||
| 150 | } | 180 | } |
| 151 | - }) | ||
| 152 | - .backgroundColor($r('app.color.color_transparent')) | ||
| 153 | - .height('184lpx') | ||
| 154 | - .width('100%') | ||
| 155 | - .padding({ left: '6lpx' }) | ||
| 156 | - | ||
| 157 | - //用户简介区域 | ||
| 158 | - if(StringUtils.isNotEmpty(this.desc)){ | ||
| 159 | - Column() { | ||
| 160 | - Row() { | ||
| 161 | - Text(this.desc) | ||
| 162 | - .fontSize('27lpx') | ||
| 163 | - .maxLines(3) | ||
| 164 | - .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 165 | - .lineHeight('40lpx') | ||
| 166 | - .fontWeight('400lpx') | ||
| 167 | - .fontColor($r('app.color.color_222222')) | ||
| 168 | - .textAlign(TextAlign.Start) | ||
| 169 | - | ||
| 170 | - } | ||
| 171 | - }.padding({ left: '31lpx',right:'31lpx',top:'19lpx',bottom:'31lpx'}) | ||
| 172 | - .alignItems(HorizontalAlign.Start) | ||
| 173 | - .justifyContent(FlexAlign.Center) | ||
| 174 | - .width('100%') | ||
| 175 | - .backgroundColor($r('app.color.white')) | ||
| 176 | - } | ||
| 177 | - //间隔符 | ||
| 178 | - Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx') | ||
| 179 | - | ||
| 180 | - //tab 页面 | ||
| 181 | - Stack({ alignContent: Alignment.Top }){ | ||
| 182 | - Tabs({controller: this.controller}) { | ||
| 183 | - TabContent() { | ||
| 184 | - OtherHomePageBottomCommentComponent({curUserId:this.curUserId,levelHead:this.levelHead,commentNum:$commentNum}) | ||
| 185 | - } | ||
| 186 | - TabContent() { | ||
| 187 | - OtherHomePageBottomFollowComponent({curUserId:this.curUserId}) | 181 | + //间隔符 |
| 182 | + Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx') | ||
| 183 | + | ||
| 184 | + //tab 页面 | ||
| 185 | + Stack({ alignContent: Alignment.Top }){ | ||
| 186 | + Tabs({controller: this.controller}) { | ||
| 187 | + TabContent() { | ||
| 188 | + OtherHomePageBottomCommentComponent({curUserId:this.curUserId,levelHead:this.levelHead,commentNum:$commentNum}) | ||
| 189 | + } | ||
| 190 | + TabContent() { | ||
| 191 | + OtherHomePageBottomFollowComponent({curUserId:this.curUserId}) | ||
| 192 | + } | ||
| 188 | } | 193 | } |
| 189 | - } | ||
| 190 | - .backgroundColor($r('app.color.white')) | ||
| 191 | - .animationDuration(0) | ||
| 192 | - .onChange((index: number) => { | ||
| 193 | - this.currentIndex = index | ||
| 194 | - }) | ||
| 195 | - .vertical(false) | ||
| 196 | - .barHeight('77lpx') | ||
| 197 | - | ||
| 198 | - Column() { | ||
| 199 | - // 页签 | ||
| 200 | - Row({ space: 7 }) { | ||
| 201 | - Scroll() { | ||
| 202 | - Row() { | ||
| 203 | - this.TabBuilder(0,"评论") | ||
| 204 | - this.TabBuilder(1,"关注") | 194 | + .backgroundColor($r('app.color.white')) |
| 195 | + .animationDuration(0) | ||
| 196 | + .onChange((index: number) => { | ||
| 197 | + this.currentIndex = index | ||
| 198 | + }) | ||
| 199 | + .vertical(false) | ||
| 200 | + .barHeight('77lpx') | ||
| 201 | + | ||
| 202 | + Column() { | ||
| 203 | + // 页签 | ||
| 204 | + Row({ space: 7 }) { | ||
| 205 | + Scroll() { | ||
| 206 | + Row() { | ||
| 207 | + this.TabBuilder(0,"评论") | ||
| 208 | + this.TabBuilder(1,"关注") | ||
| 209 | + } | ||
| 210 | + .justifyContent(FlexAlign.Start) | ||
| 205 | } | 211 | } |
| 206 | - .justifyContent(FlexAlign.Start) | 212 | + .align(Alignment.Start) |
| 213 | + .scrollable(ScrollDirection.Horizontal) | ||
| 214 | + .scrollBar(BarState.Off) | ||
| 215 | + .width('90%') | ||
| 216 | + .padding({left:'31lpx'}) | ||
| 207 | } | 217 | } |
| 208 | - .align(Alignment.Start) | ||
| 209 | - .scrollable(ScrollDirection.Horizontal) | ||
| 210 | - .scrollBar(BarState.Off) | ||
| 211 | - .width('90%') | ||
| 212 | - .padding({left:'31lpx'}) | 218 | + .alignItems(VerticalAlign.Bottom) |
| 219 | + .width('100%') | ||
| 213 | } | 220 | } |
| 214 | - .alignItems(VerticalAlign.Bottom) | 221 | + .backgroundColor($r('app.color.white')) |
| 222 | + .alignItems(HorizontalAlign.Start) | ||
| 215 | .width('100%') | 223 | .width('100%') |
| 224 | + .height('77lpx') | ||
| 216 | } | 225 | } |
| 217 | - .backgroundColor($r('app.color.white')) | ||
| 218 | - .alignItems(HorizontalAlign.Start) | ||
| 219 | - .width('100%') | ||
| 220 | - .height('77lpx') | ||
| 221 | - } | ||
| 222 | - }.width("100%") | 226 | + }.width("100%") |
| 227 | + } | ||
| 228 | + .edgeEffect(EdgeEffect.None) | ||
| 229 | + .scrollBar(BarState.Off) | ||
| 230 | + .width('100%') | ||
| 231 | + .layoutWeight(1) | ||
| 223 | } | 232 | } |
| 224 | - .edgeEffect(EdgeEffect.None) | ||
| 225 | - .scrollBar(BarState.Off) | ||
| 226 | - .width('100%') | ||
| 227 | - .layoutWeight(1) | 233 | + }.width('100%') |
| 234 | + .layoutWeight(1) | ||
| 235 | + }else{ | ||
| 236 | + Column(){ | ||
| 237 | + CustomTitleUI({ titleName: "" }) | ||
| 238 | + | ||
| 239 | + EmptyComponent({ emptyType: 1,emptyHeight:"100%" ,retry: () => { | ||
| 240 | + this.isConnectNetwork = NetworkUtil.isNetConnected() | ||
| 241 | + if(this.isChangeToUserEdit){ | ||
| 242 | + this.getUserInfo() | ||
| 243 | + } | ||
| 244 | + },}) | ||
| 245 | + .layoutWeight(1) | ||
| 246 | + .width('100%') | ||
| 228 | } | 247 | } |
| 229 | - }.width('100%') | ||
| 230 | - .layoutWeight(1) | 248 | + } |
| 231 | 249 | ||
| 232 | } | 250 | } |
| 233 | @Builder MineHomeTitleTransparent() { | 251 | @Builder MineHomeTitleTransparent() { |
-
Please register or login to post a comment