客服控制前端代码优化

pull/30/head
taoshihan1991 4 years ago
parent d948979187
commit 442cc1d7cd

@ -87,6 +87,12 @@
</div>
</body>
<script>
var kfConfig={};
kfConfig.kf_id = "kf_1";
kfConfig.kf_name = "客服丽丽";
kfConfig.avatar = "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=4217138672,2588039002&fm=26&gp=0.jpg";
kfConfig.group = "1";
var app=new Vue({
el: '#app',
delimiters:["<{","}>"],
@ -122,14 +128,9 @@
this.socket.onopen = this.OnOpen;
},
OnOpen() {
let data = {};
let mes = {}
mes.type = "kfOnline";
data.kf_id = "kf_1";
data.kf_name = "客服丽丽";
data.avatar = "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=4217138672,2588039002&fm=26&gp=0.jpg";
data.group = "1";
mes.data = data;
mes.data = kfConfig;
this.socket.send(JSON.stringify(mes));
},
OnMessage(e) {
@ -180,36 +181,27 @@
this.msgList = buf;
//发送给客户我在线
let data = {};
let mes = {}
mes.type = "kfOnline";
data.kf_id = "kf_1";
data.kf_name = "客服丽丽";
data.avatar = "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=4217138672,2588039002&fm=26&gp=0.jpg";
data.group = "1";
mes.data = data;
kfConfig.guest_id=guestId;
mes.data = kfConfig;
this.socket.send(JSON.stringify(mes));
},
//发送给客户
chatToUser() {
let mes = {};
let data = {};
mes.type = "kfChatMessage";
data.content = this.messageContent;
data.kf_id = "kf_1";
data.guest_id = this.currentGuest;
data.kf_name = "客服丽丽";
data.avatar = "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=4217138672,2588039002&fm=26&gp=0.jpg";
mes.data = data;
kfConfig.content = this.messageContent;
mes.data = kfConfig;
this.socket.send(JSON.stringify(mes));
this.messageContent = "";
let content = {}
content.avatar = data.avatar;
content.name = data.kf_name;
content.content = data.content;
content.avatar = kfConfig.avatar;
content.name = kfConfig.kf_name;
content.content = kfConfig.content;
content.is_kefu = true;
content.time = data.time;
content.time = '';
this.msgList.push(content);
if (typeof (this.msgListUser[this.currentGuest]) == "undefined") {
this.msgListUser[this.currentGuest] = [];
@ -218,7 +210,6 @@
},
},
created: function () {
this.getOnlineUsers();
this.initConn();
}
})

Loading…
Cancel
Save