wansfa 1 rok pred
rodič
commit
6c2e85b380

+ 17 - 2
src/components/LemonUI/components/index.vue

@@ -212,9 +212,9 @@ export default {
           if (scrollToBottom == true) {
             this.messageViewToBottom();
           }
-          this.CacheDraft.remove(message.toContactId);
+           this.CacheDraft.remove(message.toContactId);
         } else {
-          updateContact.unread = unread;
+           updateContact.unread = unread;
         }
         this.updateContact(updateContact);
       }
@@ -964,6 +964,18 @@ export default {
       this.CacheMessageLoaded.remove(id);
       return true;
     },
+    removeConversations(conversationId) {
+      const index = this.findConversationIndexById(conversationId);
+      if (index === -1) return false;
+      this.conversations.splice(index, 1);
+      // this.CacheDraft.remove(id);
+      // this.CacheMessageLoaded.remove(id);
+      return true;
+    },
+    topPopConversations(conversation) {  //置顶
+      this.removeConversations(conversation.conversationId);
+      this.conversations.unshift(conversation);
+    },
     /**
      * 修改联系人数据
      * @param {Contact} data 修改的数据,根据 Contact.id 查找联系人并覆盖传入的值
@@ -1124,6 +1136,9 @@ export default {
     },
   },
 };
+
+
+
 </script>
 <style lang="stylus">
 bezier = cubic-bezier(0.645, 0.045, 0.355, 1)

+ 29 - 27
src/views/qw/qwChat/qq.vue

@@ -423,10 +423,11 @@ export default {
                                that.$router.push({path:'/qw/qwLogin'});
                             }, 2000);
                         }
+                        //接收消息
                         if(data.cmd=="receiveMsg"){
                              var msgData=JSON.parse(data.msg);
                              if(!IMUI.hasConversation(msgData.toContactId)){  //收到新消息时是最新的会话,添加该会话
-                                    let queryParams={conversationId:msgData.toContactId,userId:that.qwUser.userId}
+                                    let queryParams={conversationId:msgData.toContactId,userId:that.qwUser.userId};
                                     getConversation(queryParams).then(response => {
                                           if(response.code==200){
                                               var conversation=response.data;
@@ -436,6 +437,15 @@ export default {
                                    });
                              }else{
                                   that.appendMessageAction(msgData);
+                                  let queryParams={conversationId:msgData.toContactId,userId:that.qwUser.userId};
+                                  getConversation(queryParams).then(response => {
+                                          if(response.code==200){
+                                              var conversation=response.data;
+                                              var conversationIdx=IMUI.findConversationIndexById(msgData.toContactId);   
+                                              IMUI.topPopConversations(conversation);
+
+                                          }
+                                   });
                              }
                         }
                   };
@@ -471,30 +481,6 @@ export default {
       });
     },
 
-    appendMessageAction(msgData){
-          if(msgData.type=="text"){   //文本
-              const message = {
-                    id: msgData.id,
-                    status: msgData.status,
-                    type: msgData.type,
-                    sendTime: msgData.sendTime,
-                    content: msgData.content,
-                    params1: "1",
-                    params2: "2",
-                    toContactId: msgData.toContactId,
-                    fromUser: msgData.fromUser,
-              };
-              this.appendRemoteMessage(message);
-           }
-    },
-
-
-    sendTextMsg(){
-
-    },
-     
-    
-
     messageTimeFormat(time) {
       //console.log("qxj messageTimeFormat:"+time);
       return this.friendlyDate(time);
@@ -540,7 +526,6 @@ export default {
                }
           }
       });
-
       // setTimeout(() => {
       //       let isEnd = true;
       //       next(MessagesData[contact.conversationId], isEnd);
@@ -557,6 +542,24 @@ export default {
         //instance.updateContact(contact);
         instance.closeDrawer();
     },
+    //接收消息回调
+    appendMessageAction(msgData){
+          if(msgData.type=="text"){   //文本   text  image  video voice 
+              const message = {
+                    id: msgData.id,
+                    status: msgData.status,
+                    type: msgData.type,
+                    sendTime: msgData.sendTime,
+                    content: msgData.content,
+                    params1: "1",
+                    params2: "2",
+                    toContactId: msgData.toContactId,
+                    fromUser: msgData.fromUser,
+              };
+              this.appendRemoteMessage(message);
+           }
+    },
+    //发送消息
     handleSend(message, next, file) {
       console.log(JSON.stringify(message));
       var params={};
@@ -568,7 +571,6 @@ export default {
               }
           });
       }
-       
       // setTimeout(() => {
       //   next();
       // }, 1000);