wangliang_wd

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

... ... @@ -11,6 +11,7 @@ import MinePageDatasModel from '../model/MinePageDatasModel';
import { ListHasNoMoreDataUI } from '../components/reusable/ListHasNoMoreDataUI';
import { FollowChildComponent } from '../components/mine/follow/FollowChildComponent';
import { SpConstants } from 'wdConstant/Index';
import { CustomPullToRefresh } from '../../../../Index';
const TAG = "SearchCreatorPage"
... ... @@ -28,6 +29,7 @@ struct SearchCreatorPage {
curPageNum: number = 1;
@State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
private scroller: Scroller = new Scroller();
onPageShow() {
this.keyword = this.params?.pageID;
... ... @@ -35,7 +37,7 @@ struct SearchCreatorPage {
this.getNewPageData()
}
getNewPageData() {
getNewPageData(resolve?: (value: string | PromiseLike<string>) => void) {
this.isLoading = true
if (this.hasMore) {
SearcherAboutDataModel.getSearchResultListData("20",`${this.curPageNum}`,this.searchType,this.keyword,getContext(this)).then((result)=>{
... ... @@ -78,6 +80,7 @@ struct SearchCreatorPage {
}
})
})
if(resolve) resolve('刷新成功')
this.getFollowListStatus(result.totalCount)
}
}).catch((err:Error)=>{
... ... @@ -170,32 +173,20 @@ struct SearchCreatorPage {
ListHasNoMoreDataUI({style:2})
.height('100%')
}else{
List({ space: 3 }) {
LazyForEach(this.data, (item: FollowListDetailItem, index: number = 0) => {
ListItem() {
FollowChildComponent({data: item,type:1})
}
.onClick(() => {
})
}, (item: FollowListDetailItem, index: number) => index.toString())
//没有更多数据 显示提示
if(!this.hasMore){
ListItem(){
ListHasNoMoreDataUI()
CustomPullToRefresh({
alldata:this.data,
scroller:this.scroller,
hasMore:this.hasMore,
customList:()=>{
this.ListLayout()
},
onRefresh:(resolve)=>{
},
onLoadMore:(resolve)=> {
if (this.hasMore) {
this.getNewPageData(resolve)
}
}
}.cachedCount(5)
.padding({left:'31lpx',right:'31lpx'})
.layoutWeight(1)
.scrollBar(BarState.Off)
.onReachEnd(()=>{
Logger.debug(TAG,"触底了");
if(!this.isLoading){
this.isLoading = true
//加载分页数据
this.getNewPageData()
}
})
}
}.layoutWeight(1)
... ... @@ -209,4 +200,27 @@ struct SearchCreatorPage {
.padding({top:px2vp(this.topSafeHeight)})
}
@Builder ListLayout() {
List({ space: 3,scroller: this.scroller }) {
LazyForEach(this.data, (item: FollowListDetailItem, index: number = 0) => {
ListItem() {
FollowChildComponent({data: item,type:1})
}
.onClick(() => {
})
}, (item: FollowListDetailItem, index: number) => index.toString())
//没有更多数据 显示提示
if(!this.hasMore){
ListItem(){
ListHasNoMoreDataUI().height(64)
}
}
}.cachedCount(5)
.padding({left:'31lpx',right:'31lpx'})
.layoutWeight(1)
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
}
}
\ No newline at end of file
... ...