|
|
@@ -19,7 +19,8 @@
|
|
|
serverTimeoutObj:null,
|
|
|
apiToken:'',
|
|
|
linkfailure:true,
|
|
|
- Messagenum:0
|
|
|
+ Messagenum:0,
|
|
|
+ kfuser_info:{}
|
|
|
}
|
|
|
},
|
|
|
methods:{
|
|
|
@@ -37,6 +38,17 @@
|
|
|
this.$websocket.onerror = this.websocketonerror;//链接错误提示
|
|
|
this.$websocket.onclose = this.socket_close;//链接断开提示
|
|
|
},
|
|
|
+ // 得到保存好的当前客服信息
|
|
|
+ getCustomerUserInfo()
|
|
|
+ {
|
|
|
+
|
|
|
+ if(typeof this.$store.getters.get_user_info != 'string'){
|
|
|
+ this.kfuser_info = this.$store.getters.get_user_info;
|
|
|
+ }else if(this.$store.getters.get_user_info!= ""){
|
|
|
+ this.kfuser_info = JSON.parse(this.$store.getters.get_user_info);
|
|
|
+ }
|
|
|
+ return this.kfuser_info;
|
|
|
+ },
|
|
|
|
|
|
/**************************************/
|
|
|
//连接成功
|
|
|
@@ -44,11 +56,7 @@
|
|
|
console.log('已经链接');
|
|
|
let user_info = '';
|
|
|
// console.log(this.$store.getters.get_user_info != "");
|
|
|
- if(typeof this.$store.getters.get_user_info != 'string'){
|
|
|
- user_info = this.$store.getters.get_user_info;
|
|
|
- }else if(this.$store.getters.get_user_info!= ""){
|
|
|
- user_info = JSON.parse(this.$store.getters.get_user_info);
|
|
|
- }
|
|
|
+ user_info=this.getCustomerUserInfo();
|
|
|
|
|
|
if(user_info){
|
|
|
this.$websocket.send(JSON.stringify({
|
|
|
@@ -75,6 +83,15 @@
|
|
|
//this.init()
|
|
|
this.reconnect();
|
|
|
},
|
|
|
+ getVisitorList(){
|
|
|
+ this.kfuser_info=this.getCustomerUserInfo();
|
|
|
+ this.$websocket.send(JSON.stringify({
|
|
|
+ type: 'kfusersmaps',
|
|
|
+ data: {
|
|
|
+ kfuid: this.kfuser_info.id
|
|
|
+ }
|
|
|
+ }));
|
|
|
+ },
|
|
|
|
|
|
/******************************************/
|
|
|
//数据接收
|
|
|
@@ -92,12 +109,15 @@
|
|
|
|
|
|
if(redata.type == "pong") return false;
|
|
|
if(redata.type != "pong" || redata.message_type != "ping"){
|
|
|
- console.log(redata);
|
|
|
+
|
|
|
if(redata.message_type === 'connct') {
|
|
|
this.$store.dispatch("SET_SESSSION_USER", redata.data.user_info);
|
|
|
}
|
|
|
}
|
|
|
+ this.getVisitorList();
|
|
|
+ console.log(redata);
|
|
|
let getters = this.$store.getters;
|
|
|
+ console.log({'getters':this.$store})
|
|
|
//获取vuex数据
|
|
|
let session = getters.get_session;//会话列表
|
|
|
let offline = getters.get_offline;//离线列表
|
|
|
@@ -275,6 +295,7 @@
|
|
|
this.$token = '';
|
|
|
this.$router.push('/login')
|
|
|
this.linkfailure = true;
|
|
|
+
|
|
|
//this.reconnect();
|
|
|
},
|
|
|
|