diff --git a/static/html/chat_page.html b/static/html/chat_page.html index be8c281..9cd71e3 100644 --- a/static/html/chat_page.html +++ b/static/html/chat_page.html @@ -53,7 +53,7 @@
- {{.SendBtn}} + <{flyLang.sent}>
GO-FLY1.0.0客服陶士涵提供技术支持 @@ -73,6 +73,8 @@ + diff --git a/static/js/chat-lang.js b/static/js/chat-lang.js new file mode 100644 index 0000000..1fdbc62 --- /dev/null +++ b/static/js/chat-lang.js @@ -0,0 +1,16 @@ +var GOFLY_LANG={ + "cn":{ + "sent":"发送", + "connecting":"正在连接...", + "connectok":"连接成功!", + "chating":"正在与您沟通!", + "historymes":"—— 以上是历史消息 ——", + }, + "en":{ + "sent":"sent", + "connecting":"connecting...", + "connectok":"connection succeeded!", + "chating":"chating with you!", + "historymes":"—— above is old messages ——", + }, +}; \ No newline at end of file diff --git a/static/js/chat-page.js b/static/js/chat-page.js index 8307914..a2d3182 100644 --- a/static/js/chat-page.js +++ b/static/js/chat-page.js @@ -4,18 +4,18 @@ new Vue({ delimiters:["<{","}>"], data: { window:window, - //server:getWsBaseUrl()+"/chat_server", server:getWsBaseUrl()+"/ws_visitor", socket:null, msgList:[], messageContent:"", - chatTitle:"正在连接...", + chatTitle:GOFLY_LANG[LANG]['connecting'], visitor:{}, face:[], showKfonline:false, socketClosed:false, timer:null, sendDisabled:false, + flyLang:GOFLY_LANG[LANG], }, methods: { //初始化websocket @@ -30,12 +30,7 @@ new Vue({ this.ping(); }, OnOpen:function() { - this.chatTitle="连接成功!" - // let mes = {} - // mes.type = "userInit"; - // this.visitor.refer=REFER; - // mes.data = this.visitor; - // this.socket.send(JSON.stringify(mes)); + this.chatTitle=GOFLY_LANG[LANG]['connectok']; }, OnMessage:function(e) { const redata = JSON.parse(e.data); @@ -45,7 +40,7 @@ new Vue({ return; } this.visitor.to_id=msg.id; - this.chatTitle=msg.name+",正在与您沟通!" + this.chatTitle=msg.name+","+GOFLY_LANG[LANG]['chating']; $(".chatBox").append("
"+this.chatTitle+"
"); this.scrollBottom(); this.showKfonline=true; @@ -91,14 +86,12 @@ new Vue({ }, //发送给客户 chatToUser:function() { - this.messageContent=this.messageContent.trim("\r\n"); - if(this.messageContent==""||this.messageContent=="\r\n"){ - this.$message({ - message: '不能发送空白信息', - type: 'warning' - }); + var messageContent=this.messageContent.trim("\r\n"); + if(messageContent==""||messageContent=="\r\n"){ + this.messageContent=""; return; } + this.messageContent=messageContent; if(this.socketClosed){ this.$message({ message: '连接关闭!请重新打开页面', @@ -214,7 +207,7 @@ new Vue({ _this.scrollBottom(); } _this.$nextTick(function(){ - $(".chatBox").append("
—— 以上是历史消息 ——
"); + $(".chatBox").append("
"+GOFLY_LANG[LANG]['historymes']+"
"); }); } if(data.code!=200){ diff --git a/static/js/functions.js b/static/js/functions.js index e11146e..5c8249a 100644 --- a/static/js/functions.js +++ b/static/js/functions.js @@ -96,11 +96,6 @@ function bigPic(src,isVisitor){ window.open(src); return; } - // $("#bigPic img").attr("src",src); - // $("#bigPic").show(); - // $("#bigPic img").click(function(){ - // $("#bigPic").hide(); - // }); } function filter (obj){ var imgType = ["image/jpeg","image/png","image/jpg","image/gif"]; @@ -116,4 +111,26 @@ function filter (obj){ function sleep(time) { var startTime = new Date().getTime() + parseInt(time, 10); while(new Date().getTime() < startTime) {} -}; \ No newline at end of file +} +function checkLang(){ + var langs=["cn","en"]; + var lang=getQuery("lang"); + if(lang!=""&&langs.indexOf(lang) > 0 ){ + return lang; + } + return "cn"; +} +function getQuery(key) { + var query = window.location.search.substring(1); + var key_values = query.split("&"); + var params = {}; + key_values.map(function (key_val){ + var key_val_arr = key_val.split("="); + params[key_val_arr[0]] = key_val_arr[1]; + }); + if(typeof params[key]!="undefined"){ + return params[key]; + } + return ""; +} +; \ No newline at end of file