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.
69 lines
1.5 KiB
69 lines
1.5 KiB
const app = getApp<IAppOption>() |
|
const dayjs = require('dayjs') |
|
|
|
Page({ |
|
data: { |
|
list: [] as any[], |
|
pagination: { |
|
page: 1, |
|
pages: 1, |
|
count: 1, |
|
}, |
|
}, |
|
onLoad() { |
|
app.waitLogin({ type: [2] }).then(() => { |
|
this.getList() |
|
}) |
|
}, |
|
handleDetail(e) { |
|
const { index } = e.currentTarget.dataset |
|
const { Id, Url } = this.data.list[index] |
|
app.oldMpBehavior({ PositionId: '4', OperateType: '1', OperateId: Id }) |
|
if (Url) { |
|
wx.navigateTo({ |
|
url: Url, |
|
fail() { |
|
wx.reLaunch({ |
|
url: Url, |
|
}) |
|
}, |
|
}) |
|
} |
|
}, |
|
getList(newPage = 1) { |
|
wx.ajax({ |
|
method: 'GET', |
|
url: '?r=xd/doctor/index/get-mini-msg-list', |
|
data: { |
|
page: newPage, |
|
}, |
|
}).then((res) => { |
|
const list = res.page === 1 ? res.list : [...this.data.list, ...res.list] |
|
this.setData({ |
|
total: res.count, |
|
list: list.map((item) => { |
|
item.year = dayjs(item.PublishDate).format('YYYY') |
|
item.month = dayjs(item.PublishDate).format('MM') |
|
item.day = dayjs(item.PublishDate).format('DD') |
|
return item |
|
}), |
|
pagination: { |
|
page: res.page, |
|
pages: res.pages, |
|
count: res.count, |
|
}, |
|
}) |
|
wx.setNavigationBarTitle({ |
|
title: `消息(${res.count})`, |
|
}) |
|
}) |
|
}, |
|
onReachBottom() { |
|
const { page, pages } = this.data.pagination |
|
if (pages > page) { |
|
this.getList(page + 1) |
|
} |
|
}, |
|
}) |
|
|
|
export {}
|
|
|