ソースを参照

fix: 1.聊天页面的群头像和单聊

suwenjiang 2 ヶ月 前
コミット
81437759a4
2 ファイル変更13 行追加4 行削除
  1. 9 3
      src/pages/chat/group-chat.vue
  2. 4 1
      src/pages/chat/single-chat.vue

+ 9 - 3
src/pages/chat/group-chat.vue

@@ -91,12 +91,15 @@ const showPage = computed(() => groupId.value)
 
 const initGroupId = async () => {
   try {
-/*    if (!groupId.value) return;
+    if (!groupId.value) return;
+/*
     pageLoading.value = true;
     const res = await chatsStore.getCurrConversationId(getUserId.value)
     await handleResponse(res)
     groupId.value = res.data;*/
+    await getAnnouncement()
     await getChatList('init')
+
   } catch (e) {
 
   } finally {
@@ -188,7 +191,10 @@ const sendImageMessage = async (file) => {
       messageType: 1,
       noticeType: 2,
       object: {
-        id: getLocalId()
+        id: getLocalId(),
+        // TODO 聊天时候改了头像昵称 会出现找不到的情况
+        headImageUrl: userInfo?.value.headImageUrl,
+        showName: userInfo?.value.showName
       }
     }
     currConversationChatList.value.push(msg)
@@ -263,7 +269,7 @@ function getLocalId() {
 
 onMounted(() => {
   initGroupId()
-  getAnnouncement()
+
   XYWebSocket.SocketEventsBus.on(XYWebSocket.SocketEvents.chatEvent, async (chat) => {
     const isCurrGroupId = chat.groupId && chat.groupId === groupId.value;
     const isOtherUserMessage = chat.sendUserId && chatsStore.isRealMessage(chat.sendUserId);

+ 4 - 1
src/pages/chat/single-chat.vue

@@ -175,7 +175,10 @@ const sendImageMessage = async (file) => {
       messageType: 1,
       noticeType: 1,
       object: {
-        id: getLocalId()
+        id: getLocalId(),
+        // TODO 聊天时候改了头像昵称 会出现找不到的情况
+        headImageUrl: userInfo?.value.headImageUrl,
+        showName: userInfo?.value.showName
       }
     }
     currConversationChatList.value.push(msg)