From 8cf2a617ebe288dab97ca123fb8629d8d3c49042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B6=E5=A3=AB=E6=B6=B5?= <630892807@qq.com> Date: Wed, 1 Jul 2020 22:30:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=AE=A2=E6=9C=8D=E8=A1=A8?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/kefu.go | 9 ++++++- server.go | 43 +----------------------------- static/html/setting_bottom.html | 31 ++++++++++++++++++--- static/html/setting_kefu_list.html | 14 +++++----- 4 files changed, 43 insertions(+), 54 deletions(-) diff --git a/controller/kefu.go b/controller/kefu.go index a06417e..f03df5d 100644 --- a/controller/kefu.go +++ b/controller/kefu.go @@ -14,10 +14,17 @@ func GetKefuInfo(c *gin.Context){ info["avator"]=user.Avator c.JSON(200, gin.H{ "code": 200, - "msg": "获取成功", + "msg": "ok", "result":info, }) } +func PostKefuInfo(c *gin.Context){ + c.JSON(200, gin.H{ + "code": 200, + "msg": "ok", + "result":"aaa", + }) +} func GetKefuList(c *gin.Context){ users:=models.FindUsers() c.JSON(200, gin.H{ diff --git a/server.go b/server.go index 3b55722..911294b 100644 --- a/server.go +++ b/server.go @@ -7,8 +7,6 @@ import ( "github.com/taoshihan1991/imaptool/middleware" "github.com/taoshihan1991/imaptool/tmpl" "log" - "net/http" - "time" ) var ( port string @@ -43,6 +41,7 @@ func main() { engine.GET("/chat_server", controller.NewChatServer) //获取客服信息 engine.GET("/kefuinfo",middleware.JwtApiMiddleware, controller.GetKefuInfo) + engine.POST("/kefuinfo",middleware.JwtApiMiddleware, controller.PostKefuInfo) engine.GET("/kefulist",middleware.JwtApiMiddleware, controller.GetKefuList) //设置页 engine.GET("/setting", tmpl.PageSetting) @@ -53,45 +52,5 @@ func main() { engine.GET("/visitor",middleware.JwtApiMiddleware, controller.GetVisitor) engine.GET("/visitors",middleware.JwtApiMiddleware, controller.GetVisitors) engine.GET("/setting_kefu_list",tmpl.PageKefuList) - //------------------old code----------------------------- - mux := &http.ServeMux{} - //根路径 - mux.HandleFunc("/", controller.ActionIndex) - //邮件夹 - mux.HandleFunc("/list", controller.ActionFolder) - //邮件夹接口 - mux.HandleFunc("/folders", controller.FoldersList) - //新邮件夹接口 - mux.HandleFunc("/folder_dirs", controller.FolderDir) - //邮件接口 - mux.HandleFunc("/mail", controller.FolderMail) - //详情界面 - mux.HandleFunc("/view", controller.ActionDetail) - //写信界面 - mux.HandleFunc("/write", controller.ActionWrite) - //框架界面 - mux.HandleFunc("/main", controller.ActionMain) - //设置界面 - mux.HandleFunc("/setting", controller.ActionSetting) - //设置账户接口 - mux.HandleFunc("/setting_account", controller.SettingAccount) - //发送邮件接口 - mux.HandleFunc("/send", controller.FolderSend) - //新邮件提醒服务 - mux.HandleFunc("/push_mail", controller.PushMailServer) - //mux.Handle("/chat_server", websocket.Handler(controller.ChatServer)) - //后台任务 - //监听端口 - //http.ListenAndServe(":8080", nil) - //var myHandler http.Handler - s := &http.Server{ - Addr: ":8080", - Handler: mux, - ReadTimeout: 30 * time.Second, - WriteTimeout: 30 * time.Second, - MaxHeaderBytes: 1 << 20, - } - //---------------old code end------------------ engine.Run(baseServer) - s.ListenAndServe() } diff --git a/static/html/setting_bottom.html b/static/html/setting_bottom.html index 0d97c11..4d3909f 100644 --- a/static/html/setting_bottom.html +++ b/static/html/setting_bottom.html @@ -33,6 +33,12 @@ username: [ { required: true, message: '请输入用户名', trigger: 'blur' }, ], + name: [ + { required: true, message: '请输入用户名', trigger: 'blur' }, + ], + avator: [ + { required: true, message: '请选择头像', trigger: 'blur' }, + ], password: [ { required: true, message: '请输入密码', trigger: 'blur' }, ], @@ -121,7 +127,7 @@ initInfo(){ let _this=this; if(ACTION=="setting_mysql"){ - this.getAjax("/mysql",{},function(result){ + this.sendAjax("/mysql","get",{},function(result){ _this.mysql.username=result.Username; _this.mysql.password=result.Password; _this.mysql.database=result.Database; @@ -130,16 +136,16 @@ }); } if(ACTION=="setting_kefu_list"){ - this.getAjax("/kefulist",{},function(result){ + this.sendAjax("/kefulist","get",{},function(result){ _this.kefuList=result; }); } }, - getAjax(url,params,callback){ + sendAjax(url,method,params,callback){ let _this=this; $.ajax({ - type: "get", + type: method, url: url, headers: { "token": localStorage.getItem("token") @@ -161,6 +167,23 @@ //添加客服的dialog addKefu(){ this.kefuDialog=true; + }, + //提交客服表单 + submitKefuForm(formName){ + let _this=this; + this.$refs[formName].validate((valid) => { + if (valid) { + this.sendAjax("/kefuinfo","post",_this.kefuForm,function(result){ + _this.$message({ + message: data.msg, + type: 'success' + }); + _this.kefuDialog=false; + }); + } else { + return false; + } + }); } }, created: function () { diff --git a/static/html/setting_kefu_list.html b/static/html/setting_kefu_list.html index 2e07041..64b2142 100644 --- a/static/html/setting_kefu_list.html +++ b/static/html/setting_kefu_list.html @@ -44,20 +44,20 @@ :visible.sync="kefuDialog" width="30%" > - - + + - - + + - - + + 取 消 - 确 定 + 确 定