提交客服表单

pull/30/head
陶士涵 4 years ago
parent f9e85cbffe
commit 8cf2a617eb

@ -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{

@ -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()
}

@ -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 () {

@ -44,20 +44,20 @@
:visible.sync="kefuDialog"
width="30%"
>
<el-form ref="kefuForm" :model="kefuForm" label-width="70px">
<el-form-item label="用户名">
<el-form ref="kefuForm" :model="kefuForm" :rules="rules" label-width="70px">
<el-form-item label="用户名" prop="name">
<el-input v-model="kefuForm.name"></el-input>
</el-form-item>
<el-form-item label="密码">
<el-input v-model="kefuForm.name"></el-input>
<el-form-item label="密码" prop="password">
<el-input v-model="kefuForm.password"></el-input>
</el-form-item>
<el-form-item label="头像">
<el-input v-model="kefuForm.name"></el-input>
<el-form-item label="头像" prop="avator">
<el-input v-model="kefuForm.avator"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="kefuDialog = false">取 消</el-button>
<el-button type="primary" @click="kefuDialog = false">确 定</el-button>
<el-button type="primary" @click="submitKefuForm('kefuForm')">确 定</el-button>
</span>
</el-dialog>
</template>

Loading…
Cancel
Save