引入模式简化

pull/23/head
taoshihan1991 4 years ago
parent 585823d1c6
commit 7106eab177

@ -165,17 +165,10 @@
</footer>
<!--对接客服代码-->
<script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/layer.min.js"></script>
<link href="/static/css/gofly-front.css" rel="stylesheet" type="text/css"/>
<div id="launchButton" class="launchButton animateUpDown">
<div class="launchButtonText">
Chat with me
</div>
</div>
<script>
var GOFLY_URL="";
var GOFLY_KEFU_ID="kefu2";
var GOFLY_BTN_TEXT="Chat with me";
</script>
<script src="/static/js/gofly-front.js"></script>
<!--//对接客服代码-->

@ -6,19 +6,12 @@
<el-main class="mainMain">
<el-tabs>
<el-tab-pane label="HTML模式">
<el-tab-pane label="默认JS模式">
<textarea style="width:100%;color:green;font-size:12px;height:290px;">
<script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/layer.min.js"></script>
<link href="/static/css/gofly-front.css" rel="stylesheet" type="text/css"/>
<div id="launchButton" class="launchButton animateUpDown">
<div class="launchButtonText">
Chat with me
</div>
</div>
<script>
var GOFLY_URL="";
var GOFLY_KEFU_ID="[客服用户名]";
var GOFLY_KEFU_ID="kefu2";
var GOFLY_BTN_TEXT="Chat with me";
</script>
<script src="/static/js/gofly-front.js"></script>
</textarea>

@ -1,5 +1,31 @@
var launchButtonFlag=false;
$("#launchButton").click(function() {
var titleTimer,titleNum=0;
var originTitle = document.title;
if (typeof GOFLY_URL=="undefined"){
var GOFLY_URL="https://gofly.sopans.com";
}
if (typeof GOFLY_KEFU_ID=="undefined"){
var GOFLY_KEFU_ID="";
}
if (typeof GOFLY_BTN_TEXT=="undefined"){
var GOFLY_BTN_TEXT="Chat with me";
}
dynamicLoadCss(GOFLY_URL+"/static/css/gofly-front.css");
if (typeof $!="function"){
dynamicLoadJs("https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js",function () {
dynamicLoadJs("https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/layer.min.js",function () {
clickBtn();
});
});
}else{
dynamicLoadJs("https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/layer.min.js",function () {
clickBtn();
});
}
function clickBtn(){
$('body').append('<div id="launchButton" class="launchButton animateUpDown"><div class="launchButtonText">'+GOFLY_BTN_TEXT+'</div></div>');
$("#launchButton").on("click",function() {
if (launchButtonFlag) return;
var width=$(window).width();
if(width<768){
@ -8,7 +34,7 @@ $("#launchButton").click(function() {
}
layer.open({
type: 2,
title: "Chat with me",
title: GOFLY_BTN_TEXT,
closeBtn: 1, //不显示关闭按钮
shade: [0],
area: ['520px', '530px'],
@ -23,12 +49,38 @@ $("#launchButton").click(function() {
launchButtonFlag=true;
$(".launchButton").hide();
});
$("body").click(function () {
clearTimeout(titleTimer);
document.title = originTitle;
});
}
function dynamicLoadCss(url) {
var head = document.getElementsByTagName('head')[0];
var link = document.createElement('link');
link.type='text/css';
link.rel = 'stylesheet';
link.href = url;
head.appendChild(link);
}
function dynamicLoadJs(url, callback) {
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
if(typeof(callback)=='function'){
script.onload = script.onreadystatechange = function () {
if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete"){
callback();
script.onload = script.onreadystatechange = null;
}
};
}
head.appendChild(script);
}
var titleTimer,titleNum=0;
var originTitle = document.title;
function flashTitle() {
titleNum++;
if (titleNum == 3) {
if (titleNum >=3) {
titleNum = 1;
}
if (titleNum == 1) {
@ -49,3 +101,4 @@ window.onfocus = function () {
clearTimeout(titleTimer);
document.title = originTitle;
};

Loading…
Cancel
Save