信达小程序
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.

70 lines
1.5 KiB

const app = getApp<IAppOption>()
const dayjs = require('dayjs')
10 months ago
Page({
data: {
list: [] as any[],
pagination: {
page: 1,
pages: 1,
count: 1,
},
},
10 months ago
onLoad() {
9 months ago
app.waitLogin({ type: [2] }).then(() => {
this.getList()
})
10 months ago
},
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,
})
},
})
}
},
10 months ago
getList(newPage = 1) {
wx.ajax({
method: 'GET',
url: '?r=xd/doctor/index/get-mini-msg-list',
10 months ago
data: {
page: newPage,
},
}).then((res) => {
const list = res.page === 1 ? res.list : [...this.data.list, ...res.list]
10 months ago
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
}),
10 months ago
pagination: {
page: res.page,
pages: res.pages,
count: res.count,
},
})
wx.setNavigationBarTitle({
title: `消息(${res.count}`,
})
})
10 months ago
},
onReachBottom() {
const { page, pages } = this.data.pagination
10 months ago
if (pages > page) {
this.getList(page + 1)
10 months ago
}
},
})
10 months ago
export {}