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.
93 lines
2.0 KiB
93 lines
2.0 KiB
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', |
|
url: '?r=zd/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=zd/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, |
|
}) |
|
}, |
|
})
|
|
|