guhongwei 3 years ago
parent
commit
062d2a1b32
1 changed files with 15 additions and 4 deletions
  1. 15 4
      src/views/customer/index.vue

+ 15 - 4
src/views/customer/index.vue

@@ -1,5 +1,8 @@
 <template>
   <div id="index">
+    <el-input v-model="customer_id" placeholder=""></el-input>
+    <el-input v-model="customer_name" placeholder=""></el-input>
+    <el-button type="primary" @click="toChannel()">连接</el-button>
     <el-row>
       <el-col :span="24" class="main">
         <el-col :span="4" class="left">
@@ -107,20 +110,22 @@ export default {
       // 用户头像
       rightIcon: require('@a/leftIcon.png'),
       // 用户列表
+      activeIndex: '',
       userList: [],
       // 聊天列表
       chatUserInfo: {},
       chatList: [],
       content: '',
-      activeIndex: '',
+      customer_id: '5f6ad08fbe2d3b407b41a693',
+      customer_name: '客服1',
     };
   },
   created() {
-    this.toOnline();
+    // this.toOnline();
     this.getClientList();
   },
   mounted() {
-    this.channel();
+    // this.channel();
   },
   methods: {
     ...customer(['online', 'record', 'createChat', 'chatRecord']),
@@ -161,7 +166,7 @@ export default {
       console.log('in function:');
       const time = 5000; //1min 600000
       setInterval(() => {
-        this.online({ _tenant: this._tenant, customer_id: this.user.id, customer_name: this.user.name });
+        this.online({ _tenant: this._tenant, customer_id: this.customer_id, customer_name: this.customer_name });
       }, time);
     },
     getTime(item) {
@@ -215,6 +220,12 @@ export default {
         container.scrollTop = container.scrollHeight;
       });
     },
+    toChannel() {
+      this.toOnline();
+      this.$stomp({
+        [`/exchange/${this._tenant}/customer.${this.customer_id}`]: this.onMessage,
+      });
+    },
   },
   computed: {
     ...mapState(['user', '_tenant']),