import dayjs from 'dayjs'; const app = getApp(); Page({ data: { list: [] as any[], pagination: { page: 1, pages: 1, count: 1, }, }, onLoad() { app.waitLogin({ type: 2 }).then(() => { this.getList(); }); }, getList(newPage = 1) { wx.ajax({ method: 'GET', url: '?r=xd/doctor/index/get-material-list', data: { page: newPage, }, }).then((res) => { res.list.forEach((item) => { item.PublishTime = dayjs(item.PublishTime).format('YYYY-MM-DD'); }); const list = res.page === 1 ? res.list : [...this.data.list, ...res.list]; this.setData({ total: res.count, list, pagination: { page: res.page, pages: res.pages, count: res.count, }, }); }); }, onReachBottom() { const { page, pages } = this.data.pagination; if (pages > page) { this.getList(page + 1); } }, handleDetail(e) { const { id } = e.currentTarget.dataset; wx.navigateTo({ url: `/pages/informationDetail/index?id=${id}`, }); }, onShareAppMessage(e) { if (e.from === 'button') { const { Title, CoverImgUrl, Id } = e.target.dataset.params; app.mpBehavior({ PositionId: '2', OperateType: '3', OperateId: Id }); return { title: Title, path: `/pages/informationDetail/index?id=${Id}`, imageUrl: CoverImgUrl, }; } return {}; }, }); export {};