|
@@ -115,22 +115,23 @@ export default {
|
|
this.channel();
|
|
this.channel();
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- ...customer(['online', 'record', 'createChat']),
|
|
|
|
|
|
+ ...customer(['online', 'record', 'createChat', 'chatRecord']),
|
|
search() {},
|
|
search() {},
|
|
- chatBtn(data) {
|
|
|
|
|
|
+ // 点击获取客户聊天列表
|
|
|
|
+ async chatBtn(data) {
|
|
this.$set(this, `chatUserInfo`, data);
|
|
this.$set(this, `chatUserInfo`, data);
|
|
|
|
+ let arr = await this.chatRecord({ client_id: data.client_id, customer_id: data.customer_id });
|
|
|
|
+ if (this.$checkRes(arr)) {
|
|
|
|
+ this.$set(this, `chatList`, arr.data);
|
|
|
|
+ this.scrollToBottom();
|
|
|
|
+ }
|
|
|
|
+ this.chatChannel();
|
|
},
|
|
},
|
|
// 区分发言人
|
|
// 区分发言人
|
|
isSender(data) {
|
|
isSender(data) {
|
|
- return data.id != '客服';
|
|
|
|
- },
|
|
|
|
- //获取客户列表
|
|
|
|
- async getClientList() {
|
|
|
|
- const res = await this.record({ _tenant: this._tenant, customer_id: this.user.id });
|
|
|
|
- if (this.$checkRes(res)) {
|
|
|
|
- this.$set(this, `userList`, res.data);
|
|
|
|
- }
|
|
|
|
|
|
+ return data.sender_id != this.user.id;
|
|
},
|
|
},
|
|
|
|
+ // 查询客服列表
|
|
channel() {
|
|
channel() {
|
|
this.$stomp({
|
|
this.$stomp({
|
|
[`/exchange/${this._tenant}/customer.${this.user.id}`]: this.onMessage,
|
|
[`/exchange/${this._tenant}/customer.${this.user.id}`]: this.onMessage,
|
|
@@ -141,7 +142,12 @@ export default {
|
|
console.log('receive a message: ', message.body);
|
|
console.log('receive a message: ', message.body);
|
|
if (message.body === 'research') this.getClientList();
|
|
if (message.body === 'research') this.getClientList();
|
|
},
|
|
},
|
|
-
|
|
|
|
|
|
+ async getClientList() {
|
|
|
|
+ const res = await this.record({ _tenant: this._tenant, customer_id: this.user.id });
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ this.$set(this, `userList`, res.data);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
async toOnline() {
|
|
async toOnline() {
|
|
console.log('in function:');
|
|
console.log('in function:');
|
|
const time = 5000; //1min 600000
|
|
const time = 5000; //1min 600000
|
|
@@ -181,6 +187,25 @@ export default {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ chatChannel() {
|
|
|
|
+ this.$stomp({
|
|
|
|
+ [`/exchange/${this._tenant}/customer.${this.chatUserInfo.client_id}.${this.chatUserInfo.customer_id}`]: this.chatMessage,
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ chatMessage(message) {
|
|
|
|
+ let body = _.get(message, 'body');
|
|
|
|
+ if (body) {
|
|
|
|
+ body = JSON.parse(body);
|
|
|
|
+ this.chatList.push(body);
|
|
|
|
+ this.scrollToBottom();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ scrollToBottom: function() {
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ var container = this.$el.querySelector('.right_2');
|
|
|
|
+ container.scrollTop = container.scrollHeight;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
...mapState(['user', '_tenant']),
|
|
...mapState(['user', '_tenant']),
|