feat: move project
This commit is contained in:
commit
4a940f28ba
97 changed files with 5047 additions and 0 deletions
63
pages/news_list/home.js
Normal file
63
pages/news_list/home.js
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
import R from '../../utils/request';
|
||||
import C from '../../utils/constant';
|
||||
Page({
|
||||
data: {
|
||||
cdnHost: C.cdnHost,
|
||||
list: [],
|
||||
page: 1,
|
||||
listEndText: '',
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.getTabBar().init();
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.init();
|
||||
},
|
||||
init() {
|
||||
this.fetchList(1);
|
||||
},
|
||||
fetchList(page) {
|
||||
R.get('/index.php/api/v1/news_list', { page }).then(({ model }) => {
|
||||
const list = [];
|
||||
model.forEach(item => {
|
||||
list.push({
|
||||
...item,
|
||||
});
|
||||
});
|
||||
if (list.length == 0) {
|
||||
this.setData({ listEndText: '没有更多了' });
|
||||
} else {
|
||||
this.setData({ listEndText: '点击加载更多。。。' });
|
||||
}
|
||||
if (page == 1) {
|
||||
this.setData({ list ,page});
|
||||
} else {
|
||||
const list2 = this.data.list.concat(list);
|
||||
this.setData({ list: list2,page });
|
||||
}
|
||||
});
|
||||
},
|
||||
loadMore() {
|
||||
const { page, listEndText } = this.data;
|
||||
if (listEndText == '点击加载更多。。。') {
|
||||
this.fetchList(page + 1);
|
||||
}
|
||||
},
|
||||
goDetail(e) {
|
||||
const { id } = e.currentTarget.dataset;
|
||||
wx.navigateTo({
|
||||
url: `/pages/detail/detail?id=${id}`
|
||||
});
|
||||
},
|
||||
refresh() {
|
||||
this.fetchList(1);
|
||||
wx.showToast({ icon: 'none', title: '刷新成功' });
|
||||
},
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.init();
|
||||
wx.stopPullDownRefresh();
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue