From 4981077643d35437a20fe570fcc2358b05c5cdac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B6=E5=A3=AB=E6=B6=B5?= <630892807@qq.com> Date: Sun, 31 Jan 2021 21:52:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/css/gofly-front.css | 1 + static/html/chat_page.html | 4 +-- static/html/index.html | 3 ++- static/js/chat-lang.js | 8 ++++-- static/js/gofly-front.js | 50 ++++++++++++++++++++++++++++++++------ 5 files changed, 54 insertions(+), 12 deletions(-) diff --git a/static/css/gofly-front.css b/static/css/gofly-front.css index 5e66b9b..fca39c1 100644 --- a/static/css/gofly-front.css +++ b/static/css/gofly-front.css @@ -17,6 +17,7 @@ box-shadow: 0 3px 15px 0 rgba(0,0,0,.25)!important; position: absolute; bottom: 60px; + right: 0; color: #222; line-height: 1.5; font-size: 14px; diff --git a/static/html/chat_page.html b/static/html/chat_page.html index 9cd71e3..6a8c30e 100644 --- a/static/html/chat_page.html +++ b/static/html/chat_page.html @@ -45,7 +45,7 @@
- +
- GO-FLY1.0.0客服陶士涵提供技术支持 + <{flyLang.copyright}>
diff --git a/static/html/index.html b/static/html/index.html index ed5219e..1d278ac 100644 --- a/static/html/index.html +++ b/static/html/index.html @@ -24,7 +24,8 @@ GOFLY.init({ GOFLY_URL:"", GOFLY_KEFU_ID: "kefu2", - GOFLY_BTN_TEXT: "{{.OnlineChat}}" + GOFLY_BTN_TEXT: "{{.OnlineChat}}", + GOFLY_LANG:"{{.Lang}}" }) diff --git a/static/js/chat-lang.js b/static/js/chat-lang.js index 1fdbc62..7e24254 100644 --- a/static/js/chat-lang.js +++ b/static/js/chat-lang.js @@ -5,12 +5,16 @@ var GOFLY_LANG={ "connectok":"连接成功!", "chating":"正在与您沟通!", "historymes":"—— 以上是历史消息 ——", + "copyright":"GO-FLY1.0.0客服陶士涵提供技术支持", + "textarea":"请输入内容", }, "en":{ - "sent":"sent", + "sent":"Send", "connecting":"connecting...", "connectok":"connection succeeded!", "chating":"chating with you!", - "historymes":"—— above is old messages ——", + "historymes":"—— Today ——", + "copyright":"We run on GOFLY", + "textarea":"Enter your message", }, }; \ No newline at end of file diff --git a/static/js/gofly-front.js b/static/js/gofly-front.js index 1bbe48c..886ee18 100644 --- a/static/js/gofly-front.js +++ b/static/js/gofly-front.js @@ -2,26 +2,40 @@ var GOFLY={ GOFLY_URL:"https://gofly.sopans.com", GOFLY_KEFU_ID:"", GOFLY_BTN_TEXT:"Chat with me", + GOFLY_LANG:"en", }; GOFLY.launchButtonFlag=false; GOFLY.titleTimer=0; GOFLY.titleNum=0; +GOFLY.noticeTimer=null; GOFLY.originTitle=document.title; GOFLY.init=function(config){ + var _this=this; if(typeof config=="undefined"){ return; } + if (typeof config.GOFLY_URL!="undefined"){ this.GOFLY_URL=config.GOFLY_URL; } + this.dynamicLoadCss(this.GOFLY_URL+"/static/css/gofly-front.css?v=1"); + if (typeof config.GOFLY_KEFU_ID!="undefined"){ this.GOFLY_KEFU_ID=config.GOFLY_KEFU_ID; } if (typeof config.GOFLY_BTN_TEXT!="undefined"){ this.GOFLY_BTN_TEXT=config.GOFLY_BTN_TEXT; } - this.dynamicLoadCss(this.GOFLY_URL+"/static/css/gofly-front.css?v=1"); - var _this=this; + + this.dynamicLoadJs(this.GOFLY_URL+"/static/js/functions.js?v=1",function(){ + _this.GOFLY_LANG=checkLang(); + if (typeof config.GOFLY_LANG!="undefined"){ + this.GOFLY_LANG=config.GOFLY_LANG; + }else{ + this.GOFLY_LANG=config.GOFLY_LANG; + } + }); + if (typeof $!="function"){ this.dynamicLoadJs("https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js",function () { _this.dynamicLoadJs("https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/layer.min.js",function () { @@ -83,9 +97,31 @@ GOFLY.clickBtn=function (){ _this.showKefu(); }); setTimeout(function(){ - $("#launchButtonNotice").show(); - $("#launchIcon").show(); - },4000); + // $("#launchButtonNotice").show(); + // $("#launchIcon").show(); + _this.getNotice(); + },3000); +} +GOFLY.getNotice=function(){ + $.get("/notice?kefu_id="+this.GOFLY_KEFU_ID,function(res) { + //debugger; + if (res.result != null) { + var msg = res.result; + var len=msg.length; + var i=0; + if(len>0){ + if(typeof msg[0]=="undefined"||msg[0]==null){ + return; + } + var content = msg[0]; + if(typeof content.content =="undefined"){ + return; + } + $("#launchButtonNotice").html(replaceContent(content.content)).show(); + } + + } + }); } GOFLY.isIE=function(){ var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串 @@ -142,7 +178,7 @@ GOFLY.layerOpen=function (){ area: ['520px', '530px'], offset: 'rb', //右下角弹出 anim: 2, - content: [this.GOFLY_URL+'/chatIndex?kefu_id='+this.GOFLY_KEFU_ID+'&refer='+window.document.title, 'yes'], //iframe的url,no代表不显示滚动条 + content: [this.GOFLY_URL+'/chatIndex?kefu_id='+this.GOFLY_KEFU_ID+'&lang='+this.GOFLY_LANG+'&refer='+window.document.title, 'yes'], //iframe的url,no代表不显示滚动条 end: function(){ _this.launchButtonFlag=false; $(".launchButtonBox").show(); @@ -150,7 +186,7 @@ GOFLY.layerOpen=function (){ }); } GOFLY.windowOpen=function (){ - window.open(this.GOFLY_URL+'/chatIndex?kefu_id='+this.GOFLY_KEFU_ID+'&refer='+window.document.title); + window.open(this.GOFLY_URL+'/chatIndex?kefu_id='+this.GOFLY_KEFU_ID+'&lang='+this.GOFLY_LANG+'&refer='+window.document.title); } GOFLY.flashTitle=function () { this.titleNum++;