编辑客服与界面小改

pull/30/head
taoshihan1991 5 years ago
parent 041a00eee3
commit 0549eb5369

@ -106,7 +106,6 @@ func sendPingToClient() {
if err != nil { if err != nil {
delete(clientList, uid) delete(clientList, uid)
models.UpdateVisitorStatus(uid,0) models.UpdateVisitorStatus(uid,0)
SendNoticeToAllKefu()
} }
} }
time.Sleep(3 * time.Second) time.Sleep(3 * time.Second)
@ -143,22 +142,13 @@ func sendPingOnlineUsers() {
Data: result, Data: result,
} }
str, _ := json.Marshal(msg) str, _ := json.Marshal(msg)
for _, kfConn := range kefuList { for kefuId, kfConn := range kefuList {
kfConn.WriteMessage(websocket.TextMessage,str) err:=kfConn.WriteMessage(websocket.TextMessage,str)
} if err != nil {
time.Sleep(3 * time.Second) delete(kefuList, kefuId)
}
}
func SendNoticeToAllKefu() {
if len(kefuList) != 0 {
//发送给客服通知
for _, conn := range kefuList {
msg := TypeMessage{
Type: "notice",
} }
str, _ := json.Marshal(msg)
conn.WriteMessage(websocket.TextMessage,str)
} }
time.Sleep(3 * time.Second)
} }
} }
@ -192,7 +182,6 @@ func singleBroadcaster(){
clientList[clientMsg.Id] = user clientList[clientMsg.Id] = user
//插入数据表 //插入数据表
models.CreateVisitor(clientMsg.Name,clientMsg.Avator,message.c.ClientIP(),clientMsg.ToId,clientMsg.Id,message.c.Request.Referer(),clientMsg.City,clientMsg.ClientIp) models.CreateVisitor(clientMsg.Name,clientMsg.Avator,message.c.ClientIP(),clientMsg.ToId,clientMsg.Id,message.c.Request.Referer(),clientMsg.City,clientMsg.ClientIp)
SendNoticeToAllKefu()
//客服上线 //客服上线
case "kfOnline": case "kfOnline":
json.Unmarshal(msgData, &clientMsg) json.Unmarshal(msgData, &clientMsg)

@ -29,10 +29,22 @@ func GetKefuInfoSetting(c *gin.Context){
}) })
} }
func PostKefuInfo(c *gin.Context){ func PostKefuInfo(c *gin.Context){
id:=c.PostForm("id")
name:=c.PostForm("name") name:=c.PostForm("name")
password:=c.PostForm("password") password:=c.PostForm("password")
avator:=c.PostForm("avator") avator:=c.PostForm("avator")
models.CreateUser(name,tools.Md5(password),avator) nickname:=c.PostForm("nickname")
//插入新用户
if id==""{
models.CreateUser(name,tools.Md5(password),avator,nickname)
}else{
//更新用户
if password!=""{
password=tools.Md5(password)
}
models.UpdateUser(id,name,password,avator,nickname)
}
c.JSON(200, gin.H{ c.JSON(200, gin.H{
"code": 200, "code": 200,
"msg": "ok", "msg": "ok",

@ -10,14 +10,26 @@ type User struct {
Nickname string `json:"nickname"` Nickname string `json:"nickname"`
Avator string `json:"avator"` Avator string `json:"avator"`
} }
func CreateUser(name string,password string,avator string){ func CreateUser(name string,password string,avator string,nickname string){
user:=&User{ user:=&User{
Name:name, Name:name,
Password: password, Password: password,
Avator:avator, Avator:avator,
Nickname: nickname,
} }
DB.Create(user) DB.Create(user)
} }
func UpdateUser(id string,name string,password string,avator string,nickname string){
user:=&User{
Name:name,
Avator:avator,
Nickname: nickname,
}
if password!=""{
user.Password=password
}
DB.Model(&User{}).Where("id = ?",id).Update(user)
}
func FindUser(username string)User{ func FindUser(username string)User{
var user User var user User
DB.Where("name = ?", username).First(&user) DB.Where("name = ?", username).First(&user)

@ -203,7 +203,7 @@
switch (redata.type){ switch (redata.type){
case "getOnlineUsers": case "getOnlineUsers":
this.handleOnlineUsers(redata.data); this.handleOnlineUsers(redata.data);
this.sendKefuOnline(); //this.sendKefuOnline();
break; break;
case "notice": case "notice":
// if(!this.usersMap[redata.data.uid]){ // if(!this.usersMap[redata.data.uid]){

@ -17,17 +17,18 @@
height: 100%; height: 100%;
} }
body { body {
background-color: #f5f5f5;
} }
.chatContext{ .chatContext{
background: #fff;border: solid 1px #e6e6e6;boder-top:none;padding:5px 10px; background: #fff;padding:0 10px;
width: 100%; width: 100%;
text-align: left; text-align: left;
position: relative;
} }
.chatBox{ .chatBox{
max-height: 400px; max-height: 500px;
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
margin-bottom: 80px;
} }
.chatBox .el-col{margin:10px 0;} .chatBox .el-col{margin:10px 0;}
.chatUser{ .chatUser{
@ -67,7 +68,10 @@
.chatBoxMe .chatUser{text-align: right} .chatBoxMe .chatUser{text-align: right}
.chatBoxMe .chatContent:after{left:auto;right: -10px;} .chatBoxMe .chatContent:after{left:auto;right: -10px;}
.chatArea{margin: 10px 0;} .chatArea{margin: 10px 0;}
.chatArea .el-textarea__inner{height: 100%;}
.chatTitle{height: 30px;line-height: 30px;color: #1989fa} .chatTitle{height: 30px;line-height: 30px;color: #1989fa}
.chatBoxSend{position: fixed;bottom: 0;left: 0;width: 100%;height: 70px;}
.chatBoxSendBtn{position: absolute;bottom: 1px;right: 2px;}
</style> </style>
</head> </head>
@ -76,11 +80,18 @@
<template> <template>
<!--客服代码--> <!--客服代码-->
<div class="chatContext"> <div class="chatContext">
<div class="chatBox">
<el-alert <el-alert
style="margin-bottom: 10px;font-size: 12px;"
title="公告 : 您好go-fly目前是即时通讯客服系统方面的小学生还有很长的路要走感谢您的使用和支持。"
type="success">
</el-alert>
<el-alert
style="margin-bottom: 10px;"
:title="chatTitle" :title="chatTitle"
:closable="false"
type="success"> type="success">
</el-alert> </el-alert>
<div class="chatBox">
<el-row :gutter="2" v-for="v in msgList" v-bind:class="{'chatBoxMe': v.is_kefu==true}"> <el-row :gutter="2" v-for="v in msgList" v-bind:class="{'chatBoxMe': v.is_kefu==true}">
<el-col :span="3"><el-avatar :size="60" :src="v.avator"></el-avatar></el-col> <el-col :span="3"><el-avatar :size="60" :src="v.avator"></el-avatar></el-col>
<el-col :span="21"> <el-col :span="21">
@ -89,8 +100,10 @@
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
<div class="chatBoxSend">
<el-input type="textarea" class="chatArea" v-model="messageContent" v-on:keyup.enter.native="chatToUser"></el-input> <el-input type="textarea" class="chatArea" v-model="messageContent" v-on:keyup.enter.native="chatToUser"></el-input>
<el-button type="primary" v-on:click="chatToUser">发送</el-button> <el-button type="primary" class="chatBoxSendBtn" size="small" v-on:click="chatToUser">发送</el-button>
</div>
</div> </div>
<!--//客服代码--> <!--//客服代码-->

@ -42,15 +42,19 @@
password: [ password: [
{ required: true, message: '请输入密码', trigger: 'blur' }, { required: true, message: '请输入密码', trigger: 'blur' },
], ],
nickname: [
{ required: true, message: '请输入昵称', trigger: 'blur' },
],
}, },
kefuList:[], kefuList:[],
kefuDialog:false, kefuDialog:false,
kefuForm:{ kefuForm:{
id:"",
name:"", name:"",
password:"", password:"",
avator:"", avator:"",
nickname:"",
}, },
kefuSelectAvator:"/static/images/0.jpg",
}, },
methods: { methods: {
//提交表单 //提交表单
@ -170,6 +174,12 @@
}, },
//添加客服的dialog //添加客服的dialog
addKefu(){ addKefu(){
this.kefuForm={
id:"",
name:"",
password:"",
avator:"",
};
this.kefuDialog=true; this.kefuDialog=true;
}, },
//提交客服表单 //提交客服表单
@ -207,6 +217,7 @@
this.sendAjax("/kefuinfo_setting","GET",{kefu_id:kefuId},function(result){ this.sendAjax("/kefuinfo_setting","GET",{kefu_id:kefuId},function(result){
_this.kefuDialog=true; _this.kefuDialog=true;
_this.kefuForm=result; _this.kefuForm=result;
_this.kefuForm.password="";
}); });
}, },
//删除客服 //删除客服

@ -23,6 +23,10 @@
prop="name" prop="name"
label="客服账号"> label="客服账号">
</el-table-column> </el-table-column>
<el-table-column
prop="nickname"
label="客服昵称">
</el-table-column>
<el-table-column <el-table-column
prop="created_at" prop="created_at"
label="添加时间"> label="添加时间">
@ -51,6 +55,9 @@
<el-form-item label="密码" prop="password"> <el-form-item label="密码" prop="password">
<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="nickname">
<el-input v-model="kefuForm.nickname"></el-input>
</el-form-item>
<el-form-item label="头像" prop="avator"> <el-form-item label="头像" prop="avator">
<el-select v-model="kefuForm.avator" placeholder="请选择头像"> <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-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">

Loading…
Cancel
Save