diff --git a/cmd/js/chat-main.js b/cmd/js/chat-main.js index 9712b30..251bd03 100644 --- a/cmd/js/chat-main.js +++ b/cmd/js/chat-main.js @@ -2,6 +2,7 @@ var app=new Vue({ el: '#app', delimiters:["<{","}>"], data: { + visible:false, chatTitleType:"info", fullscreenLoading:true, leftTabActive:"first", @@ -41,12 +42,14 @@ var app=new Vue({ otherKefus:[], replyGroupDialog:false, replyContentDialog:false, + editReplyContentDialog:false, replySearch:"", replySearchList:[], replySearchListActive:[], groupName:"", groupId:"", replys:[], + replyId:"", replyContent:"", replyTitle:"", ipBlacks:[], @@ -102,6 +105,7 @@ var app=new Vue({ case "userOnline": this.addOnlineUser(redata.data); + break; case "userOffline": this.removeOfflineUser(redata.data); @@ -119,6 +123,7 @@ var app=new Vue({ break; } + if (redata.type == "message") { let msg = redata.data let content = {} @@ -148,6 +153,7 @@ var app=new Vue({ name:msg.name, body: msg.content, icon: msg.avator + }); _this.alertSound(); _this.chatInputing=""; @@ -214,6 +220,7 @@ var app=new Vue({ // content.is_kefu = true; // content.time = ''; // this.msgList.push(content); + _this.sendDisabled=false; this.scrollBottom(); }, //处理当前在线用户列表 @@ -237,6 +244,9 @@ var app=new Vue({ break; } } + if(this.visitor.visitor_id==retData.uid){ + this.getVistorInfo(retData.uid) + } }, //处理当前在线用户列表 @@ -386,6 +396,9 @@ var app=new Vue({ type: 'error' }); } + if(data.code==400){ + window.location.href="/login"; + } } }); }, @@ -500,6 +513,9 @@ var app=new Vue({ } }); }, + replaceContent(content){ + return replaceContent(content) + }, //滚到底部 scrollBottom(){ this.$nextTick(() => { @@ -747,6 +763,27 @@ var app=new Vue({ _this.getReplys(); }); }, + //编辑回复 + editReplyContent(save,id,title,content){ + var _this=this; + if(save=='yes'){ + var data={ + reply_id:this.replyId, + reply_title:this.replyTitle, + reply_content:this.replyContent + } + this.sendAjax("/reply_content_save","post",data,function(result){ + _this.editReplyContentDialog=false; + _this.getReplys(); + }); + }else{ + this.editReplyContentDialog=true; + this.replyId=id; + this.replyTitle=title; + this.replyContent=content; + } + + }, //搜索回复 searchReply(){ var _this=this; @@ -779,6 +816,7 @@ var app=new Vue({ }, //划词搜索 selectText(){ + return false; var _this=this; $('body').click(function(){ try{ diff --git a/cmd/templates/chat_main.html b/cmd/templates/chat_main.html index 2013e2a..1da14c8 100644 --- a/cmd/templates/chat_main.html +++ b/cmd/templates/chat_main.html @@ -24,6 +24,7 @@ white-space: nowrap; color: #999; } + .chatBoxMe .el-col-3{float: right;text-align: right;} .chatBoxMe .chatUser{text-align: right} .chatBox{width: 100%;height:calc(100% - 175px);;overflow-y: auto;overflow-x: hidden;} @@ -31,7 +32,7 @@ -
+
- -
<{item.item_name}>
-
+ +
+
+
<{item.item_name}>
+
+ 编辑 删除
+添加回复内容 - -删除组 + +

确定删除吗?

+
+ 取消 + 确定 +
+ -删除组 +
+
@@ -270,6 +289,19 @@ 取 消 + + + + + 保 存 + 取 消 + +
diff --git a/controller/reply.go b/controller/reply.go index 2c2c070..2bb2f23 100644 --- a/controller/reply.go +++ b/controller/reply.go @@ -68,6 +68,24 @@ func PostReplyContent(c *gin.Context) { "msg": "ok", }) } +func PostReplyContentSave(c *gin.Context) { + kefuId, _ := c.Get("kefu_name") + replyId := c.PostForm("reply_id") + replyTitle := c.PostForm("reply_title") + replyContent := c.PostForm("reply_content") + if replyId == "" || replyTitle == "" || replyContent == "" { + c.JSON(400, gin.H{ + "code": 200, + "msg": "参数错误!", + }) + return + } + models.UpdateReplyContent(replyId, kefuId.(string), replyTitle, replyContent) + c.JSON(200, gin.H{ + "code": 200, + "msg": "ok", + }) +} func DelReplyContent(c *gin.Context) { kefuId, _ := c.Get("kefu_name") id := c.Query("id") diff --git a/controller/visitor.go b/controller/visitor.go index 7aea8a4..443fa72 100644 --- a/controller/visitor.go +++ b/controller/visitor.go @@ -258,11 +258,10 @@ func GetVisitorOnlines(c *gin.Context) { // @Router /visitors_kefu_online [get] func GetKefusVisitorOnlines(c *gin.Context) { kefuName, _ := c.Get("kefu_name") - roleId, _ := c.Get("kefu_id") users := make([]*VisitorOnline, 0) visitorIds := make([]string, 0) for uid, visitor := range ws.ClientList { - if visitor.To_id != kefuName && roleId.(float64) != 2 { + if visitor.To_id != kefuName { continue } userInfo := new(VisitorOnline) diff --git a/models/replys.go b/models/replys.go index 8cb5381..6efe406 100644 --- a/models/replys.go +++ b/models/replys.go @@ -67,6 +67,13 @@ func CreateReplyContent(groupId string, userId string, content, itemName string) } DB.Create(g) } +func UpdateReplyContent(id, userId, title, content string) { + r := &ReplyItem{ + ItemName: title, + Content: content, + } + DB.Model(&ReplyItem{}).Where("user_id = ? and id = ?", userId, id).Update(r) +} func DeleteReplyContent(id string, userId string) { DB.Where("user_id = ? and id = ?", userId, id).Delete(ReplyItem{}) } diff --git a/router/api.go b/router/api.go index 238f1b6..4e66fba 100644 --- a/router/api.go +++ b/router/api.go @@ -84,6 +84,7 @@ func InitApiRouter(engine *gin.Engine) { engine.GET("/replys", middleware.JwtApiMiddleware, controller.GetReplys) engine.POST("/reply", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.PostReply) engine.POST("/reply_content", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.PostReplyContent) + engine.POST("/reply_content_save", middleware.JwtApiMiddleware, controller.PostReplyContentSave) engine.DELETE("/reply_content", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.DelReplyContent) engine.DELETE("/reply", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.DelReplyGroup) engine.POST("/reply_search", middleware.JwtApiMiddleware, controller.PostReplySearch) diff --git a/static/css/common.css b/static/css/common.css index 220fd67..2c78d2f 100644 --- a/static/css/common.css +++ b/static/css/common.css @@ -321,7 +321,7 @@ line-height: 21px; font-size: 14px; } -.chatContent a{color: #07a9fe;text-decoration: none;} +a{color: #07a9fe;text-decoration: none;} .chatContent:before,.chatContent:after { content: ""; display: block; @@ -439,4 +439,4 @@ cursor: pointer; } .iconBtnsBox .kefuSendBtn{margin-right: 4px;float: right;} -.clear{clear:both;} \ No newline at end of file +.clear{clear:both;}