Showing
1 changed file
with
36 additions
and
22 deletions
| @@ -11,6 +11,7 @@ import MinePageDatasModel from '../model/MinePageDatasModel'; | @@ -11,6 +11,7 @@ import MinePageDatasModel from '../model/MinePageDatasModel'; | ||
| 11 | import { ListHasNoMoreDataUI } from '../components/reusable/ListHasNoMoreDataUI'; | 11 | import { ListHasNoMoreDataUI } from '../components/reusable/ListHasNoMoreDataUI'; |
| 12 | import { FollowChildComponent } from '../components/mine/follow/FollowChildComponent'; | 12 | import { FollowChildComponent } from '../components/mine/follow/FollowChildComponent'; |
| 13 | import { SpConstants } from 'wdConstant/Index'; | 13 | import { SpConstants } from 'wdConstant/Index'; |
| 14 | +import { CustomPullToRefresh } from '../../../../Index'; | ||
| 14 | 15 | ||
| 15 | const TAG = "SearchCreatorPage" | 16 | const TAG = "SearchCreatorPage" |
| 16 | 17 | ||
| @@ -28,6 +29,7 @@ struct SearchCreatorPage { | @@ -28,6 +29,7 @@ struct SearchCreatorPage { | ||
| 28 | curPageNum: number = 1; | 29 | curPageNum: number = 1; |
| 29 | @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 | 30 | @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 |
| 30 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | 31 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 |
| 32 | + private scroller: Scroller = new Scroller(); | ||
| 31 | 33 | ||
| 32 | onPageShow() { | 34 | onPageShow() { |
| 33 | this.keyword = this.params?.pageID; | 35 | this.keyword = this.params?.pageID; |
| @@ -35,7 +37,7 @@ struct SearchCreatorPage { | @@ -35,7 +37,7 @@ struct SearchCreatorPage { | ||
| 35 | this.getNewPageData() | 37 | this.getNewPageData() |
| 36 | } | 38 | } |
| 37 | 39 | ||
| 38 | - getNewPageData() { | 40 | + getNewPageData(resolve?: (value: string | PromiseLike<string>) => void) { |
| 39 | this.isLoading = true | 41 | this.isLoading = true |
| 40 | if (this.hasMore) { | 42 | if (this.hasMore) { |
| 41 | SearcherAboutDataModel.getSearchResultListData("20",`${this.curPageNum}`,this.searchType,this.keyword,getContext(this)).then((result)=>{ | 43 | SearcherAboutDataModel.getSearchResultListData("20",`${this.curPageNum}`,this.searchType,this.keyword,getContext(this)).then((result)=>{ |
| @@ -78,6 +80,7 @@ struct SearchCreatorPage { | @@ -78,6 +80,7 @@ struct SearchCreatorPage { | ||
| 78 | } | 80 | } |
| 79 | }) | 81 | }) |
| 80 | }) | 82 | }) |
| 83 | + if(resolve) resolve('刷新成功') | ||
| 81 | this.getFollowListStatus(result.totalCount) | 84 | this.getFollowListStatus(result.totalCount) |
| 82 | } | 85 | } |
| 83 | }).catch((err:Error)=>{ | 86 | }).catch((err:Error)=>{ |
| @@ -170,7 +173,36 @@ struct SearchCreatorPage { | @@ -170,7 +173,36 @@ struct SearchCreatorPage { | ||
| 170 | ListHasNoMoreDataUI({style:2}) | 173 | ListHasNoMoreDataUI({style:2}) |
| 171 | .height('100%') | 174 | .height('100%') |
| 172 | }else{ | 175 | }else{ |
| 173 | - List({ space: 3 }) { | 176 | + CustomPullToRefresh({ |
| 177 | + alldata:this.data, | ||
| 178 | + scroller:this.scroller, | ||
| 179 | + hasMore:this.hasMore, | ||
| 180 | + customList:()=>{ | ||
| 181 | + this.ListLayout() | ||
| 182 | + }, | ||
| 183 | + onRefresh:(resolve)=>{ | ||
| 184 | + }, | ||
| 185 | + onLoadMore:(resolve)=> { | ||
| 186 | + if (this.hasMore) { | ||
| 187 | + this.getNewPageData(resolve) | ||
| 188 | + } | ||
| 189 | + } | ||
| 190 | + }) | ||
| 191 | + } | ||
| 192 | + }.layoutWeight(1) | ||
| 193 | + .width('100%') | ||
| 194 | + } | ||
| 195 | + .width('100%') | ||
| 196 | + .height('100%') | ||
| 197 | + }.width("100%") | ||
| 198 | + .height("100%") | ||
| 199 | + .backgroundColor($r('app.color.color_transparent')) | ||
| 200 | + .padding({top:px2vp(this.topSafeHeight)}) | ||
| 201 | + | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + @Builder ListLayout() { | ||
| 205 | + List({ space: 3,scroller: this.scroller }) { | ||
| 174 | LazyForEach(this.data, (item: FollowListDetailItem, index: number = 0) => { | 206 | LazyForEach(this.data, (item: FollowListDetailItem, index: number = 0) => { |
| 175 | ListItem() { | 207 | ListItem() { |
| 176 | FollowChildComponent({data: item,type:1}) | 208 | FollowChildComponent({data: item,type:1}) |
| @@ -182,31 +214,13 @@ struct SearchCreatorPage { | @@ -182,31 +214,13 @@ struct SearchCreatorPage { | ||
| 182 | //没有更多数据 显示提示 | 214 | //没有更多数据 显示提示 |
| 183 | if(!this.hasMore){ | 215 | if(!this.hasMore){ |
| 184 | ListItem(){ | 216 | ListItem(){ |
| 185 | - ListHasNoMoreDataUI() | 217 | + ListHasNoMoreDataUI().height(64) |
| 186 | } | 218 | } |
| 187 | } | 219 | } |
| 188 | }.cachedCount(5) | 220 | }.cachedCount(5) |
| 189 | .padding({left:'31lpx',right:'31lpx'}) | 221 | .padding({left:'31lpx',right:'31lpx'}) |
| 190 | .layoutWeight(1) | 222 | .layoutWeight(1) |
| 191 | .scrollBar(BarState.Off) | 223 | .scrollBar(BarState.Off) |
| 192 | - .onReachEnd(()=>{ | ||
| 193 | - Logger.debug(TAG,"触底了"); | ||
| 194 | - if(!this.isLoading){ | ||
| 195 | - this.isLoading = true | ||
| 196 | - //加载分页数据 | ||
| 197 | - this.getNewPageData() | ||
| 198 | - } | ||
| 199 | - }) | ||
| 200 | - } | ||
| 201 | - }.layoutWeight(1) | ||
| 202 | - .width('100%') | ||
| 203 | - } | ||
| 204 | - .width('100%') | ||
| 205 | - .height('100%') | ||
| 206 | - }.width("100%") | ||
| 207 | - .height("100%") | ||
| 208 | - .backgroundColor($r('app.color.color_transparent')) | ||
| 209 | - .padding({top:px2vp(this.topSafeHeight)}) | ||
| 210 | - | 224 | + .edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果 |
| 211 | } | 225 | } |
| 212 | } | 226 | } |
-
Please register or login to post a comment