|
|
@ -4,18 +4,18 @@ new Vue({
|
|
|
|
delimiters:["<{","}>"],
|
|
|
|
delimiters:["<{","}>"],
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
|
window:window,
|
|
|
|
window:window,
|
|
|
|
//server:getWsBaseUrl()+"/chat_server",
|
|
|
|
|
|
|
|
server:getWsBaseUrl()+"/ws_visitor",
|
|
|
|
server:getWsBaseUrl()+"/ws_visitor",
|
|
|
|
socket:null,
|
|
|
|
socket:null,
|
|
|
|
msgList:[],
|
|
|
|
msgList:[],
|
|
|
|
messageContent:"",
|
|
|
|
messageContent:"",
|
|
|
|
chatTitle:"正在连接...",
|
|
|
|
chatTitle:GOFLY_LANG[LANG]['connecting'],
|
|
|
|
visitor:{},
|
|
|
|
visitor:{},
|
|
|
|
face:[],
|
|
|
|
face:[],
|
|
|
|
showKfonline:false,
|
|
|
|
showKfonline:false,
|
|
|
|
socketClosed:false,
|
|
|
|
socketClosed:false,
|
|
|
|
timer:null,
|
|
|
|
timer:null,
|
|
|
|
sendDisabled:false,
|
|
|
|
sendDisabled:false,
|
|
|
|
|
|
|
|
flyLang:GOFLY_LANG[LANG],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
methods: {
|
|
|
|
//初始化websocket
|
|
|
|
//初始化websocket
|
|
|
@ -30,12 +30,7 @@ new Vue({
|
|
|
|
this.ping();
|
|
|
|
this.ping();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
OnOpen:function() {
|
|
|
|
OnOpen:function() {
|
|
|
|
this.chatTitle="连接成功!"
|
|
|
|
this.chatTitle=GOFLY_LANG[LANG]['connectok'];
|
|
|
|
// let mes = {}
|
|
|
|
|
|
|
|
// mes.type = "userInit";
|
|
|
|
|
|
|
|
// this.visitor.refer=REFER;
|
|
|
|
|
|
|
|
// mes.data = this.visitor;
|
|
|
|
|
|
|
|
// this.socket.send(JSON.stringify(mes));
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
OnMessage:function(e) {
|
|
|
|
OnMessage:function(e) {
|
|
|
|
const redata = JSON.parse(e.data);
|
|
|
|
const redata = JSON.parse(e.data);
|
|
|
@ -45,7 +40,7 @@ new Vue({
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.visitor.to_id=msg.id;
|
|
|
|
this.visitor.to_id=msg.id;
|
|
|
|
this.chatTitle=msg.name+",正在与您沟通!"
|
|
|
|
this.chatTitle=msg.name+","+GOFLY_LANG[LANG]['chating'];
|
|
|
|
$(".chatBox").append("<div class=\"chatTime\">"+this.chatTitle+"</div>");
|
|
|
|
$(".chatBox").append("<div class=\"chatTime\">"+this.chatTitle+"</div>");
|
|
|
|
this.scrollBottom();
|
|
|
|
this.scrollBottom();
|
|
|
|
this.showKfonline=true;
|
|
|
|
this.showKfonline=true;
|
|
|
@ -91,14 +86,12 @@ new Vue({
|
|
|
|
},
|
|
|
|
},
|
|
|
|
//发送给客户
|
|
|
|
//发送给客户
|
|
|
|
chatToUser:function() {
|
|
|
|
chatToUser:function() {
|
|
|
|
this.messageContent=this.messageContent.trim("\r\n");
|
|
|
|
var messageContent=this.messageContent.trim("\r\n");
|
|
|
|
if(this.messageContent==""||this.messageContent=="\r\n"){
|
|
|
|
if(messageContent==""||messageContent=="\r\n"){
|
|
|
|
this.$message({
|
|
|
|
this.messageContent="";
|
|
|
|
message: '不能发送空白信息',
|
|
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.messageContent=messageContent;
|
|
|
|
if(this.socketClosed){
|
|
|
|
if(this.socketClosed){
|
|
|
|
this.$message({
|
|
|
|
this.$message({
|
|
|
|
message: '连接关闭!请重新打开页面',
|
|
|
|
message: '连接关闭!请重新打开页面',
|
|
|
@ -214,7 +207,7 @@ new Vue({
|
|
|
|
_this.scrollBottom();
|
|
|
|
_this.scrollBottom();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_this.$nextTick(function(){
|
|
|
|
_this.$nextTick(function(){
|
|
|
|
$(".chatBox").append("<div class=\"chatTime\">—— 以上是历史消息 ——</div>");
|
|
|
|
$(".chatBox").append("<div class=\"chatTime\">"+GOFLY_LANG[LANG]['historymes']+"</div>");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(data.code!=200){
|
|
|
|
if(data.code!=200){
|
|
|
|