添加和删除客服

pull/30/head
陶士涵 5 years ago
parent 4c5e4a1139
commit 041a00eee3

@ -4,7 +4,6 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/taoshihan1991/imaptool/models" "github.com/taoshihan1991/imaptool/models"
"github.com/taoshihan1991/imaptool/tools" "github.com/taoshihan1991/imaptool/tools"
"log"
) )
func GetKefuInfo(c *gin.Context){ func GetKefuInfo(c *gin.Context){
@ -20,6 +19,15 @@ func GetKefuInfo(c *gin.Context){
"result":info, "result":info,
}) })
} }
func GetKefuInfoSetting(c *gin.Context){
kefuId := c.Query("kefu_id")
user:=models.FindUserById(kefuId)
c.JSON(200, gin.H{
"code": 200,
"msg": "ok",
"result":user,
})
}
func PostKefuInfo(c *gin.Context){ func PostKefuInfo(c *gin.Context){
name:=c.PostForm("name") name:=c.PostForm("name")
password:=c.PostForm("password") password:=c.PostForm("password")
@ -41,7 +49,6 @@ func GetKefuList(c *gin.Context){
} }
func DeleteKefuInfo(c *gin.Context){ func DeleteKefuInfo(c *gin.Context){
kefuId := c.Query("id") kefuId := c.Query("id")
log.Println(kefuId)
models.DeleteUserById(kefuId) models.DeleteUserById(kefuId)
c.JSON(200, gin.H{ c.JSON(200, gin.H{
"code": 200, "code": 200,

@ -41,6 +41,7 @@ func main() {
engine.GET("/chat_server", controller.NewChatServer) engine.GET("/chat_server", controller.NewChatServer)
//获取客服信息 //获取客服信息
engine.GET("/kefuinfo",middleware.JwtApiMiddleware, controller.GetKefuInfo) engine.GET("/kefuinfo",middleware.JwtApiMiddleware, controller.GetKefuInfo)
engine.GET("/kefuinfo_setting",middleware.JwtApiMiddleware, controller.GetKefuInfoSetting)
engine.POST("/kefuinfo",middleware.JwtApiMiddleware, controller.PostKefuInfo) engine.POST("/kefuinfo",middleware.JwtApiMiddleware, controller.PostKefuInfo)
engine.DELETE("/kefuinfo",middleware.JwtApiMiddleware, controller.DeleteKefuInfo) engine.DELETE("/kefuinfo",middleware.JwtApiMiddleware, controller.DeleteKefuInfo)
engine.GET("/kefulist",middleware.JwtApiMiddleware, controller.GetKefuList) engine.GET("/kefulist",middleware.JwtApiMiddleware, controller.GetKefuList)

@ -50,6 +50,7 @@
password:"", password:"",
avator:"", avator:"",
}, },
kefuSelectAvator:"/static/images/0.jpg",
}, },
methods: { methods: {
//提交表单 //提交表单
@ -187,9 +188,31 @@
} }
}); });
}, },
//编辑客服表单
editKefuForm(formName){
let _this=this;
this.$refs[formName].validate((valid) => {
if (valid) {
_this.sendAjax("/kefulist","PUT",_this.kefuForm,function(result){
_this.kefuList=result;
});
} else {
return false;
}
});
},
//获取客服
getKefu(kefuId){
let _this=this;
this.sendAjax("/kefuinfo_setting","GET",{kefu_id:kefuId},function(result){
_this.kefuDialog=true;
_this.kefuForm=result;
});
},
//删除客服 //删除客服
deleteKefu(kefuId){ deleteKefu(kefuId){
this.sendAjax("/kefuinfo","DELETE",{id:kefuId},function(result){ let _this=this;
this.sendAjax("/kefuinfo?id="+kefuId,"DELETE",{id:kefuId},function(result){
_this.kefuDialog=false; _this.kefuDialog=false;
_this.sendAjax("/kefulist","get",{},function(result){ _this.sendAjax("/kefulist","get",{},function(result){
_this.kefuList=result; _this.kefuList=result;

@ -31,7 +31,7 @@
prop="id" prop="id"
label="操作"> label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button @click="" type="primary" size="small" plain>编辑</el-button> <el-button @click="getKefu(scope.row.id)" type="primary" size="small" plain>编辑</el-button>
<el-button @click="deleteKefu(scope.row.id)" type="danger" size="small" plain>删除</el-button> <el-button @click="deleteKefu(scope.row.id)" type="danger" size="small" plain>删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -52,7 +52,11 @@
<el-input v-model="kefuForm.password"></el-input> <el-input v-model="kefuForm.password"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="头像" prop="avator"> <el-form-item label="头像" prop="avator">
<el-input v-model="kefuForm.avator"></el-input> <el-select v-model="kefuForm.avator" placeholder="请选择头像">
<el-option :label="'头像'+item" :value="'/static/images/'+item+'.jpg'" v-for="item in [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]" v-bind:key="item">
<el-avatar :size="30" :src="'/static/images/'+item+'.jpg'"></el-avatar>
</el-option>
</el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">

Loading…
Cancel
Save