import dayjs from 'dayjs' const app = getApp() Page({ data: { active: 0, statType: '', navTitle: '', list: [] as any[], total: 0, pagination: { page: 1, pages: 1, count: 1, }, }, onLoad(options) { this.setData({ statType: options.type, navTitle: options.name || '患者列表', }) app.waitLogin().then((_res) => { this.getList() }) }, handleReset() { this.getList() }, handleSearch() { this.getList() }, getList(newPage = 1) { const params = { statType: this.data.statType, } wx.ajax({ method: 'GET', url: '?r=igg4/doctor/patient/get-stat-patient-list', data: { page: newPage, ...params, }, }).then((res) => { res.list.forEach((item) => { if (item.LastAdlTime) { item.LastAdlTimeName = dayjs(item.LastAdlTime).from(dayjs().format('YYYY-MM-DD')).replace(' ', '') } }) const list = res.page === 1 ? res.list : [...this.data.list, ...res.list] this.setData({ total: res.count, list, pagination: { page: res.page, pages: res.pages, count: res.count, }, }) }) }, onReachBottom() { const { page, pages } = this.data.pagination if (pages > page) { this.getList(page + 1) } }, handleDetail(e: any) { const { index } = e.currentTarget.dataset const item = this.data.list[index] wx.navigateTo({ url: `/doctor/pages/d_patientDetail/index?id=${item.PatientId}`, }) }, handleSend(e) { const { index } = e.currentTarget.dataset wx.navigateTo({ url: `/doctor/pages/d_interactiveDoctor/index?patientId=${this.data.list[index].PatientId}`, }) }, handleSendGroup() { wx.navigateTo({ url: '/doctor/pages/d_taskList/index', }) }, onShareAppMessage() { return { title: '愈见昕生,重拾生活掌控感!', path: '/doctor/pages/d_patient/index', } }, handleBack() { wx.navigateBack() }, })