wangliang_wd

feat:优化人民号搜索结果上拉更多逻辑处理

@@ -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,32 +173,20 @@ struct SearchCreatorPage { @@ -170,32 +173,20 @@ struct SearchCreatorPage {
170 ListHasNoMoreDataUI({style:2}) 173 ListHasNoMoreDataUI({style:2})
171 .height('100%') 174 .height('100%')
172 }else{ 175 }else{
173 - List({ space: 3 }) {  
174 - LazyForEach(this.data, (item: FollowListDetailItem, index: number = 0) => {  
175 - ListItem() {  
176 - FollowChildComponent({data: item,type:1})  
177 - }  
178 - .onClick(() => {  
179 - })  
180 - }, (item: FollowListDetailItem, index: number) => index.toString())  
181 -  
182 - //没有更多数据 显示提示  
183 - if(!this.hasMore){  
184 - ListItem(){  
185 - ListHasNoMoreDataUI() 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)
186 } 188 }
187 } 189 }
188 - }.cachedCount(5)  
189 - .padding({left:'31lpx',right:'31lpx'})  
190 - .layoutWeight(1)  
191 - .scrollBar(BarState.Off)  
192 - .onReachEnd(()=>{  
193 - Logger.debug(TAG,"触底了");  
194 - if(!this.isLoading){  
195 - this.isLoading = true  
196 - //加载分页数据  
197 - this.getNewPageData()  
198 - }  
199 }) 190 })
200 } 191 }
201 }.layoutWeight(1) 192 }.layoutWeight(1)
@@ -209,4 +200,27 @@ struct SearchCreatorPage { @@ -209,4 +200,27 @@ struct SearchCreatorPage {
209 .padding({top:px2vp(this.topSafeHeight)}) 200 .padding({top:px2vp(this.topSafeHeight)})
210 201
211 } 202 }
  203 +
  204 + @Builder ListLayout() {
  205 + List({ space: 3,scroller: this.scroller }) {
  206 + LazyForEach(this.data, (item: FollowListDetailItem, index: number = 0) => {
  207 + ListItem() {
  208 + FollowChildComponent({data: item,type:1})
  209 + }
  210 + .onClick(() => {
  211 + })
  212 + }, (item: FollowListDetailItem, index: number) => index.toString())
  213 +
  214 + //没有更多数据 显示提示
  215 + if(!this.hasMore){
  216 + ListItem(){
  217 + ListHasNoMoreDataUI().height(64)
  218 + }
  219 + }
  220 + }.cachedCount(5)
  221 + .padding({left:'31lpx',right:'31lpx'})
  222 + .layoutWeight(1)
  223 + .scrollBar(BarState.Off)
  224 + .edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
  225 + }
212 } 226 }