diff --git a/server.go b/server.go index 70a4c98..e892a04 100644 --- a/server.go +++ b/server.go @@ -61,6 +61,10 @@ func main() { //前台接口 engine.GET("/notice", controller.GetNotice) + //前台引入js接口 + engine.GET("/webjs", tmpl.PageWebJs) + //前台引入css接口 + engine.GET("/webcss", tmpl.PageWebCss) //配置文件 engine.Run(baseServer) } diff --git a/static/html/chat_web.css b/static/html/chat_web.css new file mode 100644 index 0000000..901f6d5 --- /dev/null +++ b/static/html/chat_web.css @@ -0,0 +1,5 @@ +.chatBtn{ + position: fixed; + right: 10px; + bottom: 10px; +} diff --git a/static/html/chat_web.js b/static/html/chat_web.js new file mode 100644 index 0000000..f1dbe76 --- /dev/null +++ b/static/html/chat_web.js @@ -0,0 +1,52 @@ +var loadJs=function(url,callback){ + var script = document.createElement('script'), fn = callback || function(){}; + script.type = 'text/javascript'; + //IE + if(script.readyState){ + script.onreadystatechange = function(){ + if( script.readyState == 'loaded' || script.readyState == 'complete' ){ + script.onreadystatechange = null; + fn(); + } + }; + }else{ + //其他浏览器 + script.onload = function(){ + fn(); + }; + } + script.src = url; + document.getElementsByTagName('head')[0].appendChild(script); +}; +loadJs("https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js",function(){ + loadJs("https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/layer.min.js" ,function () { + $(function () { + //==================================================================== + var div =document.createElement('div'); + div.id ='goflyKefu'; + div.className +='goflyKefu'; + document.body.appendChild(div); + var w =document.getElementById('goflyKefu'); + w.innerHTML='
在线咨询
'; + + $("#goflyKefu").click(function () { + $("#goflyKefu").hide(); + layer.open({ + type: 2, + title: '在线咨询', + shadeClose: true, + shade: false, + maxmin: true, //开启最大化最小化按钮 + area: ['660px', '600px'], + content: ['http://gofly.sopans.com/chat_page','no'], + end: function(){ + $("#goflyKefu").show(); + } + }); + }); + //--------------------------------------------------------------- + }) + }); +}); + + diff --git a/tmpl/setting.go b/tmpl/setting.go index 89ef38a..7d1a5bd 100644 --- a/tmpl/setting.go +++ b/tmpl/setting.go @@ -18,6 +18,14 @@ func PageSettingMysql(c *gin.Context) { "action":"setting_mysql", }) } +//前台js部署 +func PageWebJs(c *gin.Context){ + c.HTML(http.StatusOK, "chat_web.js",nil) +} +//前台css部署 +func PageWebCss(c *gin.Context){ + c.HTML(http.StatusOK, "chat_web.css",nil) +} func PageKefuList(c *gin.Context) { c.HTML(http.StatusOK, "setting_kefu_list.html", gin.H{ "tab_index":"1-2",