|
@@ -40,7 +40,7 @@
|
|
<ChatMessage :message="message"></ChatMessage>
|
|
<ChatMessage :message="message"></ChatMessage>
|
|
</template>
|
|
</template>
|
|
<div v-if="chatErrorText" class="text-[#979797] text-sm text-center mt-auto mb-10">
|
|
<div v-if="chatErrorText" class="text-[#979797] text-sm text-center mt-auto mb-10">
|
|
- {{chatErrorText}}
|
|
|
|
|
|
+ {{ chatErrorText }}
|
|
</div>
|
|
</div>
|
|
</van-list>
|
|
</van-list>
|
|
</van-pull-refresh>
|
|
</van-pull-refresh>
|
|
@@ -72,7 +72,7 @@ import ChatMessage from './components/chat-message'
|
|
import ChatInput from './components/chat-input'
|
|
import ChatInput from './components/chat-input'
|
|
import { findHyperlinks } from '~/pages/chat/components/chat-message/link-message/handle'
|
|
import { findHyperlinks } from '~/pages/chat/components/chat-message/link-message/handle'
|
|
import { XYWebSocket } from '~/utils/XYWebSocket'
|
|
import { XYWebSocket } from '~/utils/XYWebSocket'
|
|
-
|
|
|
|
|
|
+import defaultAvatar from '@/assets/img/default_avatar.png'
|
|
const route = useRoute()
|
|
const route = useRoute()
|
|
const router = useRouter()
|
|
const router = useRouter()
|
|
|
|
|
|
@@ -176,7 +176,7 @@ const sendTextMessage = async (text) => {
|
|
object: {
|
|
object: {
|
|
id: getLocalId(),
|
|
id: getLocalId(),
|
|
// TODO 聊天时候改了头像昵称 会出现找不到的情况
|
|
// TODO 聊天时候改了头像昵称 会出现找不到的情况
|
|
- headImageUrl: userInfo?.value.headImageUrl,
|
|
|
|
|
|
+ headImageUrl: userInfo.value.headImageUrl ? userInfo.value?.headImageUrl : defaultAvatar,
|
|
showName: userInfo?.value.showName,
|
|
showName: userInfo?.value.showName,
|
|
web_message_status: chatsStore.WEB_MESSAGE_STATUS.loading
|
|
web_message_status: chatsStore.WEB_MESSAGE_STATUS.loading
|
|
}
|
|
}
|
|
@@ -186,8 +186,11 @@ const sendTextMessage = async (text) => {
|
|
// console.log(currConversationChatList.value, '1122')
|
|
// console.log(currConversationChatList.value, '1122')
|
|
currConversationChatList.value.push(msg)
|
|
currConversationChatList.value.push(msg)
|
|
await scrollToBottom()
|
|
await scrollToBottom()
|
|
- const backMessage = await chatsStore.sendSocketMessage(msg);
|
|
|
|
- const {index, message} = chatsStore.updateBackMessage(currConversationChatList.value, backMessage);
|
|
|
|
|
|
+ const backMessage = await chatsStore.sendSocketMessage(msg)
|
|
|
|
+ const { index, message } = chatsStore.updateBackMessage(
|
|
|
|
+ currConversationChatList.value,
|
|
|
|
+ backMessage
|
|
|
|
+ )
|
|
currConversationChatList.value[index] = message
|
|
currConversationChatList.value[index] = message
|
|
} catch (e) {
|
|
} catch (e) {
|
|
console.log(e, '2')
|
|
console.log(e, '2')
|
|
@@ -222,7 +225,7 @@ const sendImageMessage = async (file) => {
|
|
object: {
|
|
object: {
|
|
id: getLocalId(),
|
|
id: getLocalId(),
|
|
// TODO 聊天时候改了头像昵称 会出现找不到的情况
|
|
// TODO 聊天时候改了头像昵称 会出现找不到的情况
|
|
- headImageUrl: userInfo?.value.headImageUrl,
|
|
|
|
|
|
+ headImageUrl: userInfo.value.headImageUrl ? userInfo.value?.headImageUrl : defaultAvatar,
|
|
showName: userInfo?.value.showName,
|
|
showName: userInfo?.value.showName,
|
|
web_message_status: chatsStore.WEB_MESSAGE_STATUS.loading
|
|
web_message_status: chatsStore.WEB_MESSAGE_STATUS.loading
|
|
}
|
|
}
|
|
@@ -231,8 +234,11 @@ const sendImageMessage = async (file) => {
|
|
currConversationChatList.value.push(msg)
|
|
currConversationChatList.value.push(msg)
|
|
await scrollToBottom()
|
|
await scrollToBottom()
|
|
await chatsStore.sendSocketMessage(msg)
|
|
await chatsStore.sendSocketMessage(msg)
|
|
- const backMessage = await chatsStore.sendSocketMessage(msg);
|
|
|
|
- const {index, message} = chatsStore.updateBackMessage(currConversationChatList.value, backMessage);
|
|
|
|
|
|
+ const backMessage = await chatsStore.sendSocketMessage(msg)
|
|
|
|
+ const { index, message } = chatsStore.updateBackMessage(
|
|
|
|
+ currConversationChatList.value,
|
|
|
|
+ backMessage
|
|
|
|
+ )
|
|
currConversationChatList.value[index] = message
|
|
currConversationChatList.value[index] = message
|
|
} catch (e) {
|
|
} catch (e) {
|
|
console.error(e, '??')
|
|
console.error(e, '??')
|
|
@@ -296,17 +302,17 @@ const onClickRight = () => {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
// async
|
|
// async
|
|
-const scrollToBottom = async () => {
|
|
|
|
|
|
+const scrollToBottom = () => {
|
|
// 操作向上加载不滚动 TODO 判断用户是否有向上滑的操作更准确
|
|
// 操作向上加载不滚动 TODO 判断用户是否有向上滑的操作更准确
|
|
if (moreLoading.value) return
|
|
if (moreLoading.value) return
|
|
- setTimeout(async () => {
|
|
|
|
- await nextTick() // 确保DOM已经更新
|
|
|
|
- const listElement = chatListRef.value?.$el
|
|
|
|
- if (listElement) {
|
|
|
|
- const scrollContainer = listElement
|
|
|
|
- scrollContainer.scrollTop = scrollContainer.scrollHeight + 100
|
|
|
|
- }
|
|
|
|
- }, 200)
|
|
|
|
|
|
+ // setTimeout(async () => {
|
|
|
|
+ // await nextTick() // 确保DOM已经更新
|
|
|
|
+ // const listElement = chatListRef.value?.$el
|
|
|
|
+ // if (listElement) {
|
|
|
|
+ // const scrollContainer = listElement
|
|
|
|
+ // scrollContainer.scrollTop = scrollContainer.scrollHeight + 100
|
|
|
|
+ // }
|
|
|
|
+ // }, 200)
|
|
|
|
|
|
// await nextTick() // 确保DOM已经更新
|
|
// await nextTick() // 确保DOM已经更新
|
|
// const listElement = chatListRef.value?.$el
|
|
// const listElement = chatListRef.value?.$el
|
|
@@ -314,12 +320,12 @@ const scrollToBottom = async () => {
|
|
// const scrollContainer = listElement
|
|
// const scrollContainer = listElement
|
|
// scrollContainer.scrollTop = scrollContainer.scrollHeight
|
|
// scrollContainer.scrollTop = scrollContainer.scrollHeight
|
|
// }
|
|
// }
|
|
- // await nextTick(() => {
|
|
|
|
- // const listElement = chatListRef.value?.$el
|
|
|
|
- // setTimeout(() => {
|
|
|
|
- // listElement && (listElement.scrollTop = listElement.scrollHeight + 100)
|
|
|
|
- // }, 200)
|
|
|
|
- // })
|
|
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ const listElement = chatListRef.value?.$el
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ listElement && (listElement.scrollTop = listElement.scrollHeight + 100)
|
|
|
|
+ }, 200)
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
// 获取我与对方的关注情况
|
|
// 获取我与对方的关注情况
|
|
@@ -349,7 +355,8 @@ onMounted(() => {
|
|
const isOtherUserMessage = chat.sendUserId && chatsStore.isRealMessage(chat.sendUserId)
|
|
const isOtherUserMessage = chat.sendUserId && chatsStore.isRealMessage(chat.sendUserId)
|
|
if (isCurrGroupId) {
|
|
if (isCurrGroupId) {
|
|
if (isOtherUserMessage) {
|
|
if (isOtherUserMessage) {
|
|
- currConversationChatList.value.push(chat)
|
|
|
|
|
|
+ const { message } = chatsStore.updateBackMessage([chat], chat)
|
|
|
|
+ currConversationChatList.value.push(message)
|
|
await scrollToBottom()
|
|
await scrollToBottom()
|
|
}
|
|
}
|
|
if (!isOtherUserMessage) {
|
|
if (!isOtherUserMessage) {
|
|
@@ -370,22 +377,6 @@ const getAnnouncement = () => {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
-// async function getAnnouncement() {
|
|
|
|
-// let { data } = await request('/website/tourMember/getGroupUserListVo', {
|
|
|
|
-// query: { groupId: groupId.value }
|
|
|
|
-// })
|
|
|
|
-
|
|
|
|
-// if (data) {
|
|
|
|
-// if (Array.isArray(data.memberList) && data?.memberList?.length) {
|
|
|
|
-// data.memberList.map((el) => {
|
|
|
|
-// if (el.userId == userInfo.value.userId) {
|
|
|
|
-// memberInfo.value = el
|
|
|
|
-// }
|
|
|
|
-// })
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
// 用户删除消息
|
|
// 用户删除消息
|
|
const delMessage = (messageId) => {
|
|
const delMessage = (messageId) => {
|
|
showConfirmDialog({
|
|
showConfirmDialog({
|