index.vue
26.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
<template>
<u-sticky>
<u-navbar :title="navbarTitle" :autoBack="true" bgColor="#fff" placeholder safeAreaInsetTop :titleStyle="{ color: '#000' }" leftIconColor="#000"></u-navbar>
<view class="imtopinfo">
<view class="flexJ">
<view class="flexA">
<image :src="![null, undefined, ''].includes(detailData?.doctor?.avatar) ? proxy.$h.downFile(detailData?.doctor?.avatar) : '/static/images/mAvatar.png'" class="imtopinfo-avatar" mode="aspectFill" />
<view class="imtopinfo-username">{{ detailData?.doctor?.nickname }}</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 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">
<view>
<view class="flexA" style="margin-bottom: 20rpx">
<view class="infocard-username">问诊信息</view>
<view class="blueTag1">{{ proxy.$h.optObjectValue('consultationWay', detailData.consultationWay) || '未设置' }}</view>
</view>
<view class="infocard-infoitem Zindex">
<text class="gray">宠物信息:</text>
{{ detailData?.petName }}/{{ detailData?.petClass || '品种未知' }}/{{ detailData?.age || '年龄未知' }}/ {{ proxy.$h.optObjectValue('petSex', detailData?.petSex) || '性别未知' }}
</view>
</view>
<up-button color="#05B8D2" shape="circle" text="查看详情" throttleTime="1500" plain @click="showUserCardDetailState = true" :customStyle="{ width: '146rpx', height: '66rpx', marginRight: '0rpx' }"></up-button>
</view>
</view>
</view>
</u-sticky>
<!-- #ifdef MP-WEIXIN -->
<tuicallkit ref="TUICallKit"></tuicallkit>
<!-- #endif -->
<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" :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: 390rpx"></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)" />
</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">
<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" :messageData="item" @longpress="handleItem($event, item)" />
</MessageBubble>
<MessageRevoked v-if="item.isRevoked" :data="item" @edit="handleEdit(item)" />
</view>
</template>
<!-- 对话结束显示 -->
<ConversationEnd v-if="history === 'success'" />
</view>
</scroll-view>
</view>
<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" @scrollbottomHandler="scrollbottomHandler" @sendMessagehandler="handleSendTextMessage"></TUIChatInput>
</template>
</view>
<!-- <view class="TUIChat" v-if="conversationType === 'system'">
<MessageSystem :data="messages" :types="types" />
</view> -->
<u-popup :show="sendPrescriptionState" @close="sendPrescriptionState = false" mode="bottom" closeIconPos="top-right" closeable round="20">
<SendPrescription
:orderId="Event.orderId"
:detailData="detailData"
@closeSendPrescriptionHandler="
() => {
sendPrescriptionState = false
getDetailHandler()
}
"
:isSend="true"
/>
</u-popup>
<!-- <u-modal :show="showPrescriptionDetailState" :title="`处方单详情`" @confirm="showPrescriptionDetailState = false">
<ViewPrescription :orderId="Event.orderId" @click="showPrescriptionDetailState = false" />
</u-modal> -->
<u-modal :show="showUserCardDetailState" :title="``" :showConfirmButton="false" closeOnClickOverlay @close="showUserCardDetailState = false">
<view class="slot-content" @click="showUserCardDetailState = false">
<view class="text mb24">问诊类型:{{ proxy.$h.optObjectValue('consultationWay', detailData.consultationWay) || '未设置' }}</view>
<view class="text mb24">宠物品种:{{ detailData?.petClass }}</view>
<view class="text mb24">年龄:{{ detailData?.age }}</view>
<view class="text mb24">性别:{{ proxy.$h.optObjectValue('petSex', detailData?.petSex) || '性别未知' }}</view>
<view class="text mb24">是否绝育:{{ proxy.$h.optObjectValue('isSterilization', detailData?.isSterilization) || '未知' }}</view>
<view class="text mb24">体重:{{ detailData?.weight ? detailData?.weight + 'kg' : '体重未知' }}</view>
<view class="text mb24">免疫情况:{{ proxy.$h.optObjectValue('immuneStatus', detailData?.immuneStatus, 4) }}</view>
<view class="text mb24">洗澡频率:{{ proxy.$h.optObjectValue('batheFrequency', detailData?.batheFrequency, 2) }}</view>
<view class="text mb24">饲料类型:{{ proxy.$h.optObjectValue('feedType', detailData?.feedType, 1) }}</view>
<view class="text mb24">
症状类型:
<template v-if="![null, '', undefined].includes(detailData?.symptom)">
<template v-for="(_, index) in detailData?.symptom.split(',')">{{ proxy.$h.optObjectValue('symptom', _) || '' }}{{ index !== (detailData?.symptom.split(',').length as number) - 1 ? ',' : '' }}</template>
</template>
</view>
<view class="text mb24">症状描述: {{ detailData.supplement }}</view>
<view class="text mb24">
症状照片:
<view class="flexW" v-if="detailData?.image?.length">
<image v-for="_ in detailData.image?.split(',')" :src="proxy.$h.downFile(_)" class="infocard-itemimg" mode="aspectFill" @click.stop="proxy.$h.previewImage(proxy.$h.downFile(_))" />
</view>
</view>
</view>
</u-modal>
<u-popup :show="showPrescriptionDetailState" @close="showPrescriptionDetailState = false" mode="bottom" closeIconPos="top-right" closeable round="20">
<Prescription :showTopState="false" :PrescriptionDetail="PrescriptionDetail" bg="linear-gradient(188deg, #E0FFF4 5.54%, #FFF 24.89%)" :title="`${detailData?.user?.nickname}的处方单`" :isRenew="'err'" :showStep="`err`" />
</u-popup>
</template>
<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 { getConsultation_information_detail, getEndInformation, getReceive_diagnosis, getOrder_chat, getPrescription_detail_information } from '@/api'
// 消息元素组件
import MessageBubble from './components/message-elements/message-bubble.vue'
import MessageText from './components/message-elements/message-text.vue'
import MessageImage from './components/message-elements/message-image.vue'
import MessageOperate from './components/message-elements/message-operate.vue'
import MessageVideo from './components/message-elements/message-video.vue'
import MessageAudio from './components/message-elements/message-audio.vue'
import MessageFace from './components/message-elements/message-face.vue'
import MessageCustom from './components/message-elements/message-custom.vue'
import MessageTip from './components/message-elements/message-tip.vue'
import MessageRevoked from './components/message-elements/message-revoked.vue'
import MessageSystem from './components/message-elements/message-system.vue'
// 底部消息发送组件
import TUIChatInput from './components/message-input'
import ConversationEnd from '@/components/ConversationEnd'
import SendPrescription from '@/components/SendPrescription'
import ViewPrescription from '@/components/ViewPrescription'
import Prescription from '@/pages2/order/com/Prescription.vue'
import store from '../../TUICore/store'
import type { DiaLogEventType, Consultation_information_detailType, PrescriptionDetailType } from '../../../types'
import { emojiMap } from '../../utils/emojiMap'
import {
handleTextMessageShowContext,
handleImageMessageShowContext,
handleVideoMessageShowContext,
handleAudioMessageShowContext,
handleFileMessageShowContext,
handleFaceMessageShowContext,
handleLocationMessageShowContext,
handleMergerMessageShowContext,
handleTipMessageShowContext,
handleCustomMessageShowContext
} from '../../utils/untis'
import { caculateTimeago } from '../../utils/date'
import { TUIChatServer } from '../../TUICore/server'
export default defineComponent({
name: 'TUIChat',
components: {
MessageText,
MessageImage,
MessageVideo,
MessageAudio,
MessageFace,
MessageCustom,
MessageBubble,
MessageTip,
MessageRevoked,
MessageSystem,
TUIChatInput,
MessageOperate,
ConversationEnd,
SendPrescription,
ViewPrescription,
Prescription
},
setup(props) {
const { proxy } = getCurrentInstance() as { proxy: ComponentPublicInstance }
const timStore = store.state.timStore
uni.$TUIKit.TUIChatServer = new TUIChatServer()
const TUICallKit = shallowRef(null)
const TUIServer = uni.$TUIKit.TUIChatServer
const left: number | null = 0
const right: number | null = 0
const defaultDialogPosition = {
top: -70,
left,
right
}
const data = reactive({
messageList: computed(() => timStore.messageList),
conversation: computed(() => timStore.conversation),
triggered: false,
scrollTop: 999,
text: '',
types: uni.$TIM.TYPES,
currentMessage: {},
dialogID: '',
forwardStatus: false,
imageFlag: false,
isCompleted: false,
oldMessageTime: 0,
dialogPosition: defaultDialogPosition,
sendPrescriptionState: false,
showPrescriptionDetailState: false,
Event: {} as DiaLogEventType,
detailData: {} as Consultation_information_detailType,
countdownTime: 300,
end: false,
showUserCardDetailState: false,
history: 'err',
page: {
pageNo: 1,
pageSize: 15
},
imUserId: '',
historyList: [] as any,
navbarTitle: '',
PrescriptionDetail: {}
})
// 判断当前会话类型:无/系统会话/正常C2C、群聊
const conversationType = computed(() => {
const conversation: any = data.conversation
if (!conversation?.conversationID) {
return ''
}
if (conversation?.type === uni.$TIM.TYPES.CONV_SYSTEM) {
return 'system'
}
return 'chat'
})
// 不展示已删除消息
const messages = computed(() => {
if (data.messageList.length > 0) {
data.oldMessageTime = data.messageList[0].time
return data.messageList.filter((item: any) => {
return !item.isDeleted
})
}
})
// 获取页面参数
onLoad(async (options: DiaLogEventType) => {
data.history = uni.getStorageSync('history')
data.imUserId = uni.getStorageSync('ImUserId')
data.Event = options
getDetailHandler()
data.navbarTitle = { err: '问诊中', success: '问诊记录' }[data.history] as string
setTimeout(() => {
data.scrollTop = 10000
}, 1300)
// uni.setNavigationBarTitle({
// // title: options && options.conversationName
// title: '自定义用户名'
// })
})
onBeforeUnmount(() => {
uni.$TUIKit.logout()
})
onUnmounted(() => {})
onUnload(() => {
clearInterval(stateInterval)
// uni.$TUIKit.TUIConversationServer.destroyed()
// #ifdef MP-WEIXIN
// 回收 TUICallKit
uni.$TUICallKit.value !== null && uni.$TUICallKit.value.destroyed()
// #endif
TUIServer.destroyed()
})
// 监听数据渲染,展示最新一条消息
watch(messages, (newVal: any, oldVal: any) => {
// 下拉刷新不滑动 todo 优化
nextTick(() => {
// const newLastMessage = newVal[newVal.length - 1]
// const oldLastMessage = oldVal ? oldVal[oldVal.length - 1] : {}
// data.oldMessageTime = messages.value[0].time
// handleShowTime()
// if (oldVal && newLastMessage.ID !== oldLastMessage.ID) {
// handleScrollBottom() // 非从conversationList 首次进入
// }
})
})
// 监听数据初次渲染,展示最新一条消息
// TODO app 中获取不到DOM 元素
onReady(() => {
const options = {
sdkAppID: uni.$chat_SDKAppID, // 开通实时音视频服务创建应用后分配的 SDKAppID
userID: uni.$chat_userID, // 用户 ID,可以由您的帐号系统指定
userSig: uni.$chat_userSig, // 身份签名,相当于登录密码的作用
tim: uni.$TUIKit // tim 参数适用于业务中已存在 TIM 实例,为保证 TIM 实例唯一性
}
uni.$TUICallKit = TUICallKit
nextTick(() => {
uni.$TUICallKit.value !== null && uni.$TUICallKit.value.init(options)
})
setTimeout(() => {
data.scrollTop = 998
}, 500)
})
onMounted(() => {
handleShowTime()
// // 监听回退,已读上报
uni.addInterceptor('navigateBack', {
success() {
// 小程序无效 官网链接:https://uniapp.dcloud.io/api/interceptor.html
// uni.$TUIKit.TUIConversationServer.setMessageRead(data.conversation.conversationID)
}
})
})
onNavigationBarButtonTap(() => {
if (data.conversation?.type === uni.$TIM.TYPES.CONV_GROUP) {
uni.navigateTo({
url: '../TUIGroup/index'
})
} else {
uni.showToast({
title: '暂无信息'
})
}
})
const scrollbottomHandler = () => {
setTimeout(() => {
data.scrollTop = Number(String(new Date().getTime()).slice(-5))
}, 500)
}
const imageFormatMap = new Map([
['jpg', 1],
['gif', 2],
['png', 3],
['bmp', 4]
])
const stateInterval = setInterval(async () => {
if (data.history === 'err') {
const { result }: { result: Consultation_information_detailType } = await getConsultation_information_detail({ id: data.Event.orderId })
if (result?.orderState !== 30) proxy.$h.timeCallBack('对方已结束问诊即将返回', 2000)
}
}, 5000)
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
const { result: Pdetail }: { result: PrescriptionDetailType } = await getPrescription_detail_information({ id: data.Event.orderId })
data.PrescriptionDetail = Pdetail
if (data.history === 'success') getOrder_chatHandler(true)
}
const getOrder_chatHandler = async (refresh: boolean) => {
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
}
})
if (result.records.length) {
result.records.map((_: any) => data.historyList.unshift(_))
return
}
uni.$u.toast('没有更多数据了')
}
const finishCountDownHandler = async () => {
await getEndInformation({ id: data.Event.orderId })
data.end = true
proxy.$h.timeCallBack('问诊结束~')
}
const getEndInformationHandler = async () => {
uni.showModal({
title: '提示',
content: '您确定要结束问诊吗',
success: async function (res: any) {
if (res.confirm) {
try {
await getEndInformation({ id: data.Event.orderId })
proxy.$h.backUrl(1)
} catch (error) {
proxy.$h.backUrl(1)
uni.$u.toast(error)
}
}
}
})
}
const computedTotalHandler = () => {
data.form.prescriptionAmount = data.form.drugList.reduce((accumulator, item) => {
// 将amount和num转换为数字,如果为空则转换为0
const amount = item.amount ? item.amount : 0
const num = item.num ? item.num : 0
// 只有当amount和num都不为空时才加入计算
if (amount !== 0 && num !== 0) {
accumulator += amount * num
}
return accumulator
}, 0)
}
const handleGetProfile = () => {
uni.navigateTo({
url: '../TUIGroup/index'
})
}
const handleShowTime = () => {
if (messages.value) {
Array.from(messages.value).forEach(item => {
if (item.time - data.oldMessageTime > 5 * 60) {
data.oldMessageTime = item.time
item.showTime = true
} else {
item.showTime = false
}
})
}
}
const handleScrollBottom = () => {
uni
.createSelectorQuery()
.select('.TUI-message-list')
.boundingClientRect(res => {
const scrollH = res.height?.height
// data.scrollTop = scrollH
})
.exec()
}
// 需要自实现下拉加载
const handleScroll = (e: any) => {
data.triggered = 'restore' // 需要重置
}
const handleRefresher = () => {
data.triggered = true
if (data.history === 'err') {
if (!data.isCompleted) {
TUIServer.getHistoryMessageList().then(res => {
data.triggered = false
data.isCompleted = res.isCompleted
})
}
} else if (data.history === 'success') {
getOrder_chatHandler(false)
}
setTimeout(() => {
data.triggered = false
}, 500)
}
// 处理需要合并的数据
const handleSend = (emo: any) => {
data.text += emo.name
// inputEle.value.focus();
}
// 发送消息
const handleSendTextMessage = (e: any) => {
if (e.trimEnd()) {
TUIServer.sendTextMessage(JSON.parse(JSON.stringify(e)))
}
// data.text = ' '
}
// 右键消息,展示处理功能
const handleItem = (event: any, item: any) => {
const { flow } = item
// const { height, top } = event.target.getBoundingClientRect();
try {
const query = uni.createSelectorQuery() // .in(this)
query
.select(`#${item.flow + '-' + item.ID}`)
.boundingClientRect((res: any) => {
const { top } = res
// 弹框在下面显示,60--弹框高度;44--导航栏高度;20--弹框离信息间距
if (top < 60 + 20) {
data.dialogPosition = {
...data.dialogPosition,
top: res.height?.res + 10 // 在下面展示弹框 + 10px 间隔
}
data.dialogPosition = {
...data.dialogPosition,
right: flow === 'out' ? 0 : null, // 发出去的消息(弹框 right 都是 0)
left: flow === 'in' ? 0 : null // 接收的消息(弹框 left 都是 0)
}
} else {
data.dialogPosition = {
...defaultDialogPosition,
right: flow === 'out' ? 0 : null, // 发出去的消息(弹框 right 都是 0)
left: flow === 'in' ? 0 : null // 接收的消息(弹框 left 都是 0)
}
}
})
.exec((res: any) => {
data.currentMessage = item
data.dialogID = item.ID
})
} catch (error) {
data.currentMessage = item
data.dialogID = item.ID
}
}
// 滑动触发时,失焦收起键盘
const handleTouchStart = () => {
uni.hideKeyboard()
}
// 重新编辑
const handleEdit = (item: any) => {
data.text = item.payload.text
}
return {
...toRefs(data),
TUICallKit,
conversationType,
messages,
proxy,
handleShowTime,
handleTouchStart,
handleRefresher,
handleScroll,
handleScrollBottom,
handleSendTextMessage,
handleItem,
handleEdit,
handleTextMessageShowContext,
handleImageMessageShowContext,
handleVideoMessageShowContext,
handleAudioMessageShowContext,
handleFileMessageShowContext,
handleFaceMessageShowContext,
handleLocationMessageShowContext,
handleMergerMessageShowContext,
handleTipMessageShowContext,
handleCustomMessageShowContext,
handleSend,
caculateTimeago,
handleGetProfile,
getDetailHandler,
getEndInformationHandler,
computedTotalHandler,
finishCountDownHandler,
getOrder_chatHandler,
scrollbottomHandler
}
}
})
</script>
<style>
page {
background: #f4f5f7 !important;
}
</style>
<style lang="scss" scoped>
:deep(.u-textarea) {
background: #f8f8fa !important;
margin: 0 auto;
width: 100%;
height: 196prx;
border-radius: 24rpx;
margin-bottom: 46rpx;
}
@import '../styles/TUIChat.scss';
.mb24 {
margin-bottom: 24rpx;
}
.text {
color: #323233;
font-size: 28rpx;
font-weight: 700;
}
.blacktext {
color: #323233;
font-size: 30rpx;
font-weight: 700;
}
.graytext {
color: #999999;
font-size: 24rpx;
font-weight: 700;
}
.list {
width: 460rpx;
box-sizing: border-box;
padding: 34rpx 28rpx;
background: #f8f8fa;
margin-bottom: 32rpx;
}
.zmimg {
width: 210rpx;
height: 210rpx;
border-radius: 24rpx;
margin-right: 16rpx;
}
</style>