|
@@ -25,21 +25,20 @@ const props = defineProps({
|
|
|
})
|
|
|
const { nowPickInfo } = toRefs(props)
|
|
|
const { messageData } = toRefs(props)
|
|
|
+console.log('>>>>>messageData', messageData)
|
|
|
/* 处理时间显示间隔 */
|
|
|
-const handleMsgTimeShow = (time, index) => {
|
|
|
- console.log('>>>>>时间显示', time, index)
|
|
|
+const handleMsgTimeShow = (sendTime, index) => {
|
|
|
const msgList = Array.from(messageData.value)
|
|
|
if (index !== 0) {
|
|
|
- const lastTime = msgList[index - 1].time
|
|
|
- console.log('>>>>>时间间隔', time - lastTime, time, lastTime)
|
|
|
- return time - lastTime > 50000 ? formatDate(time, 'MM/DD/HH:mm') : ''
|
|
|
+ const lastTime = msgList[index - 1].sendTime
|
|
|
+ return sendTime - lastTime > 50000 ? formatDate(sendTime, 'MM/DD/HH:mm') : ''
|
|
|
} else {
|
|
|
- return formatDate(time, 'MM/DD/HH:mm')
|
|
|
+ return formatDate(sendTime, 'MM/DD/HH:mm')
|
|
|
}
|
|
|
}
|
|
|
/* computed-- 消息来源是否为自己 */
|
|
|
const isMyself = (msgBody) => {
|
|
|
- return msgBody.from === '1'
|
|
|
+ return msgBody.senderId === userStore.user.id || msgBody.receiverId === userStore.user.id
|
|
|
}
|
|
|
/* 文本中是否包含link */
|
|
|
const isLink = computed(() => {
|
|
@@ -51,15 +50,11 @@ const isLink = computed(() => {
|
|
|
const loginUserInfo = {
|
|
|
avatarurl: avatar.value
|
|
|
}
|
|
|
-/* 获取他人的用户信息 */
|
|
|
-const otherUserInfo = (from) => {
|
|
|
- return {
|
|
|
- avatarurl: 'https://avatars.githubusercontent.com/u/2?v=4'
|
|
|
- }
|
|
|
-}
|
|
|
//处理聊天对方昵称展示
|
|
|
-const handleNickName = (from) => {
|
|
|
- return from === '1' ? '我' : '对方'
|
|
|
+const handleNickName = (msgBody) => {
|
|
|
+ return msgBody.senderId === userStore.user.id || msgBody.receiverId === userStore.user.id
|
|
|
+ ? '我'
|
|
|
+ : '对方'
|
|
|
}
|
|
|
//引用消息
|
|
|
let clickQuoteMsgId = ref('')
|
|
@@ -102,121 +97,40 @@ const startplayAudio = (msgBody) => {
|
|
|
>
|
|
|
<!-- 普通消息气泡 -->
|
|
|
<div
|
|
|
- v-if="!msgBody.isRecall && msgBody.type !== ALL_MESSAGE_TYPE.OA_NOTIFICATION"
|
|
|
+ v-if="msgBody.conversationType !== ALL_MESSAGE_TYPE.OA_NOTIFICATION"
|
|
|
class="message_box_item"
|
|
|
:style="{
|
|
|
flexDirection: isMyself(msgBody) ? 'row-reverse' : 'row'
|
|
|
}"
|
|
|
>
|
|
|
<div class="message_item_time">
|
|
|
- {{ handleMsgTimeShow(msgBody.time, index) }}
|
|
|
+ {{ handleMsgTimeShow(msgBody.sendTime, index) }}
|
|
|
</div>
|
|
|
- <el-avatar
|
|
|
- class="message_item_avator"
|
|
|
- :src="
|
|
|
- isMyself(msgBody)
|
|
|
- ? loginUserInfo.avatarurl
|
|
|
- : otherUserInfo(msgBody.from).avatarurl || defaultAvatar
|
|
|
- "
|
|
|
- />
|
|
|
+ <el-avatar class="message_item_avator" :src="loginUserInfo.avatarurl" />
|
|
|
<!-- 普通消息内容 -->
|
|
|
<div class="message_box_card">
|
|
|
<span v-show="!isMyself(msgBody)" class="message_box_nickname">{{
|
|
|
- handleNickName(msgBody.from)
|
|
|
+ handleNickName(msgBody)
|
|
|
}}</span>
|
|
|
<el-dropdown
|
|
|
class="message_box_content"
|
|
|
- :class="[
|
|
|
- isMyself(msgBody) ? 'message_box_content_mine' : 'message_box_content_other',
|
|
|
- clickQuoteMsgId === msgBody.id && 'quote_msg_avtive'
|
|
|
- ]"
|
|
|
+ :class="[isMyself(msgBody) ? 'message_box_content_mine' : 'message_box_content_other']"
|
|
|
trigger="contextmenu"
|
|
|
placement="bottom-end"
|
|
|
>
|
|
|
<!-- 文本类型消息 -->
|
|
|
<p
|
|
|
style="padding: 10px; line-height: 20px"
|
|
|
- v-if="msgBody.type === ALL_MESSAGE_TYPE.TEXT"
|
|
|
+ v-if="msgBody.contentType === ALL_MESSAGE_TYPE.TEXT"
|
|
|
>
|
|
|
- <template v-if="!isLink(msgBody.msg)">
|
|
|
- {{ msgBody.msg }}
|
|
|
+ <template v-if="!isLink(msgBody.content)">
|
|
|
+ {{ msgBody.content }}
|
|
|
</template>
|
|
|
- <template v-else> <span v-html="paseLink(msgBody.msg).msg"> </span></template>
|
|
|
+ <template v-else> <span v-html="paseLink(msgBody.content).msg"> </span></template>
|
|
|
</p>
|
|
|
<!-- 图片类型消息 -->
|
|
|
- <!-- <div> -->
|
|
|
- <el-image
|
|
|
- v-if="msgBody.type === ALL_MESSAGE_TYPE.IMAGE"
|
|
|
- style="border-radius: 5px"
|
|
|
- :src="msgBody.thumb"
|
|
|
- :preview-src-list="[msgBody.url]"
|
|
|
- :initial-index="1"
|
|
|
- fit="cover"
|
|
|
- />
|
|
|
- <!-- </div> -->
|
|
|
<!-- 语音类型消息 -->
|
|
|
- <div
|
|
|
- :class="[
|
|
|
- 'message_box_content_audio',
|
|
|
- isMyself(msgBody)
|
|
|
- ? 'message_box_content_audio_mine'
|
|
|
- : 'message_box_content_audio_other'
|
|
|
- ]"
|
|
|
- v-if="msgBody.type === ALL_MESSAGE_TYPE.AUDIO"
|
|
|
- @click="startplayAudio(msgBody)"
|
|
|
- :style="`width:${msgBody.length * 10}px`"
|
|
|
- >
|
|
|
- <span class="audio_length_text"> {{ msgBody.length }}′′ </span>
|
|
|
- <div
|
|
|
- :class="[
|
|
|
- isMyself(msgBody) ? 'play_audio_icon_mine' : 'play_audio_icon_other',
|
|
|
- audioPlayStatus.playMsgId === msgBody.id && 'start_play_audio'
|
|
|
- ]"
|
|
|
- style="background-size: 100% 100%"
|
|
|
- ></div>
|
|
|
- </div>
|
|
|
- <div v-if="msgBody.type === ALL_MESSAGE_TYPE.LOCAL">
|
|
|
- <p style="padding: 10px">[暂不支持位置消息展示]</p>
|
|
|
- </div>
|
|
|
<!-- 文件类型消息 -->
|
|
|
- <div v-if="msgBody.type === ALL_MESSAGE_TYPE.FILE" class="message_box_content_file">
|
|
|
- <div class="file_text_box">
|
|
|
- <div class="file_name">
|
|
|
- {{ msgBody.filename }}
|
|
|
- </div>
|
|
|
- <div class="file_size">
|
|
|
- {{ fileSizeFormat(msgBody.file_length) }}
|
|
|
- </div>
|
|
|
- <a class="file_download" :href="msgBody.url" download>点击下载</a>
|
|
|
- </div>
|
|
|
- <span class="iconfont icon-wenjian"></span>
|
|
|
- </div>
|
|
|
- <!-- 自定义类型消息 -->
|
|
|
- <div v-if="msgBody.type === ALL_MESSAGE_TYPE.CUSTOM" class="message_box_content_custom">
|
|
|
- <template v-if="msgBody.customEvent && CUSTOM_TYPE[msgBody.customEvent]">
|
|
|
- <div class="user_card">
|
|
|
- <div class="user_card_main">
|
|
|
- <!-- 头像 -->
|
|
|
- <el-avatar
|
|
|
- shape="circle"
|
|
|
- :size="50"
|
|
|
- :src="
|
|
|
- (msgBody.customExts && msgBody.customExts.avatarurl) ||
|
|
|
- msgBody.customExts.avatar ||
|
|
|
- defaultAvatar
|
|
|
- "
|
|
|
- fit="cover"
|
|
|
- />
|
|
|
- <!-- 昵称 -->
|
|
|
- <span class="nickname">{{
|
|
|
- (msgBody.customExts && msgBody.customExts.nickname) || msgBody.customExts.uid
|
|
|
- }}</span>
|
|
|
- </div>
|
|
|
- <el-divider style="margin: 5px 0; border-top: 1px solid black" />
|
|
|
- <p style="font-size: 8px">个人名片</p>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </div>
|
|
|
</el-dropdown>
|
|
|
</div>
|
|
|
</div>
|