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.

127 lines
3.0 KiB

3 months ago
const app = getApp<IAppOption>()
Page({
data: {
list: [] as any,
unReadCount: 0,
pagination: {
page: 1,
pages: 1,
count: 1,
},
active: '',
search: '',
},
onShow() {
app.waitLogin().then((_res) => {
this.getList()
})
},
handleTapSearch() {
app.mpBehavior({ doctor:true, PageName: 'BTN_DOCTORINTERACTIONSEARCH' })
},
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) {
const { active } = this.data
if (active == '' && newPage == 1) {
app.mpBehavior({ doctor:true, PageName: 'PG_DOCTORINTERACTIONALL' })
}
if (active == '1' && newPage == 1) {
app.mpBehavior({ doctor:true, PageName: 'PG_DOCTORINTERACTIONREAD' })
}
if (active == '2' && newPage == 1) {
app.mpBehavior({ doctor:true, PageName: 'PG_DOCTORINTERACTIONUNREAD' })
}
wx.ajax({
method: 'GET',
url: '?r=igg4/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,
},
})
const header = this.selectComponent('#tabbar')
header.getList() //子组件的方法
})
},
onReachBottom() {
const { page, pages } = this.data.pagination
if (pages > page) {
this.getList(page + 1)
}
},
handleDetail(e) {
app.mpBehavior({ doctor:true, PageName: 'BTN_DOCTORINTERACTIONVIEW' })
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: '#62bed0',
success: (res) => {
if (res.confirm) {
wx.ajax({
method: 'POST',
url: '?r=igg4/doctor/message-interact/read-history',
data: {},
}).then((_res) => {
this.setData({
unReadCount: 0,
list: this.data.list.map((item: any) => {
return {
...item,
msgReadStatus: '1',
}
}),
})
const header = this.selectComponent('#tabbar')
header.getList() //子组件的方法
})
}
},
})
},
})