const app = getApp() Page({ data: { list: [] as any, unReadCount: 0, pagination: { page: 1, pages: 1, count: 1, }, active: '', search: '', }, onShow() { app.waitLogin().then((_res) => { app.mpBehavior({ doctor: true, PageName: 'PG_DoctorIMList' }) this.getList() }) }, handleTapSearch() { app.mpBehavior({ doctor: true, PageName: 'BTN_DoctorIMListSearch' }) }, handleSearch() { this.setData({ list: [], pagination: { page: 1, pages: 1, count: 1, }, }) this.getList() }, handleNav(e) { const { active } = e.currentTarget.dataset this.setData({ active, }) this.getList() }, getList(newPage = 1) { wx.ajax({ method: 'GET', url: '?r=zd/doctor/message-interact/get-interact-patient-list', data: { page: newPage, search: this.data.search, readStatus: this.data.active, }, }).then((res) => { const list = res.page === 1 ? res.list : [...this.data.list, ...res.list] this.setData({ list, unReadCount: res.unReadCount, 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) { app.mpBehavior({ doctor: true, PageName: 'BTN_DoctorIMList' }) const { index } = e.currentTarget.dataset const { list } = this.data const listItem: any = list[index] wx.navigateTo({ url: `/doctor/pages/d_interactiveDoctor/index?patientId=${listItem.patientId}`, }) }, hancleClaer() { if (Number(this.data.unReadCount) === 0) { wx.showToast({ title: '暂无未读消息', icon: 'none', }) return } wx.showModal({ title: '提示', content: '确认清空消息吗?', confirmColor: '#8c75d0', success: (res) => { if (res.confirm) { wx.ajax({ method: 'POST', url: '?r=zd/doctor/message-interact/read-history', data: {}, }).then((_res) => { this.setData({ unReadCount: 0, list: this.data.list.map((item: any) => { return { ...item, msgReadStatus: '1', } }), }) }) } }, }) }, })