增加访客端显示是否在线

pull/23/head
taoshihan1991 3 years ago
commit 085c90ccd4

@ -7,6 +7,7 @@ import (
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/taoshihan1991/imaptool/models" "github.com/taoshihan1991/imaptool/models"
"github.com/taoshihan1991/imaptool/tools" "github.com/taoshihan1991/imaptool/tools"
"github.com/taoshihan1991/imaptool/ws"
"log" "log"
"net/http" "net/http"
"time" "time"
@ -27,6 +28,12 @@ func GetNotice(c *gin.Context) {
} }
result = append(result, h) result = append(result, h)
} }
status := "online"
if kefus, ok := ws.KefuList[kefuId]; !ok {
if len(kefus) <= 0 {
status = "offline"
}
}
c.JSON(200, gin.H{ c.JSON(200, gin.H{
"code": 200, "code": 200,
"msg": "ok", "msg": "ok",
@ -34,6 +41,7 @@ func GetNotice(c *gin.Context) {
"welcome": result, "welcome": result,
"username": user.Nickname, "username": user.Nickname,
"avatar": user.Avator, "avatar": user.Avator,
"status": status,
}, },
}) })
} }

@ -103,10 +103,13 @@
height: 30px; height: 30px;
border-radius: 50%; border-radius: 50%;
display: inline-block; display: inline-block;
border:1px solid #cccccc; border:2px solid #fff;
float: left; float: left;
margin-right: 5px; margin-right: 5px;
} }
.layui-layer-title .flyAvatar{
margin-top: 5px;
}
.launchButtonNotice .flyUsername{ .launchButtonNotice .flyUsername{
font-weight: bold; font-weight: bold;
float: left; float: left;
@ -130,6 +133,20 @@
#layui-layer1{ #layui-layer1{
display: none; display: none;
} }
.launchPointer{
background: #3cc51f;
width: 10px;
height: 10px;
display: inline-block;
border-radius: 50%;
position: absolute;
top: 25px;
left: 42px;
border:2px solid #fff;
}
.launchPointer.offline{
background: #ce3c39;
}
@-webkit-keyframes bounce-up { @-webkit-keyframes bounce-up {
25% {-webkit-transform: translateY(4px);} 25% {-webkit-transform: translateY(4px);}
50%, 100% {-webkit-transform: translateY(0);} 50%, 100% {-webkit-transform: translateY(0);}

@ -119,7 +119,12 @@ GOFLY.clickBtn=function (){
GOFLY.getNotice=function(){ GOFLY.getNotice=function(){
var _this=this; var _this=this;
$.get(this.GOFLY_URL+"/notice?kefu_id="+this.GOFLY_KEFU_ID,function(res) { $.get(this.GOFLY_URL+"/notice?kefu_id="+this.GOFLY_KEFU_ID,function(res) {
_this.chatPageTitle="<img style='margin-top: 5px;' src='"+_this.GOFLY_URL+res.result.avatar+"' class='flyAvatar'>"+res.result.username; if(res.result.status=='offline'){
_this.chatPageTitle="<div class='launchPointer offline'></div>";
}else{
_this.chatPageTitle="<div class='launchPointer'></div>";
}
_this.chatPageTitle+="<img src='"+_this.GOFLY_URL+res.result.avatar+"' class='flyAvatar'>"+res.result.username;
if(_this.GOFLY_AUTO_OPEN){ if(_this.GOFLY_AUTO_OPEN){
_this.showKefu(); _this.showKefu();
$(".launchButtonBox").show(); $(".launchButtonBox").show();

Loading…
Cancel
Save