|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
|
|
|
|
|
|
const app = getApp<IAppOption>()
|
|
|
|
|
|
|
|
|
|
interface IMessageItem {
|
|
|
|
|
msgId: string
|
|
|
|
|
msgContentType: '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' // 1:文本 2: 出诊时间 3: adl卡片 4: 语音 5: 欢迎语 6:补充真实姓名 7: 提醒完善信息 8: 复诊卡片 9:患者恢复复诊消息
|
|
|
|
|
msgContent: any
|
|
|
|
|
msgVisitTime: string
|
|
|
|
|
msgVisitTimeType?: string
|
|
|
|
|
msgFromType: '1' | '2' // 1: 患者 2: 医生
|
|
|
|
|
isPlay?: boolean
|
|
|
|
|
msgCreateTime: string // 消息创建时间
|
|
|
|
|
msgCreateTimeName?: string // 消息创建时间
|
|
|
|
|
showTime?: boolean
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface Item {
|
|
|
|
|
wordId: string
|
|
|
|
|
word: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
data: {
|
|
|
|
|
doctor: {} as any,
|
|
|
|
|
|
|
|
|
|
patientId: '',
|
|
|
|
|
messageListShow: false,
|
|
|
|
|
patientDetail: {},
|
|
|
|
|
|
|
|
|
|
isLoad: false,
|
|
|
|
|
isFinish: false,
|
|
|
|
|
scrollTop: 0,
|
|
|
|
|
scrollIntoView: '',
|
|
|
|
|
messageList: [] as IMessageItem[],
|
|
|
|
|
nextMsgId: '',
|
|
|
|
|
|
|
|
|
|
wordIndex: 0,
|
|
|
|
|
wordList: [] as Item[],
|
|
|
|
|
|
|
|
|
|
week: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
|
|
|
|
|
timeDay: { 1: '上午', 2: '下午' },
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
innerAudioContext: null as WechatMiniprogram.InnerAudioContext | null,
|
|
|
|
|
|
|
|
|
|
onLoad(options) {
|
|
|
|
|
this.innerAudioContext = wx.createInnerAudioContext({
|
|
|
|
|
useWebAudioImplement: true,
|
|
|
|
|
})
|
|
|
|
|
this.setData({
|
|
|
|
|
patientId: options.patientId,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
onShow() {
|
|
|
|
|
app.waitLogin({ type: [2] }).then((_res) => {
|
|
|
|
|
app.mpBehavior({ doctor:true, PageName: 'PG_DoctorIMDetail' })
|
|
|
|
|
this.getDoctorDetail()
|
|
|
|
|
this.getPatientDetail()
|
|
|
|
|
this.getMessageList()
|
|
|
|
|
this.getWordList()
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
onUnload() {
|
|
|
|
|
if (this.innerAudioContext) {
|
|
|
|
|
this.innerAudioContext.stop()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getDoctorDetail() {
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: '?r=zd/doctor/account/info',
|
|
|
|
|
data: {},
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
this.setData({
|
|
|
|
|
doctor: res.doctor,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getPatientDetail() {
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: '?r=zd/doctor/message-interact/get-patient-info',
|
|
|
|
|
data: {
|
|
|
|
|
patientId: this.data.patientId,
|
|
|
|
|
},
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
if (res.LastAdlTime) {
|
|
|
|
|
res.LastAdlTimeName = dayjs(res.LastAdlTime).from(dayjs().format('YYYY-MM-DD')).replace(' ', '')
|
|
|
|
|
}
|
|
|
|
|
this.setData({
|
|
|
|
|
patientDetail: res,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getMessageList() {
|
|
|
|
|
if (this.data.isLoad || this.data.isFinish) return
|
|
|
|
|
this.setData({
|
|
|
|
|
isLoad: true,
|
|
|
|
|
})
|
|
|
|
|
const nextMsgId = this.data.nextMsgId
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: '?r=zd/doctor/message-interact/doctor-get-message-list',
|
|
|
|
|
data: {
|
|
|
|
|
nextMsgId,
|
|
|
|
|
patientId: this.data.patientId,
|
|
|
|
|
},
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
res.messageList.map((item) => {
|
|
|
|
|
if (item.msgContentType === '4') {
|
|
|
|
|
item.msgContent = JSON.parse(item.msgContent)
|
|
|
|
|
}
|
|
|
|
|
if (item.msgContentType === '2') {
|
|
|
|
|
item.msgVisitTime = item.msgVisitTimeType == 2 ? item.msgVisitTime : JSON.parse(item.msgVisitTime)
|
|
|
|
|
}
|
|
|
|
|
if (item.msgContentType === '5') {
|
|
|
|
|
item.welcomeMsg = JSON.parse(item.welcomeMsg)
|
|
|
|
|
}
|
|
|
|
|
if (item.msgContentType === '9') {
|
|
|
|
|
item.ReVisitInfo = JSON.parse(item.ReVisitInfo)
|
|
|
|
|
item.ReVisitInfo.visitDateName = dayjs(item.ReVisitInfo.visitDate).format('YYYY年M月DD日')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return item
|
|
|
|
|
})
|
|
|
|
|
if (!this.data.nextMsgId && !res.messageList.length) {
|
|
|
|
|
res.messageList = [
|
|
|
|
|
{
|
|
|
|
|
msgId: '0',
|
|
|
|
|
msgContentType: '0',
|
|
|
|
|
msgContent: '',
|
|
|
|
|
msgVisitTime: '',
|
|
|
|
|
msgFromType: '2',
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
this.setData({
|
|
|
|
|
messageList: [...res.messageList.reverse(), ...this.data.messageList],
|
|
|
|
|
nextMsgId: res.nextMsgId,
|
|
|
|
|
unReadCount: res.unReadCount,
|
|
|
|
|
firstNotReadMsgId: res.firstNotReadMsgId,
|
|
|
|
|
isVisitAdl: res.isVisitAdl,
|
|
|
|
|
adlMsgId: res.adlMsgId,
|
|
|
|
|
isLoad: false,
|
|
|
|
|
isFinish: nextMsgId === res.nextMsgId,
|
|
|
|
|
})
|
|
|
|
|
this.filterCreateTime()
|
|
|
|
|
if (!nextMsgId) {
|
|
|
|
|
this.handleView()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
scrolltoupper(e) {
|
|
|
|
|
if (e.detail.direction === 'top') {
|
|
|
|
|
this.getMessageList()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getWordList() {
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: '?r=zd/doctor/message-interact/get-common-word-list',
|
|
|
|
|
data: {},
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
this.setData({
|
|
|
|
|
wordList: res,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleSendDate() {
|
|
|
|
|
app.mpBehavior({ doctor:true, PageName: 'BTN_DoctorIMDetailClinicHours' })
|
|
|
|
|
const {
|
|
|
|
|
messageList,
|
|
|
|
|
doctor: { Clinic },
|
|
|
|
|
} = this.data
|
|
|
|
|
if (!Clinic || (Array.isArray(Clinic) && !Clinic.length)) {
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title: '完善出诊时间?',
|
|
|
|
|
content: '您还没有录入出诊时间',
|
|
|
|
|
confirmText: '录入',
|
|
|
|
|
confirmColor: '#8c75d0',
|
|
|
|
|
success: (res) => {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/d_userInfo/index',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title: '提示',
|
|
|
|
|
content: '将您的出诊时间发送给患者?',
|
|
|
|
|
confirmColor: '#8c75d0',
|
|
|
|
|
success: (res) => {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
this.setData({
|
|
|
|
|
messageList: [
|
|
|
|
|
...messageList,
|
|
|
|
|
{
|
|
|
|
|
msgId: '',
|
|
|
|
|
msgContentType: '2',
|
|
|
|
|
msgContent: '',
|
|
|
|
|
msgVisitTime: this.data.doctor.Clinic,
|
|
|
|
|
msgVisitTimeType: this.data.doctor.ClinicType,
|
|
|
|
|
msgFromType: '2',
|
|
|
|
|
msgCreateTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
this.filterCreateTime()
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'POST',
|
|
|
|
|
url: '?r=zd/doctor/message-interact/send-visit-time',
|
|
|
|
|
data: {
|
|
|
|
|
patientId: this.data.patientId,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
this.handleView()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleSendShow() {
|
|
|
|
|
app.mpBehavior({ doctor:true, PageName: 'BTN_DoctorIMDetailSendMessage' })
|
|
|
|
|
this.setData({
|
|
|
|
|
messageListShow: true,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handlePopupMessageClose() {
|
|
|
|
|
this.setData({
|
|
|
|
|
messageListShow: false,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleWord(e) {
|
|
|
|
|
const { index } = e.currentTarget.dataset
|
|
|
|
|
this.setData({
|
|
|
|
|
wordIndex: index,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleSendWord() {
|
|
|
|
|
const { messageList, wordList, wordIndex } = this.data
|
|
|
|
|
const { wordId, word } = wordList[wordIndex]
|
|
|
|
|
this.setData({
|
|
|
|
|
messageList: [
|
|
|
|
|
...messageList,
|
|
|
|
|
{
|
|
|
|
|
msgId: '',
|
|
|
|
|
msgContentType: '1',
|
|
|
|
|
msgContent: word,
|
|
|
|
|
msgVisitTime: '',
|
|
|
|
|
msgFromType: '2',
|
|
|
|
|
msgCreateTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
this.filterCreateTime()
|
|
|
|
|
this.handlePopupMessageClose()
|
|
|
|
|
this.handleView()
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'POST',
|
|
|
|
|
url: '?r=zd/doctor/message-interact/send-word-message',
|
|
|
|
|
data: {
|
|
|
|
|
patientId: this.data.patientId,
|
|
|
|
|
wordId,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleSendUserConform(e) {
|
|
|
|
|
const { id } = e.currentTarget.dataset
|
|
|
|
|
const title = {
|
|
|
|
|
6: '发送后患者将收到补充姓名通知',
|
|
|
|
|
7: '发送后患者将收到完善信息通知',
|
|
|
|
|
}[id]
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title,
|
|
|
|
|
confirmColor: '#8c75d0',
|
|
|
|
|
success: (res) => {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
this.handleSendUser(id)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleSendUser(id) {
|
|
|
|
|
const { messageList } = this.data
|
|
|
|
|
const content = {
|
|
|
|
|
6: '请完善您的真实姓名,以便我清楚了解您的病情',
|
|
|
|
|
7: '请完善您的个人信息,以便我清楚了解您的病情',
|
|
|
|
|
}[id]
|
|
|
|
|
this.setData({
|
|
|
|
|
messageList: [
|
|
|
|
|
...messageList,
|
|
|
|
|
{
|
|
|
|
|
msgId: '',
|
|
|
|
|
msgContentType: id,
|
|
|
|
|
msgContent: content,
|
|
|
|
|
msgVisitTime: '',
|
|
|
|
|
msgFromType: '2',
|
|
|
|
|
msgCreateTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
this.filterCreateTime()
|
|
|
|
|
this.handlePopupMessageClose()
|
|
|
|
|
this.handleView()
|
|
|
|
|
const url = {
|
|
|
|
|
6: '?r=zd/doctor/message-interact/send-remind-name',
|
|
|
|
|
7: '?r=zd/doctor/message-interact/send-remind-init',
|
|
|
|
|
}[id]
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'POST',
|
|
|
|
|
url,
|
|
|
|
|
data: {
|
|
|
|
|
patientId: this.data.patientId,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
formatTime(date: string) {
|
|
|
|
|
let msgCreateTimeName = ''
|
|
|
|
|
if (dayjs().format('YYYY-MM-DD') === dayjs(date).format('YYYY-MM-DD')) {
|
|
|
|
|
msgCreateTimeName = dayjs(date).format('HH:mm')
|
|
|
|
|
} else if (dayjs().format('YYYY-MM-DD') === dayjs(date).add(1, 'day').format('YYYY-MM-DD')) {
|
|
|
|
|
msgCreateTimeName = `昨天 ${dayjs(date).format('HH:mm')}`
|
|
|
|
|
} else if (dayjs().diff(date, 'day') < 7) {
|
|
|
|
|
msgCreateTimeName = dayjs(date).format(`dddd HH:mm`)
|
|
|
|
|
} else {
|
|
|
|
|
msgCreateTimeName = dayjs(date).format('YYYY-MM-DD HH:mm')
|
|
|
|
|
}
|
|
|
|
|
return msgCreateTimeName
|
|
|
|
|
},
|
|
|
|
|
filterCreateTime() {
|
|
|
|
|
const gapTime = 5 * 60 * 1000
|
|
|
|
|
const { messageList } = this.data
|
|
|
|
|
|
|
|
|
|
let preTime = 0
|
|
|
|
|
messageList.forEach((item, index) => {
|
|
|
|
|
if (index === 0) {
|
|
|
|
|
item.showTime = true
|
|
|
|
|
preTime = dayjs(item.msgCreateTime).valueOf()
|
|
|
|
|
item.msgCreateTimeName = this.formatTime(item.msgCreateTime)
|
|
|
|
|
} else {
|
|
|
|
|
const curTime = dayjs(item.msgCreateTime).valueOf()
|
|
|
|
|
if (curTime - preTime > gapTime) {
|
|
|
|
|
item.showTime = true
|
|
|
|
|
item.msgCreateTimeName = this.formatTime(item.msgCreateTime)
|
|
|
|
|
preTime = dayjs(item.msgCreateTime).valueOf()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
this.setData({
|
|
|
|
|
messageList,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleView(index = -1) {
|
|
|
|
|
this.setData({
|
|
|
|
|
scrollIntoView: index > -1 ? `view${index}` : `place`,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handlePatientDetail() {
|
|
|
|
|
app.mpBehavior({ doctor:true, PageName: 'BTN_DoctorIMDetailPatient' })
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: `/pages/d_patientDetail/index?id=${this.data.patientId}`,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleAudio(e) {
|
|
|
|
|
const { index } = e.currentTarget.dataset
|
|
|
|
|
const { messageList } = this.data
|
|
|
|
|
const messageItem = messageList[index]
|
|
|
|
|
const { url } = messageItem.msgContent[0]
|
|
|
|
|
if (this.innerAudioContext) {
|
|
|
|
|
if (messageItem.isPlay) {
|
|
|
|
|
this.innerAudioContext.stop()
|
|
|
|
|
messageItem.isPlay = false
|
|
|
|
|
this.setData({
|
|
|
|
|
messageList,
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.innerAudioContext.stop()
|
|
|
|
|
this.innerAudioContext.src = url
|
|
|
|
|
this.innerAudioContext.play()
|
|
|
|
|
messageItem.isPlay = true
|
|
|
|
|
this.innerAudioContext.onEnded(() => {
|
|
|
|
|
messageItem.isPlay = false
|
|
|
|
|
this.setData({
|
|
|
|
|
messageList,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
this.innerAudioContext.onStop(() => {
|
|
|
|
|
messageItem.isPlay = false
|
|
|
|
|
this.setData({
|
|
|
|
|
messageList,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
this.setData({
|
|
|
|
|
messageList,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handleAdl() {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '患者点击此按钮可进入ADL测评页面',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleReferral() {
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title: '',
|
|
|
|
|
content: '您将给患者发送复诊时间填写卡片?',
|
|
|
|
|
confirmText: '发送',
|
|
|
|
|
confirmColor: '#8c75d0',
|
|
|
|
|
success: (res) => {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'POST',
|
|
|
|
|
url: '?r=zd/doctor/message-interact/send-re-visit',
|
|
|
|
|
data: {
|
|
|
|
|
patientId: this.data.patientId,
|
|
|
|
|
},
|
|
|
|
|
}).then(() => {
|
|
|
|
|
this.setData({
|
|
|
|
|
messageList: [
|
|
|
|
|
...this.data.messageList,
|
|
|
|
|
{
|
|
|
|
|
msgId: '',
|
|
|
|
|
msgContentType: '8',
|
|
|
|
|
msgVisitTime: '',
|
|
|
|
|
msgContent: '',
|
|
|
|
|
msgFromType: '2',
|
|
|
|
|
msgCreateTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
this.handleView()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleBack() {
|
|
|
|
|
wx.navigateBack()
|
|
|
|
|
},
|
|
|
|
|
})
|