修复对不同访客聊天

pull/30/head
taoshihan1991 5 years ago
parent 346bcf34ad
commit c832e6cd5a

@ -143,6 +143,11 @@
});
this.users = redata.data;
this.currentGuest = redata.data[0].uid;
for(i=0;i<redata.data.length;i++){
if (typeof (this.msgListUser[redata.data[i].uid]) == "undefined") {
this.msgListUser[redata.data[i].uid] = [];
}
}
}
if (redata.type == "chatMessage") {
@ -166,7 +171,12 @@
talkTo(guestId) {
this.currentGuest = guestId;
this.msgList = [];
this.msgList=this.clone(this.msgListUser[guestId]);
let buf = [];
var i = this.msgListUser[guestId].length;
while (i--) {
buf[i] = this.msgListUser[guestId][i];
}
this.msgList = buf;
},
//发送给客户
chatToUser() {
@ -194,26 +204,6 @@
}
this.msgListUser[this.currentGuest].push(content);
},
clone(Obj){
var buf;
if(Obj instanceof Array){
buf=[];
var i=Obj.length;
while(i--){
buf[i]=clone(Obj[i]);
}
return buf;
}else if(Obj instanceof Object){
buf={};
for(var k in Obj){
buf[k]=clone(Obj[k]);
}
return buf;
}else{
return Obj;
}
},
},
created: function () {
this.getOnlineUsers();

Loading…
Cancel
Save