const app = getApp() Page({ data: { list: [], pagination: { page: 1, pages: 1, count: 1, }, alertPending: false, userInfo: {}, }, onLoad() { app.getTheme().then((res) => { this.setData({ theme: res, }) }) const SystemInfo = app.globalSystemInfo if (SystemInfo) { const { bottom } = SystemInfo.capsulePosition this.setData({ bottom, }) } }, onShow() { app.waitLogin().then((_res) => { app.mpBehavior({ PageName: 'PG_PATIENTDESIREDLIFE' }) this.getList() app.getUserInfo(this, true) }) }, getList(newPage = 1) { const loading = !this.data.list.length wx.ajax({ method: 'GET', url: '?r=igg4/story/story-list', data: { page: newPage, }, loading, }).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, }, }) }) }, handleStar(e) { const { index } = e.currentTarget.dataset const { Id, ComplimentNum } = this.data.list[index] wx.ajax({ method: 'POST', url: '?r=igg4/story/compliment', data: { ContentId: Id, }, }).then(() => { this.setData({ [`list[${index}].ComplimentNum`]: ComplimentNum * 1 + 1, [`list[${index}].IsCompliment`]: 1, }) }) }, onReachBottom() { const { page, pages } = this.data.pagination if (pages > page) { this.getList(page + 1) } }, routerTo(e) { const { url } = e.currentTarget.dataset // let PageName = { // '/pages/storyGuide/index': 'BTN_STORY_SUBMIT', // }[url] // if (PageName) { // app.mpBehavior({ PageName }) // } if (url.includes('/pages/publishStoryDetail/index')) { app.mpBehavior({ PageName: 'BTN_PATIENTDESIRELIFESTORYLIST' }) } if (url === '/pages/storyGuide/index') { app.mpBehavior({ PageName: 'BTN_PATIENTDESIRELIFESHARE' }) } wx.navigateTo({ url, }) }, })