diff --git a/controller/reply.go b/controller/reply.go index 69b7c9b..2c2c070 100644 --- a/controller/reply.go +++ b/controller/reply.go @@ -25,6 +25,15 @@ func GetReplys(c *gin.Context) { "result": res, }) } +func GetAutoReplys(c *gin.Context) { + kefu_id := c.Query("kefu_id") + res := models.FindReplyTitleByUserId(kefu_id) + c.JSON(200, gin.H{ + "code": 200, + "msg": "ok", + "result": res, + }) +} func PostReply(c *gin.Context) { var replyForm ReplyForm kefuId, _ := c.Get("kefu_name") diff --git a/models/replys.go b/models/replys.go index 8170c7a..8cb5381 100644 --- a/models/replys.go +++ b/models/replys.go @@ -35,6 +35,22 @@ func FindReplyByUserId(userId interface{}) []*ReplyGroup { } return replyGroups } +func FindReplyTitleByUserId(userId interface{}) []*ReplyGroup { + var replyGroups []*ReplyGroup + //DB.Raw("select a.*,b.* from reply_group a left join reply_item b on a.id=b.group_id where a.user_id=? ", userId).Scan(&replyGroups) + var replyItems []*ReplyItem + DB.Where("user_id = ?", userId).Find(&replyGroups) + DB.Select("item_name,group_id").Where("user_id = ?", userId).Find(&replyItems) + temp := make(map[string]*ReplyGroup) + for _, replyGroup := range replyGroups { + replyGroup.Items = make([]*ReplyItem, 0) + temp[replyGroup.Id] = replyGroup + } + for _, replyItem := range replyItems { + temp[replyItem.GroupId].Items = append(temp[replyItem.GroupId].Items, replyItem) + } + return replyGroups +} func CreateReplyGroup(groupName string, userId string) { g := &ReplyGroup{ GroupName: groupName, diff --git a/router/api.go b/router/api.go index 2674b04..fd1e10c 100644 --- a/router/api.go +++ b/router/api.go @@ -84,6 +84,7 @@ func InitApiRouter(engine *gin.Engine) { engine.GET("/configs", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.GetConfigs) engine.POST("/config", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.PostConfig) engine.GET("/config", controller.GetConfig) + engine.GET("/autoreply", controller.GetAutoReplys) 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) diff --git a/static/css/common.css b/static/css/common.css index 225f7f0..f2faf5c 100644 --- a/static/css/common.css +++ b/static/css/common.css @@ -422,5 +422,16 @@ } .kefuFuncBox .el-textarea{width: 99%;} .kefuFolderBtn{vertical-align: middle;} +.visitorReply{ + font-size: 14px; + line-height: 24px; +} +.visitorReplyTitle{ + +} +.visitorReplyContent{ + color:#007aff; + cursor: pointer; +} .iconBtnsBox .kefuSendBtn{margin-right: 4px;float: right;} .clear{clear:both;} \ No newline at end of file diff --git a/static/html/chat_page.html b/static/html/chat_page.html index 85cf22d..d0efae3 100644 --- a/static/html/chat_page.html +++ b/static/html/chat_page.html @@ -28,6 +28,21 @@ type="success">
 <{flyLang['moremessage']}>
+ + + + +
<{noticeName}>
+
+
+
<{reply.group_name}>
+
<{item.item_name}>
+
+
+
+
+
+
<{v.time}>
diff --git a/static/js/chat-page.js b/static/js/chat-page.js index b04352a..27794a9 100644 --- a/static/js/chat-page.js +++ b/static/js/chat-page.js @@ -19,6 +19,9 @@ new Vue({ sendDisabled:false, flyLang:GOFLY_LANG[LANG], textareaFocused:false, + replys:[], + noticeName:"", + noticeAvatar:"", }, methods: { //初始化websocket @@ -283,6 +286,10 @@ new Vue({ } }, + sendReply:function(title){ + this.messageContent=title; + this.chatToUser(); + }, //获取日期 getNowDate : function() {// 获取日期 var d = new Date(new Date()); @@ -307,6 +314,8 @@ new Vue({ let _this=this; $.get("/notice?kefu_id="+KEFU_ID,function(res) { //debugger; + _this.noticeName=res.result.username; + _this.noticeAvatar=res.result.avatar; if (res.result.welcome != null) { let msg = res.result.welcome; var len=msg.length; @@ -532,6 +541,15 @@ new Vue({ } }); }, + //自动 + getAutoReply:function(){ + var _this=this; + $.get("/autoreply?kefu_id="+KEFU_ID,function(res) { + if(res.code==200){ + _this.replys=res.result; + } + }); + }, //提示音 alertSound:function(){ var b = document.getElementById("chatMessageAudio"); @@ -567,6 +585,6 @@ new Vue({ //this.scrollBottom(); //获取欢迎 this.getNotice(); - + this.getAutoReply(); } })