From 893cd5d8f528f00e1edb34e495ed0041730bcb00 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Thu, 4 Jul 2024 16:23:11 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=EF=BC=9Ama?= =?UTF-8?q?ll=20=E5=AE=A2=E6=9C=8D=E4=BC=98=E5=8C=96=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=AE=B5=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../promotion/kefu/components/KeFuChatBox.vue | 106 +++++++++++++----- .../kefu/components/KeFuConversationBox.vue | 20 +--- .../components/message/ImageMessageItem.vue | 3 +- .../components/tools/PictureSelectUpload.vue | 5 +- 4 files changed, 81 insertions(+), 53 deletions(-) diff --git a/src/views/mall/promotion/kefu/components/KeFuChatBox.vue b/src/views/mall/promotion/kefu/components/KeFuChatBox.vue index da25c9d9..8c6b5b71 100644 --- a/src/views/mall/promotion/kefu/components/KeFuChatBox.vue +++ b/src/views/mall/promotion/kefu/components/KeFuChatBox.vue @@ -6,34 +6,55 @@
-
- -
- - - - +
+
+ +
+ {{ formatDate(item.createTime) }} +
+ + + {{ item.content }} + +
+
+ +
+ + + + +
+
-
@@ -69,6 +90,11 @@ import { Emoji } from './tools/emoji' import { KeFuMessageContentTypeEnum } from './tools/constants' import { isEmpty } from '@/utils/is' import { UserTypeEnum } from '@/utils/constants' +import { formatDate } from '@/utils/formatTime' +import dayjs from 'dayjs' +import relativeTime from 'dayjs/plugin/relativeTime' + +dayjs.extend(relativeTime) defineOptions({ name: 'KeFuMessageBox' }) const messageTool = useMessage() @@ -90,7 +116,7 @@ const getMessageList = async (conversation: KeFuConversationRespVO) => { if (!poller.value) { poller.value = setInterval(() => { getMessageList(conversation) - }, 1000) + }, 2000) } } defineExpose({ getMessageList }) @@ -143,7 +169,18 @@ const scrollToBottom = async () => { await nextTick() scrollbarRef.value!.setScrollTop(innerRef.value!.clientHeight) } - +/** + * 是否显示时间 + * @param {*} item - 数据 + * @param {*} index - 索引 + */ +const showTime = computed(() => (item: KeFuMessageRespVO, index: number) => { + if (unref(messageList.value)[index + 1]) { + let dateString = dayjs(unref(messageList.value)[index + 1].createTime).fromNow() + return dateString !== dayjs(unref(item).createTime).fromNow() + } + return false +}) // TODO puhui999: 轮训相关,功能完善后移除 onBeforeUnmount(() => { if (!poller.value) { @@ -225,6 +262,17 @@ onBeforeUnmount(() => { transform: scale(1.03); } } + + .date-message, + .system-message { + width: fit-content; + border-radius: 12rpx; + padding: 8rpx 16rpx; + margin-bottom: 16rpx; + background-color: #e8e8e8; + color: #999; + font-size: 24rpx; + } } .chat-tools { diff --git a/src/views/mall/promotion/kefu/components/KeFuConversationBox.vue b/src/views/mall/promotion/kefu/components/KeFuConversationBox.vue index d45343ad..bf2d6fdd 100644 --- a/src/views/mall/promotion/kefu/components/KeFuConversationBox.vue +++ b/src/views/mall/promotion/kefu/components/KeFuConversationBox.vue @@ -36,7 +36,7 @@