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.

94 lines
2.0 KiB

1 week ago
const app = getApp<IAppOption>()
Page({
data: {
list: [],
pagination: {
page: 1,
pages: 1,
count: 1,
},
alertPending: false,
userInfo: {},
},
onLoad() {
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',
3 days ago
url: '?r=zd/story/story-list',
1 week ago
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',
3 days ago
url: '?r=zd/story/compliment',
1 week ago
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,
})
},
})