Browse Source

企微聊天 重粉、黑粉处理

Long 4 days ago
parent
commit
0bf7af1905
3 changed files with 34 additions and 20 deletions
  1. 2 2
      src/components/LemonUI/components/contact.vue
  2. 0 1
      src/layout/index.vue
  3. 32 17
      src/views/qw/qwChat/qq.vue

+ 2 - 2
src/components/LemonUI/components/contact.vue

@@ -58,8 +58,8 @@ export default {
           <p class="lemon-contact__label">
             <span class="lemon-contact__name">
               {contact.displayName}
-              {true && <span class="lemon-contact__chong">重</span>}
-              {true && <span class="lemon-contact__hei">黑</span>}
+              {contact.isRepeat && <span class="lemon-contact__chong">重</span>}
+              {contact.isBlack && <span class="lemon-contact__hei">黑</span>}
             </span>
             {!this.simple && (
               <span class="lemon-contact__time">

+ 0 - 1
src/layout/index.vue

@@ -57,7 +57,6 @@
                custom-class="im-dialog"
                :fullscreen="qw.isMaximized"
                :visible.sync="qw.open"
-               :modal="false"
                :style="{visibility: !qw.initLoad ? 'hidden' : 'unset'}"
                :title="qw.title">
 <!--      <template #title>-->

+ 32 - 17
src/views/qw/qwChat/qq.vue

@@ -63,7 +63,7 @@
               <div>
                 <el-checkbox-group v-model="selectedFilters">
                   <el-checkbox label="1">去掉重粉</el-checkbox>
-                  <el-checkbox label="2">去掉小黑屋</el-checkbox>
+                  <el-checkbox label="2">去掉黑粉</el-checkbox>
                 </el-checkbox-group>
                 <div style="margin-top: 10px; text-align: right;">
                   <el-button size="mini" type="primary" @click="applyFilter">确定</el-button>
@@ -378,7 +378,7 @@ export default {
               this.updateSessionConversation(conversation);
             } else {
               // 如果找不到会话,可能需要刷新会话列表
-              this.refreshCurrentSession();
+              this.refreshSession(messageAppKey);
             }
           } else if (messageAppKey) {
             // 如果不是当前账号的消息,增加对应账号的未读消息数
@@ -389,6 +389,10 @@ export default {
                 item => item.conversationId === message.toContactId
               );
 
+              if (index === -1) {
+                this.refreshSession(messageAppKey, false)
+              }
+
               if (index !== -1) {
                 let conversation = this.qwUserSessions[messageAppKey][index]
                 conversation.lastSendTime = message.sendTime;
@@ -912,41 +916,52 @@ export default {
     // 搜索
     handleSearch() {
       const keyword = this.searchKeyword.trim().toLowerCase();
-      if (!keyword) {
+      if (!keyword && !this.selectedFilters) {
         // 为空时显示全部
         this.$refs.IMUI.initConversations(this.conversationData);
         return;
       }
+
+      const notRepeat = this.selectedFilters.some(item => item === '1')
+      const notBlack = this.selectedFilters.some(item => item === '2')
+
       // 过滤会话列表
       const filtered = this.conversationData.filter(item => {
         // 搜索最后一条消息内容和联系人名
         return (
           (item.lastContent && item.lastContent.toLowerCase().includes(keyword)) ||
           (item.displayName && item.displayName.toLowerCase().includes(keyword))
-        );
+        )
+          && (notRepeat ? !item.isRepeat : true)
+          && (notBlack ? !item.isBlack : true);
       });
       this.$refs.IMUI.initConversations(filtered);
     },
     applyFilter() {
       this.filterPopoverVisible = false;
-      // 这里可以根据 selectedFilters 做过滤
       this.handleSearch();
     },
-    // 手动刷新当前企微账号会话列表
-    refreshCurrentSession() {
+    // 刷新企微账号会话列表
+    refreshSession(appKey, isCurrent = true) {
       // 删除当前企微账号的会话缓存
-      if (this.appKey) {
-        delete this.qwUserSessions[this.appKey];
-        delete this.qwUserSessions[`${this.appKey}_selected`];
+      delete this.qwUserSessions[appKey];
+      delete this.qwUserSessions[`${appKey}_selected`];
 
-        // 重新获取会话列表
-        this.getConversation();
+      // 重新获取会话列表
+      getConversations(this.qwUser.id).then(response => {
+        this.conversationData = response.data;
 
-        this.$message({
-          message: '会话列表已刷新',
-          type: 'success'
-        });
-      }
+        // 缓存会话记录
+        this.qwUserSessions[appKey] = response.data;
+
+        if (isCurrent) {
+          this.$refs.IMUI.initConversations(response.data);
+          const fstConversation = this.conversationData[0];
+          if(fstConversation) {
+            this.$refs.IMUI.changeContact(fstConversation.conversationId);
+          }
+        }
+      });
     },
     handleClose() {
       this.$emit('close')