Showing
2 changed files
with
69 additions
and
28 deletions
| @@ -7,6 +7,7 @@ import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI'; | @@ -7,6 +7,7 @@ import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI'; | ||
| 7 | import { FollowChildComponent } from '../follow/FollowChildComponent'; | 7 | import { FollowChildComponent } from '../follow/FollowChildComponent'; |
| 8 | import dataPreferences from '@ohos.data.preferences'; | 8 | import dataPreferences from '@ohos.data.preferences'; |
| 9 | import { EmptyComponent } from '../../view/EmptyComponent'; | 9 | import { EmptyComponent } from '../../view/EmptyComponent'; |
| 10 | +import { CustomPullToRefresh } from '../../reusable/CustomPullToRefresh'; | ||
| 10 | 11 | ||
| 11 | const TAG = "HomePageBottomFollowComponent" | 12 | const TAG = "HomePageBottomFollowComponent" |
| 12 | /** | 13 | /** |
| @@ -14,6 +15,7 @@ const TAG = "HomePageBottomFollowComponent" | @@ -14,6 +15,7 @@ const TAG = "HomePageBottomFollowComponent" | ||
| 14 | */ | 15 | */ |
| 15 | @Component | 16 | @Component |
| 16 | export struct HomePageBottomFollowComponent { | 17 | export struct HomePageBottomFollowComponent { |
| 18 | + private scroller: Scroller = new Scroller(); | ||
| 17 | @State data_follow: LazyDataSource<FollowListDetailItem> = new LazyDataSource(); | 19 | @State data_follow: LazyDataSource<FollowListDetailItem> = new LazyDataSource(); |
| 18 | @State isLoading: boolean = false | 20 | @State isLoading: boolean = false |
| 19 | @State hasMore: boolean = true | 21 | @State hasMore: boolean = true |
| @@ -104,8 +106,40 @@ export struct HomePageBottomFollowComponent { | @@ -104,8 +106,40 @@ export struct HomePageBottomFollowComponent { | ||
| 104 | }) | 106 | }) |
| 105 | }.layoutWeight(1) | 107 | }.layoutWeight(1) |
| 106 | } else { | 108 | } else { |
| 107 | - List({ space: 3 }) { | 109 | + CustomPullToRefresh({ |
| 110 | + alldata:this.data_follow, | ||
| 111 | + scroller:this.scroller, | ||
| 112 | + customList:()=>{ | ||
| 113 | + this.ListLayout() | ||
| 114 | + }, | ||
| 115 | + onRefresh:(resolve)=>{ | ||
| 116 | + this.curPageNum = 1; | ||
| 117 | + this.hasMore = true | ||
| 118 | + this.isGetRequest = false | ||
| 119 | + this.data_follow.clear() | ||
| 120 | + | ||
| 121 | + if (!this.isLoading){ | ||
| 122 | + this.getNewPageData() | ||
| 123 | + if(resolve) resolve('刷新成功') | ||
| 124 | + } | ||
| 125 | + }, | ||
| 126 | + onLoadMore:(resolve)=> { | ||
| 127 | + console.log(TAG, "触底了"); | ||
| 128 | + if (!this.isLoading) { | ||
| 129 | + this.isLoading = true | ||
| 130 | + //加载分页数据 | ||
| 131 | + this.getNewPageData() | ||
| 132 | + } | ||
| 133 | + } | ||
| 134 | + }) | ||
| 135 | + } | ||
| 136 | + }.layoutWeight(1) | ||
| 137 | + .justifyContent(FlexAlign.Start) | ||
| 138 | + .width('100%') | ||
| 139 | + } | ||
| 108 | 140 | ||
| 141 | + @Builder ListLayout(){ | ||
| 142 | + List({ space: 3 ,scroller:this.scroller}) { | ||
| 109 | ListItem() { | 143 | ListItem() { |
| 110 | Row() { | 144 | Row() { |
| 111 | Text("关注更多人民号") | 145 | Text("关注更多人民号") |
| @@ -136,7 +170,6 @@ export struct HomePageBottomFollowComponent { | @@ -136,7 +170,6 @@ export struct HomePageBottomFollowComponent { | ||
| 136 | FollowChildComponent({ data: item, type: 2 }) | 170 | FollowChildComponent({ data: item, type: 2 }) |
| 137 | } | 171 | } |
| 138 | }, (item: FollowListDetailItem, index: number) => index.toString()) | 172 | }, (item: FollowListDetailItem, index: number) => index.toString()) |
| 139 | - | ||
| 140 | //没有更多数据 显示提示 | 173 | //没有更多数据 显示提示 |
| 141 | if (!this.hasMore) { | 174 | if (!this.hasMore) { |
| 142 | ListItem() { | 175 | ListItem() { |
| @@ -153,18 +186,6 @@ export struct HomePageBottomFollowComponent { | @@ -153,18 +186,6 @@ export struct HomePageBottomFollowComponent { | ||
| 153 | scrollForward: NestedScrollMode.PARENT_FIRST, | 186 | scrollForward: NestedScrollMode.PARENT_FIRST, |
| 154 | scrollBackward: NestedScrollMode.SELF_FIRST | 187 | scrollBackward: NestedScrollMode.SELF_FIRST |
| 155 | }) | 188 | }) |
| 156 | - .onReachEnd(() => { | ||
| 157 | - console.log(TAG, "触底了"); | ||
| 158 | - if (!this.isLoading) { | ||
| 159 | - this.isLoading = true | ||
| 160 | - //加载分页数据 | ||
| 161 | - this.getNewPageData() | ||
| 162 | - } | ||
| 163 | - }) | ||
| 164 | - } | ||
| 165 | - }.layoutWeight(1) | ||
| 166 | - .justifyContent(FlexAlign.Start) | ||
| 167 | - .width('100%') | ||
| 168 | } | 189 | } |
| 169 | 190 | ||
| 170 | @Styles | 191 | @Styles |
| @@ -4,6 +4,7 @@ import { WDRouterRule, WDRouterPage } from 'wdRouter'; | @@ -4,6 +4,7 @@ import { WDRouterRule, WDRouterPage } from 'wdRouter'; | ||
| 4 | import MinePageDatasModel from '../../../model/MinePageDatasModel'; | 4 | import MinePageDatasModel from '../../../model/MinePageDatasModel'; |
| 5 | import { FollowListDetailItem } from '../../../viewmodel/FollowListDetailItem'; | 5 | import { FollowListDetailItem } from '../../../viewmodel/FollowListDetailItem'; |
| 6 | import { UserFollowListRequestItem } from '../../../viewmodel/UserFollowListRequestItem'; | 6 | import { UserFollowListRequestItem } from '../../../viewmodel/UserFollowListRequestItem'; |
| 7 | +import { CustomPullToRefresh } from '../../reusable/CustomPullToRefresh'; | ||
| 7 | import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI'; | 8 | import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI'; |
| 8 | import { EmptyComponent } from '../../view/EmptyComponent'; | 9 | import { EmptyComponent } from '../../view/EmptyComponent'; |
| 9 | import { FollowChildComponent } from '../follow/FollowChildComponent'; | 10 | import { FollowChildComponent } from '../follow/FollowChildComponent'; |
| @@ -22,7 +23,7 @@ export struct OtherHomePageBottomFollowComponent{ | @@ -22,7 +23,7 @@ export struct OtherHomePageBottomFollowComponent{ | ||
| 22 | @State count:number = 0; | 23 | @State count:number = 0; |
| 23 | @Prop curUserId: string | 24 | @Prop curUserId: string |
| 24 | @State isGetRequest:boolean = false | 25 | @State isGetRequest:boolean = false |
| 25 | - | 26 | + private scroller: Scroller = new Scroller(); |
| 26 | 27 | ||
| 27 | aboutToAppear(){ | 28 | aboutToAppear(){ |
| 28 | this.getNewPageData() | 29 | this.getNewPageData() |
| @@ -66,8 +67,39 @@ export struct OtherHomePageBottomFollowComponent{ | @@ -66,8 +67,39 @@ export struct OtherHomePageBottomFollowComponent{ | ||
| 66 | }.layoutWeight(1) | 67 | }.layoutWeight(1) |
| 67 | .justifyContent(FlexAlign.Start) | 68 | .justifyContent(FlexAlign.Start) |
| 68 | }else{ | 69 | }else{ |
| 69 | - List({ space: 3 }) { | 70 | + CustomPullToRefresh({ |
| 71 | + alldata:this.data_follow, | ||
| 72 | + scroller:this.scroller, | ||
| 73 | + customList:()=>{ | ||
| 74 | + this.ListLayout() | ||
| 75 | + }, | ||
| 76 | + onRefresh:(resolve)=>{ | ||
| 77 | + this.curPageNum = 1; | ||
| 78 | + this.hasMore = true | ||
| 79 | + this.isGetRequest = false | ||
| 80 | + this.data_follow.clear() | ||
| 70 | 81 | ||
| 82 | + if (!this.isLoading){ | ||
| 83 | + this.getNewPageData() | ||
| 84 | + if(resolve) resolve('刷新成功') | ||
| 85 | + } | ||
| 86 | + }, | ||
| 87 | + onLoadMore:(resolve)=> { | ||
| 88 | + console.log(TAG, "触底了"); | ||
| 89 | + if (!this.isLoading) { | ||
| 90 | + this.isLoading = true | ||
| 91 | + //加载分页数据 | ||
| 92 | + this.getNewPageData() | ||
| 93 | + } | ||
| 94 | + } | ||
| 95 | + }) | ||
| 96 | + } | ||
| 97 | + } | ||
| 98 | + .width('100%') | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + @Builder ListLayout(){ | ||
| 102 | + List({ space: 3 ,scroller:this.scroller}) { | ||
| 71 | ListItem() { | 103 | ListItem() { |
| 72 | Row(){ | 104 | Row(){ |
| 73 | Text("关注更多人民号") | 105 | Text("关注更多人民号") |
| @@ -115,19 +147,7 @@ export struct OtherHomePageBottomFollowComponent{ | @@ -115,19 +147,7 @@ export struct OtherHomePageBottomFollowComponent{ | ||
| 115 | scrollForward: NestedScrollMode.PARENT_FIRST, | 147 | scrollForward: NestedScrollMode.PARENT_FIRST, |
| 116 | scrollBackward: NestedScrollMode.SELF_FIRST | 148 | scrollBackward: NestedScrollMode.SELF_FIRST |
| 117 | }) | 149 | }) |
| 118 | - .onReachEnd(()=>{ | ||
| 119 | - console.log(TAG,"触底了"); | ||
| 120 | - if(!this.isLoading){ | ||
| 121 | - this.isLoading = true | ||
| 122 | - //加载分页数据 | ||
| 123 | - this.getNewPageData() | ||
| 124 | } | 150 | } |
| 125 | - }) | ||
| 126 | - } | ||
| 127 | - } | ||
| 128 | - .width('100%') | ||
| 129 | - } | ||
| 130 | - | ||
| 131 | 151 | ||
| 132 | @Styles | 152 | @Styles |
| 133 | listStyle() { | 153 | listStyle() { |
-
Please register or login to post a comment