|
|
|
@ -12,7 +12,7 @@ |
|
|
|
<view class="loading-more lf-m-b-10"> |
|
|
|
<text :class="{'loading-more-text': tabItem.loadingClass}" v-if="tabItem.list.length">{{tabItem.loadingText}}</text> |
|
|
|
<lf-nocontent v-else></lf-nocontent> |
|
|
|
<!-- <view> |
|
|
|
<!-- <view> |
|
|
|
{{tabItem.list.length}} |
|
|
|
</view> --> |
|
|
|
</view> |
|
|
|
@ -29,7 +29,8 @@ |
|
|
|
return { |
|
|
|
tab_list: [], |
|
|
|
current: 0, |
|
|
|
windowHeight: 0 |
|
|
|
windowHeight: 0, |
|
|
|
show_count: 0 |
|
|
|
} |
|
|
|
}, |
|
|
|
components: { |
|
|
|
@ -37,10 +38,13 @@ |
|
|
|
}, |
|
|
|
onShow(){ |
|
|
|
this.windowHeight = getApp().globalData.windowHeight; |
|
|
|
this.getCategory() |
|
|
|
}, |
|
|
|
onHide() { |
|
|
|
this.$refs.uWaterfall[this.current].clear(); |
|
|
|
if(this.show_count >= 1){ |
|
|
|
this.clearTabItem(); |
|
|
|
this.getData(); |
|
|
|
}else{ |
|
|
|
this.getCategory(); |
|
|
|
} |
|
|
|
this.show_count++; |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
getCategory(options = {}) { |
|
|
|
@ -58,11 +62,6 @@ |
|
|
|
isPage: true |
|
|
|
} |
|
|
|
}); |
|
|
|
if(options.type == 'pageRefresh'){ |
|
|
|
uni.stopPullDownRefresh(); |
|
|
|
}else if(options.type == 'scrollRefresh'){ |
|
|
|
this.tab_list[this.current].isRefresher = false; |
|
|
|
} |
|
|
|
this.tab_list = tab_list; |
|
|
|
this.getData() |
|
|
|
}).catch(err => { |
|
|
|
@ -79,6 +78,7 @@ |
|
|
|
tab_item.loadingClass = false; |
|
|
|
tab_item.loadingText = '没有更多数据啦~'; |
|
|
|
} |
|
|
|
tab_item.isRefresher = false; |
|
|
|
if(tab_item.page == 1){ |
|
|
|
tab_item.list = res.data.data; |
|
|
|
}else{ |
|
|
|
@ -89,10 +89,6 @@ |
|
|
|
}) |
|
|
|
}, |
|
|
|
tabChange(index){ |
|
|
|
this.$refs.uWaterfall[index].clear(); |
|
|
|
this.tab_list[index].list = []; |
|
|
|
// this.getCategory({type: 'pageRefresh'}); |
|
|
|
console.log(this.$refs) |
|
|
|
this.current = index; |
|
|
|
if(this.tab_list[index].list.length <= 0){ |
|
|
|
this.getData(); // tab下没有数据,请求第一页 |
|
|
|
@ -117,16 +113,21 @@ |
|
|
|
// scroll-view 下拉刷新 |
|
|
|
onRefresherrefresh(){ |
|
|
|
this.$u.throttle(() => { |
|
|
|
this.$refs.uWaterfall[this.current].clear(); |
|
|
|
this.tab_list[this.current].isRefresher = true; |
|
|
|
this.getCategory({type: 'scrollRefresh'}); |
|
|
|
this.clearTabItem(); |
|
|
|
this.getData(); |
|
|
|
}, 200); |
|
|
|
}, |
|
|
|
// page 下拉刷新 |
|
|
|
onPullDownRefresh(){ |
|
|
|
// 新版逻辑,刷新则整个数据全部重新获取 |
|
|
|
this.getCategory({type: 'pageRefresh'}); |
|
|
|
}, |
|
|
|
clearTabItem(){ |
|
|
|
let tab_item = this.tab_list[this.current]; |
|
|
|
tab_item.page = 1; |
|
|
|
tab_item.isPage = true; |
|
|
|
tab_item.isRefresher = true; |
|
|
|
tab_item.loadingClass = true; |
|
|
|
tab_item.loadingText = '正在加载中'; |
|
|
|
tab_item.list = []; |
|
|
|
this.$set(this.tab_list, this.current, tab_item); |
|
|
|
this.$refs.uWaterfall[this.current].clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|