From 90c77e661f1d462eb724a049194a77deaad82cea Mon Sep 17 00:00:00 2001 From: taoshihan1991 <630892807@qq.com> Date: Wed, 10 Feb 2021 11:07:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=8F=90=E7=A4=BA=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/notice.go | 12 ++++++++---- static/css/gofly-front.css | 20 +++++++++++++++++++- static/js/chat-page.js | 4 ++-- static/js/gofly-front.js | 36 ++++++++++++++++++++++-------------- 4 files changed, 51 insertions(+), 21 deletions(-) diff --git a/controller/notice.go b/controller/notice.go index 22ad845..6b3c438 100644 --- a/controller/notice.go +++ b/controller/notice.go @@ -28,9 +28,13 @@ func GetNotice(c *gin.Context) { result = append(result, h) } c.JSON(200, gin.H{ - "code": 200, - "msg": "ok", - "result": result, + "code": 200, + "msg": "ok", + "result": gin.H{ + "welcome": result, + "username": user.Nickname, + "avatar": user.Avator, + }, }) } func GetNotices(c *gin.Context) { @@ -56,7 +60,7 @@ func PostNoticeSave(c *gin.Context) { kefuId, _ := c.Get("kefu_name") content := c.PostForm("content") id := c.PostForm("id") - models.UpdateWelcome(fmt.Sprintf("%s", kefuId),id, content) + models.UpdateWelcome(fmt.Sprintf("%s", kefuId), id, content) c.JSON(200, gin.H{ "code": 200, "msg": "ok", diff --git a/static/css/gofly-front.css b/static/css/gofly-front.css index e53765a..9c31c6b 100644 --- a/static/css/gofly-front.css +++ b/static/css/gofly-front.css @@ -5,6 +5,7 @@ left: auto!important; } .launchButtonNotice{ + width: 270px; padding: 10px; margin: 0 auto; display: block; @@ -85,7 +86,24 @@ padding: 0!important; transition: .6s ease-in-out!important; } - +.launchButtonNotice .flyAvatar{ + width: 30px; + height: 30px; + border-radius: 50%; + display: inline-block; + border:1px solid #cccccc; + float: left; +} +.launchButtonNotice .flyUsername{ + font-weight: bold; + float: left; + margin-left: 4px; +} +.launchButtonNotice .flyUser{ + height: 32px; + overflow: hidden; + line-height: 32px; +} @-webkit-keyframes bounce-up { 25% {-webkit-transform: translateY(6px);} 50%, 100% {-webkit-transform: translateY(0);} diff --git a/static/js/chat-page.js b/static/js/chat-page.js index 424ccd6..2881e93 100644 --- a/static/js/chat-page.js +++ b/static/js/chat-page.js @@ -248,8 +248,8 @@ new Vue({ let _this=this; $.get("/notice?kefu_id="+KEFU_ID,function(res) { //debugger; - if (res.result != null) { - let msg = res.result; + if (res.result.welcome != null) { + let msg = res.result.welcome; var len=msg.length; var i=0; if(len>0){ diff --git a/static/js/gofly-front.js b/static/js/gofly-front.js index 21a47f2..9a11aff 100644 --- a/static/js/gofly-front.js +++ b/static/js/gofly-front.js @@ -95,28 +95,36 @@ GOFLY.clickBtn=function (){ $(".launchButtonBox").on("click",function() { _this.showKefu(); }); - setTimeout(function(){ - $("#launchIcon").show(); - _this.getNotice(); - },4000); + _this.getNotice(); } GOFLY.getNotice=function(){ var _this=this; $.get(this.GOFLY_URL+"/notice?kefu_id="+this.GOFLY_KEFU_ID,function(res) { //debugger; - if (res.result != null) { - var msg = res.result; + if (res.result.welcome != null) { + var msg = res.result.welcome; 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,_this.GOFLY_URL)).show(); + + _this.noticeTimer=setInterval(function(){ + if(i==0){ + $("#launchIcon").text(len).show(); + } + if(i>=len||typeof msg[i]=="undefined"||msg[i]==null){ + clearInterval(_this.noticeTimer); + return; + } + var content = msg[i]; + if(typeof content.content =="undefined"){ + return; + } + content.content = replaceContent(content.content); + var welcomeHtml="
"+res.result.username+"
"; + welcomeHtml+="
"+replaceContent(content.content,_this.GOFLY_URL)+"
"; + $("#launchButtonNotice").html(welcomeHtml).show(); + i++; + },4000); } }