浏览代码

Merge branch 'v3' of http://94.191.59.107:3000/houwenfeng/cloudfile-ui into v3

“yueshang” 1 年之前
父节点
当前提交
58d25d81c0
共有 1 个文件被更改,包括 12 次插入8 次删除
  1. 12 8
      src/views/liveChat/index.vue

+ 12 - 8
src/views/liveChat/index.vue

@@ -75,10 +75,7 @@ const getMsgList = async () => {
   const resFriend = await msgFriend();
   personList.data = resFriend.rows;
   searchData.value = personList.data;
-  if (clickPersonId.value ==0 && personList.data.length>0) {
-    clickPersonId.value = personList.data[0].fromId
-  }
-  console.log("会话列表获取完成!")
+  // console.log("会话列表获取完成!")
   //圆点======
   sendCont.data.toId =
     personList.data[0]?.toId == userIds.uid
@@ -88,13 +85,18 @@ const getMsgList = async () => {
     personList.data[0]?.toId == userIds.uid
       ? personList.data[0].fromName
       : personList.data[0].toName;
+  // 默认点击第一个对话人
+  if (clickPersonId.value ==0 && personList.data.length>0) {
+    clickPersonId.value = sendCont.data.toId
+  }
   getchatUserState = false
   if(tmpMsgList.value.length>0){
     //处理临时缓存消息:将发送者标记为消息未读提示
     searchData.value.map((user) => {
+      let charUserid = user?.toId == userIds.uid  ? user.fromId : user.toId;
       for(let i=0;i<tmpMsgList.value.length;i++){
         let tmpFromID = tmpMsgList.value[i].fromId
-        if (tmpFromID == user.fromId && sendCont.data.toId!=tmpFromID) {
+        if (tmpFromID == charUserid && sendCont.data.toId!=tmpFromID) {
           user.showCircel = true;
         }
       }
@@ -299,8 +301,8 @@ const sendFileClick = async () => {
 const handleNewMessage = async () => {
   if (websoctStore.newMessage) {
     msgRecordEvent(sendCont.data.toId); //获取用户的聊天记录
-     const resFriend = await msgFriend();
-    getMsgList();
+    // const resFriend = await msgFriend();
+    //getMsgList();
     websoctStore.newMessage = false; // 重置新消息标记
   }
 };
@@ -326,7 +328,9 @@ watchEffect(async() => {
     if(clickPersonId.value!=newMessages.fromId){
       let isExist=false // 当前消息发送人员是否已在对话人员列表中
       for(let i=0;i<searchData.value.length;i++){
-        if(searchData.value[i].fromId==newMessages.fromId){
+        let chatUserID = searchData.value[i].fromId
+        if(chatUserID==userIds.uid) chatUserID = searchData.value[i].toId
+        if(chatUserID==newMessages.fromId){
           isExist = true
           searchData.value[i].showCircel = true
           searchData.value[i].content = newMessages.content