|
@@ -40,11 +40,15 @@
|
|
|
<div class="flex w-[80%] pr-10 justify-end">
|
|
|
<div class="mr-10">
|
|
|
<div class="text-[#666] text-right">{{ user?.showName }}</div>
|
|
|
- <div class="p-5 rounded relative overflow-hidden flex justify-end" style="float:right;width:200px;">
|
|
|
+ <div class="p-5 rounded relative flex justify-end items-center" style="float:right;width:200px;">
|
|
|
+ <div v-if="item.messageLimit == 1" class="w-[20px] h-[20px] bg-[#f40] rounded-full text-[12px] text-[#fff] flex items-center justify-center shrink-0" style="z-index:200;margin-right:10px;">
|
|
|
+ !
|
|
|
+ </div>
|
|
|
<el-image :preview-src-list="[convertImg(item.messageContent)]" :src="convertImg(item.messageContent)" fit="cover" />
|
|
|
<div v-if="!item?.createTime" class="absolute top-[50%] left-[0px]" style="transform: translateY(-50%) translateX(-105%);">
|
|
|
<MsgStatus></MsgStatus>
|
|
|
</div>
|
|
|
+
|
|
|
<!-- <div v-else class="absolute top-[50%] left-[0px]" style="transform: translateY(-50%) translateX(-105%);">
|
|
|
<MsgStatus :messageLimit="item?.messageLimit"></MsgStatus>
|
|
|
</div> -->
|
|
@@ -65,7 +69,7 @@
|
|
|
<div class="flex justify-end mt-30">
|
|
|
<div class="flex w-[80%] pr-10 justify-end">
|
|
|
<div class="mr-10">
|
|
|
- <div class="text-[#666] text-right">{{ user?.showName }}</div>
|
|
|
+ <div class="text-[#666] text-right">{{ myName() }}</div>
|
|
|
<div class="bg-[#FD9A00]/10 py-10 px-10 rounded text-[#333] text-wrap relative"
|
|
|
style="float:right;">
|
|
|
|
|
@@ -77,6 +81,9 @@
|
|
|
style="transform: translateY(-50%) translateX(-100%);">
|
|
|
<MsgStatus></MsgStatus>
|
|
|
</div>
|
|
|
+ <div v-if="item?.messageLimit==1" class="absolute top-[50%] left-[0px] w-[20px] h-[20px] bg-[#f40] rounded-full text-[12px] text-[#fff] flex items-center justify-center" style="transform: translateY(-50%) translateX(-120%);">
|
|
|
+ !
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="w-40 h-40 rounded-full overflow-hidden shrink-0 bg-[#dedede]">
|
|
@@ -86,6 +93,9 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
+ <div v-if="item.messageLimit == 1" class="text-center text-[#f40] mt-30 text-[12px]">
|
|
|
+ 在对方关注或回复你之前,您只可以发送一条消息
|
|
|
+ </div>
|
|
|
</template>
|
|
|
<template v-else>
|
|
|
<template v-if="item.messageType == 0 && item.messageContent">
|
|
@@ -93,19 +103,18 @@
|
|
|
<div class="text-center text-[#666] mt-30 text-[12px]">
|
|
|
{{ item.createTime }}
|
|
|
</div>
|
|
|
- <!-- 左侧消息 文本 -->
|
|
|
+ <!-- 文本 -->
|
|
|
<div class="flex w-[80%] pl-10 mt-30">
|
|
|
<div class="w-40 h-40 rounded-full overflow-hidden shrink-0 bg-[#dedede]">
|
|
|
- <img v-if="item?.headImageUrl" class="w-full h-full object-cover"
|
|
|
- :src="item?.headImageUrl" alt="" />
|
|
|
+ <img class="w-full h-full object-cover" :src="item?.headImageUrl || item?.object?.headImageUrl || curConversiton?.headImage" alt="" />
|
|
|
</div>
|
|
|
<div class="ml-10">
|
|
|
<div class="text-[#666]">
|
|
|
- {{ item?.showName }}
|
|
|
+ {{ item?.showName || item?.object?.showName || curConversiton?.groupRemark }}
|
|
|
</div>
|
|
|
<div class="bg-[#eee] py-5 px-10 rounded text-[#333] text-wrap"
|
|
|
style="float:left;max-width: 500px;white-space:pre-wrap;word-wrap: break-word;">
|
|
|
- <!-- {{ convertImg(item.messageContent) }} -->
|
|
|
+
|
|
|
<TextMsg :msg="item.messageContent"></TextMsg>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -115,20 +124,18 @@
|
|
|
<div class="text-center text-[#666] mt-30 text-[12px]">
|
|
|
{{ item.createTime }}
|
|
|
</div>
|
|
|
- <!-- 左侧消息 图片 -->
|
|
|
+ <!-- 图片 -->
|
|
|
<div class="flex w-[80%] pl-10 mt-30">
|
|
|
<div class="w-40 h-40 rounded-full overflow-hidden shrink-0">
|
|
|
- <img class="w-full h-full object-cover" :src="item?.headImageUrl" alt="" />
|
|
|
+ <img class="w-full h-full object-cover" :src="item?.headImageUrl || item?.object?.headImageUrl || curConversiton?.headImage" alt="" />
|
|
|
</div>
|
|
|
<div class="ml-10">
|
|
|
<div class="text-[#666]">
|
|
|
- {{ item?.showName }}
|
|
|
+ {{ item?.showName || item?.object?.showName || curConversiton?.groupRemark }}
|
|
|
</div>
|
|
|
<div class="p-5 rounded border relative" style="width:200px">
|
|
|
- <!-- <img :src="[convertImg(item.messageContent)]" alt="" /> -->
|
|
|
<el-image :preview-src-list="[convertImg(item.messageContent)]" :src="convertImg(item.messageContent)" fit="cover" />
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -139,7 +146,6 @@
|
|
|
</div>
|
|
|
<div class="w-full h-[160px] border-t-[1px] border-[#ccc] flex flex-col justify-between">
|
|
|
<div class="flex items-center h-[36px] pl-10 cursor-pointer">
|
|
|
-
|
|
|
<el-popover placement="top-start" :width="420" trigger="hover">
|
|
|
<template #reference>
|
|
|
<img src="~assets/img/chat/emoji_icon.png" class="w-[20px] h-[20px]" alt="" />
|
|
@@ -242,6 +248,8 @@ const wsConnect = computed(() => connectSta.value)
|
|
|
// 显示聊天框右侧信息(主要是好友信息,群信息,群设置)
|
|
|
const showInfo = ref(false)
|
|
|
|
|
|
+// 如果是群聊的话,获取群成员列表
|
|
|
+const groupMemberList = ref([])
|
|
|
|
|
|
|
|
|
// 聊天记录的弹窗开关
|
|
@@ -267,9 +275,13 @@ function sendMessage() {
|
|
|
messageType: 0,
|
|
|
noticeType: noticeType.value,
|
|
|
object: {
|
|
|
- id: getLocalId()
|
|
|
+ id: getLocalId(),
|
|
|
}
|
|
|
}
|
|
|
+ if (noticeType.value == 2) {
|
|
|
+ msg.object.headImageUrl = user.value?.headImageUrl
|
|
|
+ msg.object.showName = user.value?.showName
|
|
|
+ }
|
|
|
receive.value.push(msg)
|
|
|
messageContent.value = ''
|
|
|
nextTick(() => {
|
|
@@ -338,7 +350,17 @@ function convertImg(msgJSONString) {
|
|
|
return msgJSONString
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+function myName(){
|
|
|
+ if(noticeType.value==2){
|
|
|
+ for(let i=0;i<groupMemberList.value.length;i++){
|
|
|
+ const userPass = groupMemberList.value[i].pass
|
|
|
+ if(userPass == user.value.pass){
|
|
|
+ return groupMemberList.value[i].groupNickname
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return user.value.showName
|
|
|
+}
|
|
|
function showInfoTurnOnOff() {
|
|
|
if (noticeType.value == 1) {
|
|
|
showInfo.value = !showInfo.value
|
|
@@ -367,7 +389,6 @@ function onClearMsg() {
|
|
|
|
|
|
// 监听输入框的输入事件
|
|
|
function onMsgInput(evt){
|
|
|
- console.log('value:', evt.data)
|
|
|
if(evt.data == '@'){
|
|
|
|
|
|
}
|
|
@@ -444,9 +465,13 @@ function selectImg(evt) {
|
|
|
messageType: 1,
|
|
|
noticeType: noticeType.value,
|
|
|
object: {
|
|
|
- id: getLocalId()
|
|
|
+ id: getLocalId(),
|
|
|
}
|
|
|
}
|
|
|
+ if (noticeType.value == 2) {
|
|
|
+ msg.object.headImageUrl = user.value?.headImageUrl
|
|
|
+ msg.object.showName = user.value?.showName
|
|
|
+ }
|
|
|
receive.value.push(msg)
|
|
|
ws.value.send(JSON.stringify(msg))
|
|
|
}
|
|
@@ -494,6 +519,19 @@ async function handleFollow() {
|
|
|
isFollow()
|
|
|
}
|
|
|
|
|
|
+async function getGroupMembers(){
|
|
|
+ if(!groupId.value) return
|
|
|
+ if(noticeType.value !== 2) return
|
|
|
+ const query = {
|
|
|
+ groupId: groupId.value
|
|
|
+ }
|
|
|
+ const { data } = await request('/website/tourGroup/getGroupInfoAndMemberByGroupId', { query })
|
|
|
+ const { memberList } = data || {}
|
|
|
+
|
|
|
+ if (Array.isArray(memberList)) {
|
|
|
+ groupMemberList.value = memberList
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
// 监听当前会话的切换
|
|
|
watch(groupId, async () => {
|
|
@@ -523,6 +561,9 @@ watch(groupId, async () => {
|
|
|
// 清除未读消息
|
|
|
chatStore.updateRead(groupId.value)
|
|
|
|
|
|
+ // 如果是群聊天的话,获取群成员列表
|
|
|
+ getGroupMembers()
|
|
|
+
|
|
|
})
|
|
|
watch(onNewMessage, () => {
|
|
|
messageBoxRef.value && (messageBoxRef.value.scrollTop = messageBoxRef.value.scrollHeight + 100000)
|