编辑客服与界面小改

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

@ -106,7 +106,6 @@ func sendPingToClient() {
if err != nil {
delete(clientList, uid)
models.UpdateVisitorStatus(uid,0)
SendNoticeToAllKefu()
}
}
time.Sleep(3 * time.Second)
@ -143,22 +142,13 @@ func sendPingOnlineUsers() {
Data: result,
}
str, _ := json.Marshal(msg)
for _, kfConn := range kefuList {
kfConn.WriteMessage(websocket.TextMessage,str)
}
time.Sleep(3 * time.Second)
}
}
func SendNoticeToAllKefu() {
if len(kefuList) != 0 {
//发送给客服通知
for _, conn := range kefuList {
msg := TypeMessage{
Type: "notice",
for kefuId, kfConn := range kefuList {
err:=kfConn.WriteMessage(websocket.TextMessage,str)
if err != nil {
delete(kefuList, kefuId)
}
str, _ := json.Marshal(msg)
conn.WriteMessage(websocket.TextMessage,str)
}
time.Sleep(3 * time.Second)
}
}
@ -192,7 +182,6 @@ func singleBroadcaster(){
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)
SendNoticeToAllKefu()
//客服上线
case "kfOnline":
json.Unmarshal(msgData, &clientMsg)

@ -29,10 +29,22 @@ func GetKefuInfoSetting(c *gin.Context){
})
}
func PostKefuInfo(c *gin.Context){
id:=c.PostForm("id")
name:=c.PostForm("name")
password:=c.PostForm("password")
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{
"code": 200,
"msg": "ok",

@ -10,14 +10,26 @@ type User struct {
Nickname string `json:"nickname"`
Avator string `json:"avator"`
}
func CreateUser(name string,password string,avator string){
func CreateUser(name string,password string,avator string,nickname string){
user:=&User{
Name:name,
Password: password,
Avator:avator,
Nickname: nickname,
}
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{
var user User
DB.Where("name = ?", username).First(&user)

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

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

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

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

Loading…
Cancel
Save