wansfa 1 gadu atpakaļ
vecāks
revīzija
f2fe23457d

+ 21 - 1
src/api/qw/im.js

@@ -13,4 +13,24 @@ export function getContactsByUser(userId) {
     url: '/qw/contact/listByUser/'+userId,
     method: 'get'
   })
-}
+}
+
+
+export function getConversation(userId) {
+  return request({
+    url: '/qw/contact/conversationList/'+userId,
+    method: 'get'
+  })
+}
+
+
+export function getMessageList(query) {
+  return request({
+    url: '/qw/message/getList',
+    method: 'get',
+    params: query
+  })
+}
+
+
+

+ 31 - 21
src/components/LemonUI/components/index.vue

@@ -132,7 +132,13 @@ export default {
   },
   computed: {
     currentContact() {
-      return this.contacts.find(item => item.id == this.currentContactId) || {};
+      // return this.conversations.find(function(item,index,arr){
+      //           if(!!item.conversationId){
+      //               return item.conversationId == this.currentContactId;
+      //           }
+      //           return item.id == this.currentContactId;
+      // },this.conversations) || {};
+       return this.conversations.find(item =>  item.conversationId == this.currentContactId) || {};
     },
     currentMenu() {
       return this.menus.find(item => item.name == this.activeSidebar) || {};
@@ -141,10 +147,11 @@ export default {
       return DEFAULT_MENUS.includes(this.activeSidebar);
     },
     lastMessages() {
-      var data = this.contacts.filter(item => !isEmpty(item.lastContent));
-      data.sort((a1, a2) => {
-        return a2.lastSendTime - a1.lastSendTime;
-      });
+      // var data = this.contacts.filter(item => !isEmpty(item.lastContent));
+      // data.sort((a1, a2) => {
+      //   return a2.lastSendTime - a1.lastSendTime;
+      // });
+      var data=null;
       if(!!this.conversations){
           data=this.conversations;
       }
@@ -266,15 +273,18 @@ export default {
       );
     },
     _emitPullMessages(next) {
+      //console.log("qxj currentContact:"+JSON.stringify(this.currentContact));
       this._changeContactLock = true;
-      this.$emit(
-        "pull-messages",
-        this.currentContact,
+      this.$emit("pull-messages",
+      this.currentContact,
         (messages = [], isEnd = false) => {
+        
           this._addMessage(messages, this.currentContactId, 0);
+
           this.CacheMessageLoaded.set(this.currentContactId, isEnd);
           if (isEnd == true) this.$refs.messages.loaded();
           this.updateCurrentMessages();
+          console.log("qxj _emitPullMessages");
           this._changeContactLock = false;
           next(isEnd);
         },
@@ -628,8 +638,10 @@ export default {
       return str.replace(/<img emoji-name=\"([^\"]*?)\" [^>]*>/gi, "[!$1]");
     },
     updateCurrentMessages() {
-      if (!allMessages[this.currentContactId])
-        allMessages[this.currentContactId] = [];
+      if (!allMessages[this.currentContactId]){
+          allMessages[this.currentContactId] = [];
+      }
+      console.log("qxj allMessages:"+JSON.stringify(allMessages));
       this.currentMessages = allMessages[this.currentContactId];
     },
     /**
@@ -684,12 +696,12 @@ export default {
      */
     async changeContact(contactId, menuName) {
       if (menuName) {
-        this.changeMenu(menuName);
+           this.changeMenu(menuName);
       } else {
-        if (this._changeContactLock || this.currentContactId == contactId)
-          return false;
+        if (this._changeContactLock || this.currentContactId == contactId){
+           return false;
+        }
       }
-
       //保存上个聊天目标的草稿
       if (this.currentContactId) {
         const editorValue = clearHtmlExcludeImg(this.getEditorValue()).trim();
@@ -704,11 +716,9 @@ export default {
       this.currentContactId = contactId;
       if (!this.currentContactId) return false;
       this.$emit("change-contact", this.currentContact, this);
-
       if (isFunction(this.currentContact.renderContainer) || this.activeSidebar == DEFAULT_MENU_CONTACTS) {
-        return;
+          return;
       }
-      
       //填充草稿内容
       const draft = this.CacheDraft.get(contactId);
       if (draft) this.setEditorValue(draft.editorValue);
@@ -720,10 +730,10 @@ export default {
       }
 
       if (!allMessages[contactId]) {
-        this.updateCurrentMessages();
-        this._emitPullMessages(isEnd => {
-             this.messageViewToBottom();
-        });
+          this.updateCurrentMessages();
+          this._emitPullMessages(isEnd => {
+              this.messageViewToBottom();
+          });
       } else {
           setTimeout(() => {
               this.updateCurrentMessages();

+ 30 - 0
src/components/LemonUI/components/message/voice.vue

@@ -0,0 +1,30 @@
+<script>
+export default {
+  name: "lemonMessageVoice",
+  inheritAttrs: false,
+  inject: ["IMUI"],
+  render() {
+    return (
+      <lemon-message-basic
+        class="lemon-message-voice"
+        props={{ ...this.$attrs }}
+        scopedSlots={{
+          content: props => {
+            return <span>{props.content}&nbsp;🔈</span>;
+          }
+        }}
+      />
+    );
+  }
+};
+</script>
+<style lang="stylus">
+.lemon-message.lemon-message-voice
+  user-select none
+  .lemon-message__content
+    border 2px solid #000
+    font-size 12px
+    cursor pointer
+    &::before
+      display none
+</style>

+ 0 - 1
src/components/LemonUI/components/messages.vue

@@ -85,7 +85,6 @@ export default {
               />,
             );
           }
-
           let attrs;
           if (message.type == "event") {
             attrs = { message: message };

+ 1 - 1
src/components/LemonUI/database/contacts.js

@@ -137,7 +137,7 @@ export default [
     },
   },
   {
-    id: 15,
+    id: 1688856679458971,
     displayName: "宁静致远。",
     avatar: "https://p.qqan.com/up/2020-6/2020060308522797777.jpg",
     index: "N",

+ 140 - 0
src/components/LemonUI/database/messages.js

@@ -217,4 +217,144 @@ export default {
   ],
   14: [],
   15: [],
+  1688856679458971: [
+    {
+      id: generateRandId(),
+      status: "succeed",
+      type: "text",
+      sendTime: 1670481209000,
+      content: "我是测试时候看到的",
+      toContactId: 1,
+      fromUser: getContact(4),
+    },
+    {
+      id: generateRandId(),
+      status: "succeed",
+      type: "text",
+      sendTime: 1670541395000,
+      content: "上新版本了,玩玩",
+      toContactId: 1,
+      fromUser: getContact(4),
+    },
+    {
+      id: generateRandId(),
+      status: "succeed",
+      type: "text",
+      sendTime: 1670544995000,
+      content: "项目内没有搞这个",
+      toContactId: 1,
+      fromUser: getContact(4),
+    },
+    {
+      id: generateRandId(),
+      status: "succeed",
+      type: "text",
+      sendTime: 1670545175000,
+      content: "@awesome 最新的,不然哪有这功能",
+      toContactId: 1,
+      fromUser: getContact(5),
+    },
+    {
+      id: generateRandId(),
+      status: "succeed",
+      type: "text",
+      sendTime: 1670631575000,
+      content: "其实是跟你的遮罩层有冲突",
+      toContactId: 1,
+      fromUser: getContact(4),
+    },
+    {
+      id: generateRandId(),
+      status: "succeed",
+      type: "text",
+      sendTime: 1670804375000,
+      content: "自己修改index哈",
+      toContactId: 1,
+      fromUser: UserData,
+    },
+    {
+      id: generateRandId(),
+      status: "succeed",
+      type: "text",
+      sendTime: 1670977175000,
+      content: "你们升级到最近版了吗?",
+      toContactId: 1,
+      fromUser: getContact(6),
+    },
+    {
+      id: generateRandId(),
+      status: "succeed",
+      type: "text",
+      sendTime: 1670980775000,
+      content: "wo 现在用的142",
+      toContactId: 1,
+      fromUser: getContact(7),
+    },
+    {
+      id: generateRandId(),
+      status: "succeed",
+      type: "text",
+      sendTime: 1671247175000,
+      content: "问你件事",
+      toContactId: 1,
+      fromUser: UserData,
+    },
+    {
+      id: generateRandId(),
+      status: "failed",
+      type: "text",
+      sendTime: 1671340182000,
+      content: "啥子。",
+      toContactId: 1,
+      fromUser: getContact(1),
+    },
+    {
+      id: generateRandId(),
+      status: "succeed",
+      type: "text",
+      sendTime: 1696907382000,
+      content: "为什么",
+      toContactId: 1,
+      fromUser: UserData,
+    },
+    {
+      id: generateRandId(),
+      status: "succeed",
+      type: "text",
+      sendTime: 1696920042000,
+      content: "你穿了高跟鞋还这么矮[!1f62c][!1f601][!1f602]",
+      toContactId: 1,
+      fromUser: UserData,
+    },
+    {
+      id: generateRandId(),
+      status: "succeed",
+      type: "text",
+      sendTime: 1696995642000,
+      content: "因为我矮啊。[!1f600][!1f600][!1f600]",
+      toContactId: 1,
+      fromUser: getContact(1),
+    },
+    {
+      id: generateRandId(),
+      status: "succeed",
+      type: "text",
+      sendTime: 1696995642000,
+      content: "你有意见吗。[!1f643][!1f643][!1f643]",
+      toContactId: 1,
+      fromUser: getContact(1),
+    },
+    {
+      id: generateRandId(),
+      status: "succeed",
+      type: "text",
+      sendTime: 1696995942000,
+      content: "你开心吗",
+      toContactId: 1,
+      fromUser: getContact(1),
+    },
+  ],
+
+
+
 };

+ 3 - 1
src/components/LemonUI/index.js

@@ -12,6 +12,7 @@ import LemonMessageText from "./components/message/text";
 import lemonMessageImage from "./components/message/image";
 import lemonMessageFile from "./components/message/file";
 import lemonMessageEvent from "./components/message/event";
+import LemonMessageVoice from "./components/message/voice";
 
 import LemonIMUI from "./components/index";
 import "./styles/common/index.styl";
@@ -30,7 +31,8 @@ const components = [
   LemonMessageText,
   lemonMessageImage,
   lemonMessageFile,
-  lemonMessageEvent
+  lemonMessageEvent,
+  LemonMessageVoice
 ];
 const install = (Vue) => {
   Vue.directive("LemonContextmenu", Contextmenu);

+ 1 - 1
src/views/crm/customerVisit/index.vue

@@ -323,7 +323,7 @@
       else{
         this.queryParams.receiveTimeRange=null;
       }
-        listCustomerVisit(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
+      listCustomerVisit(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
           this.customerVisitList = response.rows;
           this.total = response.total;
           this.loading = false;

+ 1 - 1
src/views/qw/qwAccounts/index.vue

@@ -47,7 +47,7 @@
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
-            v-if="scope.row.availableDevice == -1"
+            v-if="scope.row.availableDevice >= -1"
             size="mini"
             type="text"
             icon="el-icon-edit"

+ 1 - 1
src/views/qw/qwChat/index.vue

@@ -43,7 +43,7 @@ import { getDeviceId} from '@/api/qw/account';
 
 import Search from '@/components/HeaderSearch'
 
-import LemonMessageVoice from "@/components/LemonUI/components/lemon-message-voice";
+import LemonMessageVoice from "@/components/LemonUI/components/message/voice";
 import ContactsData from "@/components/LemonUI/database/contacts";
 import MessagesData from "@/components/LemonUI/database/messages";
 import EmojiData from "@/components/LemonUI/database/emoji";

+ 76 - 48
src/views/qw/qwChat/qq.vue

@@ -22,8 +22,10 @@
           @send="handleSend">
           <template #cover>
                 <div class="cover">
-                <i class="lemon-icon-message"></i>
-                <p><b>自定义封面 Lemon</b>IMUI</p>
+                    <!-- <i class="lemon-icon-message"></i>
+                    <p>
+                        <b>自定义封面 Lemon</b>IMUI
+                    </p> -->
                 </div>
           </template>
           <template #message-title="contact">
@@ -101,13 +103,13 @@
 import store from "@/store";
 import { getQrCode } from '@/api/qw/login';
 import { getDeviceId} from '@/api/qw/account';
-import LemonMessageVoice from "@/components/LemonUI/components/lemon-message-voice";
-import { getContacts,getContactsByUser} from '@/api/qw/im';
+import LemonMessageVoice from "@/components/LemonUI/components/message/voice";
+import { getContactsByUser,getConversation,getMessageList} from '@/api/qw/im';
 import ContactsData from "@/components/LemonUI/database/contacts";
 import MessagesData from "@/components/LemonUI/database/messages";
 import EmojiData from "@/components/LemonUI/database/emoji";
 import '@/components/LemonUI/index.css';
-
+let pages = {};
 export default {
   name: "qqChat",
   components: {  },
@@ -248,14 +250,21 @@ export default {
         displayName: "June",
         avatar: "https://p.qqan.com/up/2018-4/15244505348390471.jpg",
       },
+      contactData:null,
+      conversationData:null,
       windowWidth: document.documentElement.clientWidth*0.65,  //实时屏幕宽度
       windowHeight: document.documentElement.clientHeight*0.7,   //实时屏幕高度
+      queryParams: {
+          pageNum: 1,
+          pageSize: 10,
+          conversationId: null,
+        },
     };
   },
   created(){
      this.initSocket();
-     this.$store.dispatch('qwLoginOut').then(() => {
-     });
+    //  this.$store.dispatch('qwLoginOut').then(() => {
+    //  });
   },
   mounted() {
     this.qwUser=store.getters.qwUser;
@@ -266,8 +275,11 @@ export default {
         }, 2000);
         return;
     }
+    this.UserData.id=this.qwUser.userId;
+    this.UserData.displayName=this.qwUser.nickName;
+    this.UserData.avatar=this.qwUser.avatar;
     this.showQW=true;
-    this.getContacts(this.qwUser.deviceId);
+
     const contactData1 = {
             id: "contact-1",
             displayName: "工作协作群",
@@ -301,17 +313,23 @@ export default {
             lastSendTime: 3,
             lastContent: "你好123",
     };
-
     const IMUI = this.$refs.IMUI;
     
-    IMUI.initContacts(ContactsData);
-
-    var conversationData = ContactsData.filter(item => item.id<=13);
+    var conversationData = ContactsData.filter(item => item.id<=1688856679458971);
     conversationData.sort((a1, a2) => {
       return a2.lastSendTime - a1.lastSendTime;
     });
 
-    IMUI.initConversations(conversationData);
+    this.getContacts();  //获取联系人信息
+    this.getConversation();   //获取会话信息
+   
+    //  IMUI.initContacts(ContactsData);
+
+    //  IMUI.initConversations(conversationData);
+
+    // setTimeout(() => {
+    //     IMUI.changeContact(1688856679458971);
+    // }, 500);
   
     IMUI.initMenus([
       {
@@ -368,22 +386,14 @@ export default {
       },
     ]);
 
-    IMUI.initEmoji(EmojiData);  
-
-    //  setTimeout(() => {
-    //     IMUI.changeContact("13");
-    // }, 500);
+    IMUI.initEmoji(EmojiData); 
   
   },
 
   methods: {
-        initSocket() {
+    initSocket() {
                let that=this;
               if(!!this.qwIm.socket){
-                  // this.qwIm.initSocket(userId,true);
-                  // this.qwIm.socket.onopen = function() {
-                  //         console.log("socket连接成功");
-                  // };
                   this.qwIm.socket.onerror = function() {
                       console.log("连接错误")
                   };
@@ -407,14 +417,32 @@ export default {
                         console.log("socket已经关闭")
                   };
               }
-      },
-    getContacts(){
+    },
+    getContacts(){  
       getContactsByUser(this.qwUser.userId).then(response => {
            this.contactData = response.data;
            this.$refs.IMUI.initContacts(this.contactData);
-           console.log("qxj request contactData:"+JSON.stringify(this.contactData));
+           //console.log("qxj request contactData:"+JSON.stringify(this.contactData));
+      });
+    },
+    getConversation(){
+      let that=this;
+      const IMUI = this.$refs.IMUI;
+      getConversation(this.qwUser.userId).then(response => {
+           this.conversationData = response.data;
+           IMUI.initConversations(response.data);
+           var fstConversation=this.conversationData[0];
+           //console.log("qxj fstConversation:"+JSON.stringify(fstConversation));
+           if(fstConversation){
+                IMUI.changeContact(fstConversation.conversationId);
+                // setTimeout(() => {
+                //      IMUI.changeContact(1688856679458971);
+                // }, 500);
+           }
+           //console.log("qxj request conversation:"+JSON.stringify(response.data));
       });
     },
+
     messageTimeFormat(time) {
       console.log("qxj messageTimeFormat:"+time);
       return this.friendlyDate(time);
@@ -448,31 +476,31 @@ export default {
       this.IMUI.openDrawer(params);
     },
     handlePullMessages(contact, next,instance) {
-      const { IMUI } = this.$refs;
-      console.log("qxj instance:"+instance.getMessages(instance.currentContactId));
-      setTimeout(() => {
-            var tmessages=MessagesData[contact.id];
-            let messages= tmessages.sort((c1, c2) => c1.sendTime - c2.sendTime);
-            var currentMsgs=instance.getMessages(instance.currentContactId);
-            var sorMsgs=[];
-            var num=0
-            for (let index = currentMsgs.length; index < messages.length; index++) {
-                const item = messages[index];
-                if(num>=5){
-                    break;
-                }
-                sorMsgs.push(item);
-                num++;
-            }
-            let isEnd = false;
-            if (currentMsgs.length+sorMsgs.length>=messages.length){
-                isEnd = true;
-            }
-           next(MessagesData[contact.id], isEnd);
-      }, 3000);
+       const { IMUI } = this.$refs;
+      //console.log("qxj instance:"+instance.getMessages(instance.currentContactId));
+       let isEnd = false;
+       getMessageList(this.queryParams).then(response => {
+          if(response.code==200){
+               isEnd=response.data.isLastPage;
+               next(response.data.list, isEnd);
+               if(!isEnd){
+                   pages[contact.conversationId]++;
+               }
+          }
+      });
+      // setTimeout(() => {
+      //       let isEnd = true;
+      //       next(MessagesData[contact.id], isEnd);
+      // }, 2000);
+
     },
     handleChangeContact(contact, instance) {
         console.log("qxj contact:"+JSON.stringify(contact));
+        if (!pages[contact.conversationId]){
+            pages[contact.conversationId] =1;
+        }
+       this.queryParams.pageNum=pages[contact.conversationId];
+       this.queryParams.conversationId=contact.conversationId;
         //instance.updateContact(contact);
         instance.closeDrawer();
     },

+ 1 - 1
src/views/qw/qwChat/qq2.vue

@@ -102,7 +102,7 @@ import store from "@/store";
 import { getQrCode } from '@/api/qw/login';
 import { getDeviceId} from '@/api/qw/account';
 import { getContacts} from '@/api/qw/im';
-import LemonMessageVoice from "@/components/LemonUI/components/lemon-message-voice";
+import LemonMessageVoice from "@/components/LemonUI/components/message/voice";
 import ContactsData from "@/components/LemonUI/database/contacts";
 import MessagesData from "@/components/LemonUI/database/messages";
 import EmojiData from "@/components/LemonUI/database/emoji";

+ 4 - 1
src/views/qw/qwLogin/index.vue

@@ -4,6 +4,7 @@
       <el-row v-loading="loading" align="middle" justify="center">
         <el-col :span="24">
           <el-card class="scan-card" shadow="hover">
+
             <div class="scan-card-content">
               <h1 class="title">扫码登录</h1>
                <el-form-item label="账号" prop="account" style="width:100%" v-if="!showVerifyCode">
@@ -19,7 +20,10 @@
                 </div>
               </div>
             </div>
+
+
           </el-card>
+
         </el-col>
       </el-row>
      </el-form>
@@ -100,7 +104,6 @@ export default {
                   }
               });
     },
-
     loginAction(){
               const account = this.qwForm.account;
               this.loading=true;