guhongwei 4 лет назад
Родитель
Сommit
0f825c22b8
1 измененных файлов с 7 добавлено и 5 удалено
  1. 7 5
      src/components/parts/chat.vue

+ 7 - 5
src/components/parts/chat.vue

@@ -58,11 +58,13 @@ export default {
       text: '',
       hand: require('@/assets/emotion/hand.gif'),
       flower: require('@/assets/emotion/flower.gif'),
+      dock_id: '',
     };
   },
   created() {
     //回车事件
     // this.enterListen();
+    this.$set(this, 'dock_id', this.$route.query.id);
     this.search();
   },
   mounted() {
@@ -71,7 +73,7 @@ export default {
   methods: {
     ...chat(['query', 'create']),
     async search() {
-      const res = await this.query({ skip: 0, limit: 10 });
+      const res = await this.query({ skip: 0, limit: 10, dock_id: this.dock_id });
       if (this.$checkRes(res)) this.$set(this, `list`, _.reverse(res.data));
     },
     async send() {
@@ -80,7 +82,7 @@ export default {
         return;
       }
       if (this.text != '') {
-        let object = { sender_name: this.user.name ? this.user.name : this.user.adminuser, content: this.text };
+        let object = { sender_name: this.user.name ? this.user.name : this.user.adminuser, content: this.text, dock_id: this.dock_id };
         if (this.user.uid) {
           object.sender_id = this.user.uid;
           object.role = this.user.role;
@@ -90,7 +92,7 @@ export default {
       } else this.$message.error('请输入信息后发送');
     },
     async fastSend(word) {
-      let object = { sender_name: this.user.name ? this.user.name : this.user.adminuser, content: word };
+      let object = { sender_name: this.user.name ? this.user.name : this.user.adminuser, content: word, dock_id: this.dock_id };
       if (this.user.uid) {
         object.sender_id = this.user.uid;
         object.role = this.user.role;
@@ -100,7 +102,7 @@ export default {
       }
     },
     async sendEmotion(type) {
-      let object = { sender_name: this.user.name ? this.user.name : this.user.adminuser };
+      let object = { sender_name: this.user.name ? this.user.name : this.user.adminuser, dock_id: this.dock_id };
       let content = '';
       content = `<img src='${_.get(this, `${type}`)}' style="width:30px;height:30px" />`;
       object.content = content;
@@ -116,7 +118,7 @@ export default {
     },
     channel() {
       this.$stomp({
-        [`/exchange/public_chat`]: this.onMessage,
+        [`/exchange/public_chat/${this.dock_id}`]: this.onMessage,
       });
     },
     onMessage(message) {