...
|
...
|
@@ -6,11 +6,13 @@ |
|
|
<view class="flexA">
|
|
|
<image :src="proxy.$h.downFile(detailData?.doctor?.avatar)" @click="proxy.$h.previewImage(proxy.$h.downFile(detailData?.doctor?.avatar))" class="imtopinfo-avatar" mode="aspectFill" />
|
|
|
<view class="imtopinfo-username">{{ detailData?.doctor?.nickname }}</view>
|
|
|
<u-count-down :time="countdownTime * 1000" format="HH:mm:ss" @finish="finishCountDownHandler"></u-count-down>
|
|
|
<view class="graytext">后结束问诊</view>
|
|
|
<template v-if="history === 'err'">
|
|
|
<u-count-down :time="countdownTime * 1000" format="HH:mm:ss" @finish="finishCountDownHandler"></u-count-down>
|
|
|
<view class="graytext">后结束问诊</view>
|
|
|
</template>
|
|
|
</view>
|
|
|
<!-- <view class="righttext">已结束</view> -->
|
|
|
<up-button type="info" shape="circle" text="结束问诊" throttleTime="1500" @click="getEndInformationHandler" :customStyle="{ width: '146rpx', height: '66rpx', marginRight: '0rpx' }"></up-button>
|
|
|
<up-button v-if="history === 'err'" type="info" shape="circle" text="结束问诊" throttleTime="1500" @click="getEndInformationHandler" :customStyle="{ width: '146rpx', height: '66rpx', marginRight: '0rpx' }"></up-button>
|
|
|
</view>
|
|
|
<view class="infocard" style="padding: 0; width: 100%">
|
|
|
<view class="flexJ">
|
...
|
...
|
@@ -35,51 +37,70 @@ |
|
|
|
|
|
<view class="TUIChat" v-if="conversationType === 'chat'">
|
|
|
<view class="more-btn" v-if="conversation?.type === 'GROUP'" @click="handleGetProfile">更多</view>
|
|
|
<!-- <view class="more-btn" style="margin-top: 180rpx" @click="handleGetProfile">更多</view> -->
|
|
|
<view class="TUIChat-container">
|
|
|
<scroll-view class="TUIChat-main" scroll-y="true" :scroll-with-animation="true" :refresher-triggered="triggered" :refresher-enabled="true" @refresherrefresh="handleRefresher" :scroll-top="scrollTop">
|
|
|
<view class="TUI-message-list" @touchstart="handleTouchStart" @click="dialogID = ''">
|
|
|
<!-- 用户信息卡片 -->
|
|
|
<!-- <UserInfoCard :detailData="detailData" /> -->
|
|
|
<view style="height: 280rpx"></view>
|
|
|
<view class="loading-text" v-if="isCompleted">没有更多</view>
|
|
|
<view v-for="(item, index) in messages" :key="item.ID" :id="'view' + item.ID">
|
|
|
<view class="time-container" v-if="item.showTime">{{ caculateTimeago(item.time * 1000) }}</view>
|
|
|
<MessageTip v-if="!item.isRevoked && item.type === types.MSG_GRP_TIP" :data="handleTipMessageShowContext(item)" />
|
|
|
<!-- <MessageTip v-if="item.type === types.MSG_GRP_SYS_NOTICE" /> -->
|
|
|
<MessageBubble v-if="!item.isRevoked && item.type !== types.MSG_GRP_TIP" :data="item">
|
|
|
<Message-Operate
|
|
|
v-if="dialogID === item.ID"
|
|
|
:data="item"
|
|
|
class="dialog dialog-item"
|
|
|
:style="{
|
|
|
top: dialogPosition.top + 'px',
|
|
|
right: dialogPosition.right + 'px',
|
|
|
left: dialogPosition.left + 'px'
|
|
|
}"
|
|
|
></Message-Operate>
|
|
|
<MessageText :id="item.flow + '-' + item.ID" v-if="item.type === types.MSG_TEXT" :data="handleTextMessageShowContext(item)" :messageData="item" @longpress="handleItem($event, item)"></MessageText>
|
|
|
<MessageImage :id="item.flow + '-' + item.ID" v-if="item.type === types.MSG_IMAGE" :data="handleImageMessageShowContext(item)" :messageData="item" @longpress="handleItem($event, item)"></MessageImage>
|
|
|
<MessageVideo :id="item.flow + '-' + item.ID" v-if="item.type === types.MSG_VIDEO" :data="handleVideoMessageShowContext(item)" :messageData="item" @longpress="handleItem($event, item)" />
|
|
|
<MessageAudio :id="item.flow + '-' + item.ID" v-if="item.type === types.MSG_AUDIO" :data="handleAudioMessageShowContext(item)" :messageData="item" @longpress="handleItem($event, item)" />
|
|
|
<MessageFace :id="item.flow + '-' + item.ID" v-if="item.type === types.MSG_FACE" :data="handleFaceMessageShowContext(item)" :messageData="item" @longpress="handleItem($event, item)" />
|
|
|
<MessageCustom :id="item.flow + '-' + item.ID" v-if="item.type === types.MSG_CUSTOM" :data="handleCustomMessageShowContext(item)" :messageData="item" @longpress="handleItem($event, item)" />
|
|
|
</MessageBubble>
|
|
|
<MessageRevoked v-if="item.isRevoked" :data="item" @edit="handleEdit(item)" />
|
|
|
</view>
|
|
|
<template v-if="history === 'err'">
|
|
|
<view class="loading-text" v-if="isCompleted">没有更多</view>
|
|
|
<view v-for="(item, index) in messages" :key="item.ID" :id="'view' + item.ID">
|
|
|
<view class="time-container" v-if="item.showTime">{{ caculateTimeago(item.time * 1000) }}</view>
|
|
|
<MessageTip v-if="!item.isRevoked && item.type === types.MSG_GRP_TIP" :data="handleTipMessageShowContext(item)" />
|
|
|
<!-- <MessageTip v-if="item.type === types.MSG_GRP_SYS_NOTICE" /> -->
|
|
|
<MessageBubble v-if="!item.isRevoked && item.type !== types.MSG_GRP_TIP" :data="item">
|
|
|
<Message-Operate
|
|
|
v-if="dialogID === item.ID"
|
|
|
:data="item"
|
|
|
class="dialog dialog-item"
|
|
|
:style="{
|
|
|
top: dialogPosition.top + 'px',
|
|
|
right: dialogPosition.right + 'px',
|
|
|
left: dialogPosition.left + 'px'
|
|
|
}"
|
|
|
></Message-Operate>
|
|
|
<MessageText :id="item.flow + '-' + item.ID" v-if="item.type === types.MSG_TEXT" :data="handleTextMessageShowContext(item)" :messageData="item" @longpress="handleItem($event, item)"></MessageText>
|
|
|
<MessageImage :id="item.flow + '-' + item.ID" v-if="item.type === types.MSG_IMAGE" :data="handleImageMessageShowContext(item)" :messageData="item" @longpress="handleItem($event, item)"></MessageImage>
|
|
|
<MessageVideo :id="item.flow + '-' + item.ID" v-if="item.type === types.MSG_VIDEO" :data="handleVideoMessageShowContext(item)" :messageData="item" @longpress="handleItem($event, item)" />
|
|
|
<MessageAudio :id="item.flow + '-' + item.ID" v-if="item.type === types.MSG_AUDIO" :data="handleAudioMessageShowContext(item)" :messageData="item" @longpress="handleItem($event, item)" />
|
|
|
<MessageFace :id="item.flow + '-' + item.ID" v-if="item.type === types.MSG_FACE" :data="handleFaceMessageShowContext(item)" :messageData="item" @longpress="handleItem($event, item)" />
|
|
|
<MessageCustom :id="item.flow + '-' + item.ID" v-if="item.type === types.MSG_CUSTOM" :data="handleCustomMessageShowContext(item)" :messageData="item" @longpress="handleItem($event, item)" />
|
|
|
</MessageBubble>
|
|
|
<MessageRevoked v-if="item.isRevoked" :data="item" @edit="handleEdit(item)" />
|
|
|
</view>
|
|
|
</template>
|
|
|
<template v-else>
|
|
|
<view v-for="(item, index) in historyList" :key="item.ID" :id="'view' + item.ID">
|
|
|
<!-- <view class="time-container" v-if="item.showTime">{{ caculateTimeago(item.time * 1000) }}</view> -->
|
|
|
<!-- <MessageTip v-if="!item.isRevoked && item.type === types.MSG_GRP_TIP" :data="handleTipMessageShowContext(item)" /> -->
|
|
|
<!-- <MessageTip v-if="item.type === types.MSG_GRP_SYS_NOTICE" /> -->
|
|
|
<MessageBubble :data="item">
|
|
|
<MessageText :id="item.flow + '-' + item.ID" v-if="item.chatType === 1" :data="item" :messageData="item" @longpress="handleItem($event, item)"></MessageText>
|
|
|
<MessageImage :id="item.flow + '-' + item.ID" v-if="item.chatType === 2" :data="item.payload" :messageData="item" @longpress="handleItem($event, item)"></MessageImage>
|
|
|
<MessageVideo :id="item.flow + '-' + item.ID" v-if="item.chatType === 3" :data="item.payload" :messageData="item" @longpress="handleItem($event, item)" />
|
|
|
</MessageBubble>
|
|
|
<MessageRevoked v-if="item.isRevoked" :data="item" @edit="handleEdit(item)" />
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<!-- 对话结束显示 -->
|
|
|
<ConversationEnd v-if="end" />
|
|
|
<ConversationEnd v-if="history === 'success'" />
|
|
|
</view>
|
|
|
</scroll-view>
|
|
|
</view>
|
|
|
<view class="flexA imBtn">
|
|
|
<view @click="sendPrescriptionState = true" v-if="[null, undefined, ''].includes(detailData?.drugId)">发送处方单</view>
|
|
|
<view @click="showPrescriptionDetailState = true">查看处方单</view>
|
|
|
</view>
|
|
|
<TUIChatInput :text="text" :conversationData="conversation" :detailData="detailData"></TUIChatInput>
|
|
|
<template v-if="history === 'err'">
|
|
|
<view class="flexA imBtn">
|
|
|
<view @click="sendPrescriptionState = true" v-if="[null, undefined, ''].includes(detailData?.drugId)">发送处方单</view>
|
|
|
<view @click="showPrescriptionDetailState = true">查看处方单</view>
|
|
|
</view>
|
|
|
<TUIChatInput :text="text" :conversationData="conversation" :detailData="detailData"></TUIChatInput>
|
|
|
</template>
|
|
|
</view>
|
|
|
<view class="TUIChat" v-if="conversationType === 'system'">
|
|
|
<!-- <view class="TUIChat" v-if="conversationType === 'system'">
|
|
|
<MessageSystem :data="messages" :types="types" />
|
|
|
</view>
|
|
|
</view> -->
|
|
|
<u-popup :show="sendPrescriptionState" @close="sendPrescriptionState = false" mode="bottom" closeIconPos="top-right" closeable round="20">
|
|
|
<SendPrescription
|
|
|
:orderId="Event.orderId"
|
...
|
...
|
@@ -127,7 +148,7 @@ |
|
|
<script lang="ts">
|
|
|
import { defineComponent, reactive, toRefs, computed, nextTick, watch, onMounted, shallowRef, getCurrentInstance, ComponentPublicInstance, ref, onUnmounted, onBeforeUnmount } from 'vue'
|
|
|
import { onReady, onLoad, onNavigationBarButtonTap, onUnload } from '@dcloudio/uni-app'
|
|
|
import { updateSend_prescription_form, getConsultation_information_detail, getEndInformation, getReceive_diagnosis } from '@/api'
|
|
|
import { updateSend_prescription_form, getConsultation_information_detail, getEndInformation, getReceive_diagnosis, getOrder_chat } from '@/api'
|
|
|
// 消息元素组件
|
|
|
import MessageBubble from './components/message-elements/message-bubble.vue'
|
|
|
import MessageText from './components/message-elements/message-text.vue'
|
...
|
...
|
@@ -148,6 +169,7 @@ import SendPrescription from '@/components/SendPrescription' |
|
|
import ViewPrescription from '@/components/ViewPrescription'
|
|
|
import store from '../../TUICore/store'
|
|
|
import type { DiaLogEventType, Consultation_information_detailType } from '../../../types'
|
|
|
import { emojiMap } from '../../utils/emojiMap'
|
|
|
import {
|
|
|
handleAvatar,
|
|
|
handleTextMessageShowContext,
|
...
|
...
|
@@ -203,7 +225,14 @@ export default defineComponent({ |
|
|
detailData: {} as Consultation_information_detailType,
|
|
|
countdownTime: 300,
|
|
|
end: false,
|
|
|
showUserCardDetailState: false
|
|
|
showUserCardDetailState: false,
|
|
|
history: 'err',
|
|
|
page: {
|
|
|
pageNo: 1,
|
|
|
pageSize: 15
|
|
|
},
|
|
|
imUserId: '',
|
|
|
historyList: [] as any
|
|
|
})
|
|
|
|
|
|
// 判断当前会话类型:无/系统会话/正常C2C、群聊
|
...
|
...
|
@@ -229,10 +258,14 @@ export default defineComponent({ |
|
|
})
|
|
|
|
|
|
// 获取页面参数
|
|
|
onLoad((options: DiaLogEventType) => {
|
|
|
onLoad(async (options: DiaLogEventType) => {
|
|
|
data.history = uni.getStorageSync('history')
|
|
|
data.imUserId = uni.getStorageSync('ImUserId')
|
|
|
console.log(uni.getStorageSync('history'), '聊天界面onload获取是否为历史记录')
|
|
|
console.log(options, '聊天界面onload参数')
|
|
|
data.Event = options
|
|
|
getDetailHandler()
|
|
|
|
|
|
// uni.setNavigationBarTitle({
|
|
|
// // title: options && options.conversationName
|
|
|
// title: '自定义用户名'
|
...
|
...
|
@@ -312,19 +345,93 @@ export default defineComponent({ |
|
|
})
|
|
|
}
|
|
|
})
|
|
|
|
|
|
const imageFormatMap = new Map([
|
|
|
['jpg', 1],
|
|
|
['gif', 2],
|
|
|
['png', 3],
|
|
|
['bmp', 4]
|
|
|
])
|
|
|
let stateInterval = setInterval(async () => {
|
|
|
const { result }: { result: Consultation_information_detailType } = await getConsultation_information_detail({ id: data.Event.orderId })
|
|
|
|
|
|
if (result?.orderState !== 30) proxy.$h.timeCallBack('对方已结束问诊即将返回', 2000)
|
|
|
// const { result }: { result: Consultation_information_detailType } = await getConsultation_information_detail({ id: data.Event.orderId })
|
|
|
// if (result?.orderState !== 30) proxy.$h.timeCallBack('对方已结束问诊即将返回', 2000)
|
|
|
}, 3000)
|
|
|
|
|
|
const getDetailHandler = async () => {
|
|
|
const { result: timeData }: { result: { countdownTime: number } } = await getReceive_diagnosis({ id: data.Event.orderId })
|
|
|
|
|
|
data.countdownTime = timeData.countdownTime
|
|
|
|
|
|
const { result }: { result: Consultation_information_detailType } = await getConsultation_information_detail({ id: data.Event.orderId })
|
|
|
|
|
|
data.detailData = result
|
|
|
|
|
|
if (data.history === 'success') getOrder_chatHandler(true)
|
|
|
}
|
|
|
|
|
|
const getOrder_chatHandler = async refresh => {
|
|
|
refresh ? ((data.page.pageNo = 1), data.historyList.splice(0)) : data.page.pageNo++
|
|
|
|
|
|
const { result } = await getOrder_chat({ ...data.page, id: data.detailData.userId })
|
|
|
|
|
|
const regex = /(\[[^\[\]]+\])|([^\[\]]+)/g
|
|
|
result.records = result.records
|
|
|
.map(item => ({
|
|
|
...item,
|
|
|
imContent: JSON.parse(item.imContent)
|
|
|
}))
|
|
|
.map(item => {
|
|
|
let msgContent = item.imContent?.msgBody?.[0]?.msgContent
|
|
|
const text = msgContent?.text?.match(regex).map(item => ({
|
|
|
text: item,
|
|
|
name: /^\[.+?\]$/.test(item) ? '' : 'text',
|
|
|
src: `https://web.sdk.qcloud.com/im/assets/emoji/${emojiMap[item]}`
|
|
|
}))
|
|
|
let url = ''
|
|
|
let snapshotUrl = ''
|
|
|
let src = ''
|
|
|
let imageFormat: string | number = ''
|
|
|
let flow = ''
|
|
|
{
|
|
|
if (item.chatType == 1) {
|
|
|
flow = item.imContent.from_Account == data.imUserId ? 'out' : 'in'
|
|
|
} else if (item.chatType == 2) {
|
|
|
url = msgContent?.imageInfoArray?.[0]?.uRL
|
|
|
const match = url.match(/\.(\w+)(\?.*)?$/)
|
|
|
imageFormat = match ? imageFormatMap.get(match[1])! : ''
|
|
|
} else if (item.chatType == 3) {
|
|
|
url = msgContent?.videoUrl
|
|
|
snapshotUrl = msgContent?.thumbUrl
|
|
|
}
|
|
|
}
|
|
|
return {
|
|
|
...item,
|
|
|
flow,
|
|
|
url,
|
|
|
text,
|
|
|
snapshotUrl,
|
|
|
src,
|
|
|
payload: {
|
|
|
info: msgContent?.imageInfoArray?.map(item => ({
|
|
|
...item,
|
|
|
url: item.uRL
|
|
|
})),
|
|
|
imageFormat
|
|
|
},
|
|
|
ID: item.id
|
|
|
}
|
|
|
})
|
|
|
.reverse()
|
|
|
|
|
|
if (result.records.length) {
|
|
|
result.records.map((_: any) => data.historyList.push(_))
|
|
|
|
|
|
data.historyList = result.records
|
|
|
|
|
|
console.log(data.historyList, '历史记录')
|
|
|
|
|
|
return
|
|
|
}
|
|
|
uni.$u.toast('没有更多数据了')
|
|
|
}
|
|
|
|
|
|
const finishCountDownHandler = async () => {
|
...
|
...
|
@@ -404,11 +511,16 @@ export default defineComponent({ |
|
|
|
|
|
const handleRefresher = () => {
|
|
|
data.triggered = true
|
|
|
if (!data.isCompleted) {
|
|
|
TUIServer.getHistoryMessageList().then(res => {
|
|
|
data.triggered = false
|
|
|
data.isCompleted = res.isCompleted
|
|
|
})
|
|
|
if (data.history === 'err') {
|
|
|
if (!data.isCompleted) {
|
|
|
TUIServer.getHistoryMessageList().then(res => {
|
|
|
data.triggered = false
|
|
|
data.isCompleted = res.isCompleted
|
|
|
})
|
|
|
}
|
|
|
} else if (data.history === 'success') {
|
|
|
console.log('下拉刷洗执行了')
|
|
|
getOrder_chatHandler(false)
|
|
|
}
|
|
|
setTimeout(() => {
|
|
|
data.triggered = false
|
...
|
...
|
@@ -507,7 +619,8 @@ export default defineComponent({ |
|
|
getDetailHandler,
|
|
|
getEndInformationHandler,
|
|
|
computedTotalHandler,
|
|
|
finishCountDownHandler
|
|
|
finishCountDownHandler,
|
|
|
getOrder_chatHandler
|
|
|
}
|
|
|
}
|
|
|
})
|
...
|
...
|
|