更改js API

pull/23/head
taoshihan1991 3 years ago
parent 5949ee3408
commit 52a3630566

@ -9,6 +9,15 @@
<meta name="keywords" content="GO-FLY,GOFLY客服,开源免费在线客服,GO语言客服,免费客服,开源客服,web客服,go客服,网站客服系统,免费在线客服,网站在线客服,在线客服软件" />
<meta name="description" content="GOFLY客服,GO-FLY开源客服一套可独立部署的免费开源客服系统下载zip解压即可仅依赖MySQL数据库是一个开箱即用的网页在线客服适合PHP程序员使用同时也是首页完全可以编辑的单页营销系统." />
<link rel="stylesheet" type="text/css" href="../css/style.css" />
<!--对接客服代码,安装完成后更改成自己的域名或IP下面js文件路径以及GOFLY_URL都要改-->
<script src="http://127.0.0.1:8081/static/js/gofly-front.js?v=1"></script>
<script>
GOFLY.init({
GOFLY_URL:"http://127.0.0.1:8081",
GOFLY_KEFU_ID: "kefu2",
})
</script>
<!--//对接客服代码-->
</head>
<body>
<div class="header">
@ -126,20 +135,10 @@
<div class="container">
<div class="footer">
<div class="copyright">
Copyright Your sopans.com Rights Reserved. Powered By <a href="https://gofly.sopans.com">陶士涵</a> 版权所有© 2020-2021
Copyright sopans.com Rights Reserved. Powered By <a href="https://gofly.sopans.com">陶士涵</a> 版权所有<a href="javascript:GOFLY.showPanel();">联系客服</a>© 2020-2021
</div>
</div>
</div>
<!--对接客服代码,安装完成后更改成自己的域名或IP下面js文件路径以及GOFLY_URL都要改-->
<script src="/static/js/gofly-front.js?v=1"></script>
<script>
GOFLY.init({
GOFLY_URL:"",
GOFLY_KEFU_ID: "kefu2",
GOFLY_BTN_TEXT: "GOFLY在线客服!",
GOFLY_LANG:"cn",
})
</script>
<!--//对接客服代码-->
</body>
</html>

@ -5,6 +5,8 @@ var GOFLY={
GOFLY_LANG:"en",
GOFLY_EXTRA: {},
GOFLY_AUTO_OPEN:true,
GOFLY_AUTO_SHOW:false,
GOFLY_WITHOUT_BTN:false,
};
GOFLY.launchButtonFlag=false;
GOFLY.titleTimer=0;
@ -37,6 +39,12 @@ GOFLY.init=function(config){
if (typeof config.GOFLY_AUTO_OPEN!="undefined"){
this.GOFLY_AUTO_OPEN=config.GOFLY_AUTO_OPEN;
}
if (typeof config.GOFLY_AUTO_SHOW!="undefined"){
this.GOFLY_AUTO_SHOW=config.GOFLY_AUTO_SHOW;
}
if (typeof config.GOFLY_WITHOUT_BTN!="undefined"){
this.GOFLY_WITHOUT_BTN=config.GOFLY_WITHOUT_BTN;
}
var refer=document.referrer?document.referrer:"无";
this.GOFLY_EXTRA.refer=refer;
this.GOFLY_EXTRA.host=document.location.href;
@ -50,19 +58,55 @@ GOFLY.init=function(config){
}
_this.GOFLY_EXTRA=utf8ToB64(_this.GOFLY_EXTRA);
});
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 () {
_this.clickBtn();
_this.jsCallBack();
});
});
}else{
this.dynamicLoadJs("https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/layer.min.js",function () {
_this.clickBtn();
_this.jsCallBack();
});
}
_this.addEventlisten();
}
GOFLY.jsCallBack=function(){
this.showKefuBtn();
this.addClickEvent();
this.getNotice();
}
GOFLY.showKefuBtn=function(){
var _this=this;
if(_this.GOFLY_WITHOUT_BTN){
return;
}
var html="<div class='launchButtonBox'>" +
'<div id="launchButton" class="launchButton">' +
'<div id="launchIcon" class="launchIcon animateUpDown">1</div> ' +
'<div class="launchButtonText">'+_this.GOFLY_BTN_TEXT+'</div></div>' +
'<div id="launchButtonNotice" class="launchButtonNotice"></div>' +
'</div>';
$('body').append(html);
}
GOFLY.addClickEvent=function(){
var _this=this;
$(".launchButton").on("click",function() {
_this.showKefu();
$("#launchIcon").text(0).hide();
});
$("body").on("click","#launchNoticeClose",function() {
$("#launchButtonNotice").hide();
});
$("body").click(function () {
clearTimeout(_this.titleTimer);
document.title = _this.originTitle;
});
}
GOFLY.addEventlisten=function(){
var _this=this;
window.addEventListener('message',function(e){
var msg=e.data;
if(msg.type=="message"){
@ -116,27 +160,11 @@ GOFLY.dynamicLoadJs=function(url, callback){
head.appendChild(script);
}
GOFLY.clickBtn=function (){
var _this=this;
var html="<div class='launchButtonBox'>" +
'<div id="launchButton" class="launchButton">' +
'<div id="launchIcon" class="launchIcon animateUpDown">1</div> ' +
'<div class="launchButtonText">'+_this.GOFLY_BTN_TEXT+'</div></div>' +
'<div id="launchButtonNotice" class="launchButtonNotice">您好:<br/>极简强大的开源免费Go语言在线客服单页营销系统来了解一下</div>' +
'</div>';
$('body').append(html);
$(".launchButton").on("click",function() {
_this.showKefu();
$("#launchIcon").text(0).hide();
});
$("body").on("click","#launchNoticeClose",function() {
$("#launchButtonNotice").hide();
});
_this.getNotice();
}
GOFLY.getNotice=function(){
var _this=this;
if(!_this.GOFLY_AUTO_OPEN){
return;
}
$.get(this.GOFLY_URL+"/notice?kefu_id="+this.GOFLY_KEFU_ID,function(res) {
if(res.result.status=='offline'){
_this.chatPageTitle="<div class='launchPointer offline'></div>";
@ -176,8 +204,10 @@ GOFLY.getNotice=function(){
welcomeHtml+="<div id='launchNoticeContent'>"+replaceContent(content.content,_this.GOFLY_URL)+"</div>";
var obj=$("#launchButtonNotice");
obj[0].innerHTML=welcomeHtml;
obj.show();
if(obj[0]){
obj[0].innerHTML=welcomeHtml;
obj.show();
}
i++;
$("#launchIcon").text(i).show();
},4000);
@ -214,6 +244,20 @@ GOFLY.isIE=function(){
return -1;//不是ie浏览器
}
}
GOFLY.showPanel=function (){
var width=$(window).width();
this.GOFLY_AUTO_SHOW=true;
if(this.isIE()>0){
this.windowOpen();
return;
}
if(width<768){
this.layerOpen("100%","100%");
return;
}
this.layerOpen("400px","530px");
this.launchButtonFlag=true;
}
GOFLY.showKefu=function (){
if (this.launchButtonFlag) return;
var width=$(window).width();
@ -228,15 +272,6 @@ GOFLY.showKefu=function (){
this.layerOpen("400px","530px");
this.launchButtonFlag=true;
$(".launchButtonBox").hide();
var _this=this;
$("body").click(function () {
clearTimeout(_this.titleTimer);
document.title = _this.originTitle;
});
window.onfocus = function () {
clearTimeout(_this.titleTimer);
document.title = _this.originTitle;
};
}
GOFLY.layerOpen=function (width,height){
if (this.launchButtonFlag) return;
@ -258,7 +293,8 @@ GOFLY.layerOpen=function (width,height){
content: [this.GOFLY_URL+'/chatIndex?kefu_id='+this.GOFLY_KEFU_ID+'&lang='+this.GOFLY_LANG+'&refer='+window.document.title+'&extra='+this.GOFLY_EXTRA , 'yes'], //iframe的urlno代表不显示滚动条
success:function(){
var layBox=$("#layui-layer19911116");
if(!_this.GOFLY_AUTO_OPEN && layBox.css("display")=="none"){
if(_this.GOFLY_AUTO_SHOW&&layBox.css("display")=="none"){
_this.launchButtonFlag=true;
layBox.show();
}
},

Loading…
Cancel
Save