Showing
2 changed files
with
55 additions
and
29 deletions
| 1 | -import { EmitterUtils, EmitterEventId, Logger } from 'wdKit/Index' | 1 | +import { EmitterUtils, EmitterEventId, Logger, NetworkUtil } from 'wdKit/Index' |
| 2 | import MinePageDatasModel from '../../../model/MinePageDatasModel' | 2 | import MinePageDatasModel from '../../../model/MinePageDatasModel' |
| 3 | import { FollowListItem } from '../../../viewmodel/FollowListItem' | 3 | import { FollowListItem } from '../../../viewmodel/FollowListItem' |
| 4 | import { CustomTitleUI } from '../../reusable/CustomTitleUI' | 4 | import { CustomTitleUI } from '../../reusable/CustomTitleUI' |
| 5 | +import { EmptyComponent } from '../../view/EmptyComponent' | ||
| 5 | import { FollowSecondTabsComponent } from './FollowSecondTabsComponent' | 6 | import { FollowSecondTabsComponent } from './FollowSecondTabsComponent' |
| 6 | const TAG = "FollowFirstTabsComponent" | 7 | const TAG = "FollowFirstTabsComponent" |
| 7 | @Component | 8 | @Component |
| @@ -12,13 +13,24 @@ export struct FollowFirstTabsComponent{ | @@ -12,13 +13,24 @@ export struct FollowFirstTabsComponent{ | ||
| 12 | @State data:FollowListItem[] = [] | 13 | @State data:FollowListItem[] = [] |
| 13 | fontColor: string = '#999999' | 14 | fontColor: string = '#999999' |
| 14 | selectedFontColor: string = '#000000' | 15 | selectedFontColor: string = '#000000' |
| 16 | + @State isConnectNetwork : boolean = NetworkUtil.isNetConnected() | ||
| 15 | 17 | ||
| 16 | aboutToAppear(){ | 18 | aboutToAppear(){ |
| 19 | + this.getFollowTabList() | ||
| 20 | + | ||
| 21 | + EmitterUtils.receiveEvent(EmitterEventId.MY_FOLLOW_EMPTY, (() => { | ||
| 22 | + if(this.controller != null && this.data.length>1 ){ | ||
| 23 | + this.jumpFollowNextPage() | ||
| 24 | + } | ||
| 25 | + })) | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + getFollowTabList(){ | ||
| 17 | MinePageDatasModel.getFollowListData(getContext(this)).then((value)=>{ | 29 | MinePageDatasModel.getFollowListData(getContext(this)).then((value)=>{ |
| 18 | this.data.push(new FollowListItem("我的")) | 30 | this.data.push(new FollowListItem("我的")) |
| 19 | - value.forEach((element)=>{ | ||
| 20 | - this.data.push(element) | ||
| 21 | - }) | 31 | + value.forEach((element)=>{ |
| 32 | + this.data.push(element) | ||
| 33 | + }) | ||
| 22 | 34 | ||
| 23 | if(this.controller != null && this.data.length>1 && this.changeIndex === 1){ | 35 | if(this.controller != null && this.data.length>1 && this.changeIndex === 1){ |
| 24 | this.jumpFollowNextPage() | 36 | this.jumpFollowNextPage() |
| @@ -26,12 +38,6 @@ export struct FollowFirstTabsComponent{ | @@ -26,12 +38,6 @@ export struct FollowFirstTabsComponent{ | ||
| 26 | }).catch((err:Error)=>{ | 38 | }).catch((err:Error)=>{ |
| 27 | console.log(TAG,JSON.stringify(err)) | 39 | console.log(TAG,JSON.stringify(err)) |
| 28 | }) | 40 | }) |
| 29 | - | ||
| 30 | - EmitterUtils.receiveEvent(EmitterEventId.MY_FOLLOW_EMPTY, (() => { | ||
| 31 | - if(this.controller != null && this.data.length>1 ){ | ||
| 32 | - this.jumpFollowNextPage() | ||
| 33 | - } | ||
| 34 | - })) | ||
| 35 | } | 41 | } |
| 36 | 42 | ||
| 37 | jumpFollowNextPage(){ | 43 | jumpFollowNextPage(){ |
| @@ -75,24 +81,40 @@ export struct FollowFirstTabsComponent{ | @@ -75,24 +81,40 @@ export struct FollowFirstTabsComponent{ | ||
| 75 | //标题栏目 | 81 | //标题栏目 |
| 76 | CustomTitleUI({titleName:"关注列表"}) | 82 | CustomTitleUI({titleName:"关注列表"}) |
| 77 | 83 | ||
| 78 | - Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { | ||
| 79 | - ForEach(this.data, (item: FollowListItem, index: number ) => { | ||
| 80 | - TabContent(){ | ||
| 81 | - FollowSecondTabsComponent({data:$data,firstIndex:index}) | ||
| 82 | - }.tabBar(this.TabBuilder(index,item)) | ||
| 83 | - }, (item: FollowListItem, index: number) => index.toString()) | 84 | + if(!this.isConnectNetwork){ |
| 85 | + EmptyComponent({ emptyType: 1,emptyHeight:"100%" ,retry: () => { | ||
| 86 | + this.reloadNetWork() | ||
| 87 | + },}) | ||
| 88 | + .layoutWeight(1) | ||
| 89 | + .width('100%') | ||
| 90 | + }else{ | ||
| 91 | + Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { | ||
| 92 | + ForEach(this.data, (item: FollowListItem, index: number ) => { | ||
| 93 | + TabContent(){ | ||
| 94 | + FollowSecondTabsComponent({data:$data,firstIndex:index}) | ||
| 95 | + }.tabBar(this.TabBuilder(index,item)) | ||
| 96 | + }, (item: FollowListItem, index: number) => index.toString()) | ||
| 97 | + } | ||
| 98 | + .vertical(false) | ||
| 99 | + .barMode(BarMode.Scrollable) | ||
| 100 | + .barWidth('100%') | ||
| 101 | + .barBackgroundColor($r('app.color.white')) | ||
| 102 | + .barHeight('84lpx') | ||
| 103 | + .animationDuration(0) | ||
| 104 | + .onChange((index: number) => { | ||
| 105 | + this.currentIndex = index | ||
| 106 | + }) | ||
| 107 | + .width('100%') | ||
| 108 | + .layoutWeight(1) | ||
| 84 | } | 109 | } |
| 85 | - .vertical(false) | ||
| 86 | - .barMode(BarMode.Scrollable) | ||
| 87 | - .barWidth('100%') | ||
| 88 | - .barBackgroundColor($r('app.color.white')) | ||
| 89 | - .barHeight('84lpx') | ||
| 90 | - .animationDuration(0) | ||
| 91 | - .onChange((index: number) => { | ||
| 92 | - this.currentIndex = index | ||
| 93 | - }) | ||
| 94 | - .width('100%') | ||
| 95 | - .layoutWeight(1) | ||
| 96 | }.width('100%') | 110 | }.width('100%') |
| 97 | } | 111 | } |
| 112 | + | ||
| 113 | + reloadNetWork(){ | ||
| 114 | + let c = NetworkUtil.isNetConnected() | ||
| 115 | + if(c){ | ||
| 116 | + this.getFollowTabList() | ||
| 117 | + this.isConnectNetwork = c | ||
| 118 | + } | ||
| 119 | + } | ||
| 98 | } | 120 | } |
| 1 | -import { EmitterEventId, EmitterUtils, LazyDataSource, SPHelper, UserDataLocal } from 'wdKit'; | 1 | +import { EmitterEventId, EmitterUtils, LazyDataSource, NetworkUtil, SPHelper, UserDataLocal } from 'wdKit'; |
| 2 | import MinePageDatasModel from '../../../model/MinePageDatasModel'; | 2 | import MinePageDatasModel from '../../../model/MinePageDatasModel'; |
| 3 | import SearcherAboutDataModel from '../../../model/SearcherAboutDataModel'; | 3 | import SearcherAboutDataModel from '../../../model/SearcherAboutDataModel'; |
| 4 | import { CreatorDetailRequestItem } from '../../../viewmodel/CreatorDetailRequestItem'; | 4 | import { CreatorDetailRequestItem } from '../../../viewmodel/CreatorDetailRequestItem'; |
| @@ -70,7 +70,11 @@ export struct FollowListDetailUI { | @@ -70,7 +70,11 @@ export struct FollowListDetailUI { | ||
| 70 | Column() { | 70 | Column() { |
| 71 | if (this.count === 0) { | 71 | if (this.count === 0) { |
| 72 | if (this.isGetRequest == true) { | 72 | if (this.isGetRequest == true) { |
| 73 | - if(this.creatorDirectoryId === -1){ | 73 | + if(!NetworkUtil.isNetConnected()){ |
| 74 | + EmptyComponent({ emptyType: 1,emptyHeight:"100%" }) | ||
| 75 | + .layoutWeight(1) | ||
| 76 | + .width('100%') | ||
| 77 | + }else if(this.creatorDirectoryId === -1){ | ||
| 74 | EmptyComponent({ emptyType: 14,emptyHeight:"100%" }) | 78 | EmptyComponent({ emptyType: 14,emptyHeight:"100%" }) |
| 75 | .layoutWeight(1) | 79 | .layoutWeight(1) |
| 76 | .width('100%') | 80 | .width('100%') |
-
Please register or login to post a comment