You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
1.5 KiB
79 lines
1.5 KiB
3 weeks ago
|
const app = getApp<IAppOption>();
|
||
|
|
||
|
Page({
|
||
|
data: {
|
||
|
background: 'transparent',
|
||
|
|
||
|
focus: false,
|
||
|
Search: '',
|
||
|
pagination: {
|
||
|
page: 1,
|
||
|
pages: 1,
|
||
|
count: 1,
|
||
|
},
|
||
|
list: [],
|
||
|
},
|
||
|
onLoad() {
|
||
|
app.waitLogin().then(() => {
|
||
|
this.setData({
|
||
|
focus: true,
|
||
|
});
|
||
|
});
|
||
|
},
|
||
|
handleInput() {
|
||
|
this.setData({
|
||
|
'pagination.count': 1,
|
||
|
});
|
||
|
},
|
||
|
handleSearch() {
|
||
|
if (!this.data.Search) {
|
||
|
wx.showToast({
|
||
|
title: '请输入搜索内容',
|
||
|
icon: 'none',
|
||
|
});
|
||
|
return;
|
||
|
}
|
||
|
this.getList();
|
||
|
},
|
||
|
getList(newPage = 1) {
|
||
|
wx.ajax({
|
||
|
method: 'GET',
|
||
|
url: `?r=shizhong/book/search-list`,
|
||
|
data: {
|
||
|
page: newPage,
|
||
|
Search: this.data.Search,
|
||
|
},
|
||
|
}).then((res) => {
|
||
|
const list = res.page === 1 ? res.list : [...this.data.list, ...res.list];
|
||
|
this.setData({
|
||
|
list,
|
||
|
pagination: {
|
||
|
page: res.page,
|
||
|
pages: res.pages,
|
||
|
count: res.count,
|
||
|
},
|
||
|
});
|
||
|
});
|
||
|
},
|
||
|
onReachBottom() {
|
||
|
const { page, pages } = this.data.pagination;
|
||
|
if (pages > page && this.data.list.length) {
|
||
|
this.getList(page + 1);
|
||
|
}
|
||
|
},
|
||
|
handleBack() {
|
||
|
wx.navigateBack();
|
||
|
},
|
||
|
handleDetail(e) {
|
||
|
const { id, cid } = e.currentTarget.dataset;
|
||
|
const backPath = `/pages/article/index?id=${id}&cid=${cid}`;
|
||
|
app.waitLogin(false, true, backPath).then(() => {
|
||
|
wx.navigateTo({
|
||
|
url: backPath,
|
||
|
});
|
||
|
});
|
||
|
},
|
||
|
});
|
||
|
|
||
|
export {};
|