Browse Source

客服对话

chenjj 3 months ago
parent
commit
03ef7bff9d
1 changed files with 10 additions and 4 deletions
  1. 10 4
      src/views/message/index.vue

+ 10 - 4
src/views/message/index.vue

@@ -16,7 +16,7 @@
           </div>
           <div class="message-time2">
             <div class="newestMsgTime">{{ formatTime(user.newestMsgTime) }}</div>
-            <div class="msgUnreadCount" v-if="user.msgUnreadCount && user.msgUnreadCount>0 && user.senderId !== districtCode">{{ user.msgUnreadCount }}</div>
+            <div class="msgUnreadCount" v-if="user.msgUnreadCount && user.msgUnreadCount>0">{{ user.msgUnreadCount }}</div>
           </div>
         </div>
       </div>
@@ -156,7 +156,8 @@ const selectUser = async (user) => {
       scrollToBottom()
     })
   } catch (error) {
-
+   console.log("TCL: selectUser -> error", error)
+   
   }
 }
 
@@ -326,15 +327,20 @@ const soketInit = () => {
     // })
     // 监听消息事件
     ws.on('message', (res) => {
-      console.log('收到消息:', res,res.type === 'msgNew')
+      console.log('收到消息:', res,currentUser.value.conversationRecordId , res.data.conversationRecordId)
       // const data = JSON.parse(res.data);
 
-      if (res.type === 'msgNew') {
+      if (res.type === 'msgNew' && currentUser.value.conversationRecordId === res.data.conversationRecordId) {
         console.log("TCL: soketInit -> data", res.data)
         messages.value.push(res.data)
         nextTick(() => {
             scrollToBottom()
         })
+      }else{
+        getMList();//获取用户列表
+      }
+      if(res.type ==='msgUnreadCount'){
+        getMList();//获取用户列表
       }
     })