|
@@ -39,48 +39,47 @@ export default {
|
|
|
methods: {
|
|
|
async getList (init) {
|
|
|
if (init) {
|
|
|
- this.page = 0;
|
|
|
- this.more = true;
|
|
|
+ this.page = 0
|
|
|
+ this.more = true
|
|
|
}
|
|
|
- wx.showNavigationBarLoading();
|
|
|
- const books = await get('/weapp/booklist', {page:this.page});
|
|
|
- if (books.list.length<10 && this.page>0) {
|
|
|
- this.more = false; // 这种情况下 没有更多数据了
|
|
|
+ wx.showNavigationBarLoading()
|
|
|
+ const books = await get('/weapp/booklist', {page: this.page})
|
|
|
+ if (books.list.length < 10 && this.page > 0) {
|
|
|
+ this.more = false // 这种情况下 没有更多数据了
|
|
|
// console.log(this.more);
|
|
|
}
|
|
|
if (init) {
|
|
|
- this.books = books.list;
|
|
|
- wx.stopPullDownRefresh(); // 手动停止下拉刷新
|
|
|
+ this.books = books.list
|
|
|
+ wx.stopPullDownRefresh() // 手动停止下拉刷新
|
|
|
} else {
|
|
|
// 下拉刷新,不能直接覆盖books 而是累加
|
|
|
- this.books = this.books.concat(books.list);
|
|
|
+ this.books = this.books.concat(books.list)
|
|
|
}
|
|
|
- wx.hideNavigationBarLoading(); // 关闭下拉刷新加载
|
|
|
+ wx.hideNavigationBarLoading() // 关闭下拉刷新加载
|
|
|
},
|
|
|
- async getTop() {
|
|
|
- const tops = await get('/weapp/top');
|
|
|
- this.tops = tops.list;
|
|
|
+ async getTop () {
|
|
|
+ const tops = await get('/weapp/top')
|
|
|
+ this.tops = tops.list
|
|
|
}
|
|
|
},
|
|
|
- onPullDownRefresh() {
|
|
|
- this.getList(true);
|
|
|
+ onPullDownRefresh () {
|
|
|
+ this.getList(true)
|
|
|
// console.log('下拉');
|
|
|
- this.getTop();
|
|
|
-
|
|
|
+ this.getTop()
|
|
|
},
|
|
|
- onReachBottom() {
|
|
|
+ onReachBottom () {
|
|
|
// console.log('没有更多了')
|
|
|
if (!this.more) {
|
|
|
// 没有更多了
|
|
|
- return false;
|
|
|
+ return false
|
|
|
}
|
|
|
- this.page++;
|
|
|
+ this.page++
|
|
|
// console.log('上啦加载', this.page)
|
|
|
- this.getList();
|
|
|
+ this.getList()
|
|
|
},
|
|
|
mounted () {
|
|
|
- this.getList(true);
|
|
|
- this.getTop();
|
|
|
+ this.getList(true)
|
|
|
+ this.getTop()
|
|
|
}
|
|
|
}
|
|
|
</script>
|