优化发信息问题

pull/23/head
630892807@qq.com 3 years ago
parent 6851d1d817
commit 833598b90c

@ -155,7 +155,7 @@ func SendMessageV2(c *gin.Context) {
} }
models.CreateMessage(kefuInfo.Name, vistorInfo.VisitorId, content, cType) models.CreateMessage(kefuInfo.Name, vistorInfo.VisitorId, content, cType)
var msg TypeMessage //var msg TypeMessage
if cType == "kefu" { if cType == "kefu" {
guest, ok := ws.ClientList[vistorInfo.VisitorId] guest, ok := ws.ClientList[vistorInfo.VisitorId]
@ -191,20 +191,21 @@ func SendMessageV2(c *gin.Context) {
// }) // })
// return // return
//} //}
msg = TypeMessage{ //msg = TypeMessage{
Type: "message", // Type: "message",
Data: ws.ClientMessage{ // Data: ws.ClientMessage{
Avator: vistorInfo.Avator, // Avator: vistorInfo.Avator,
Id: vistorInfo.VisitorId, // Id: vistorInfo.VisitorId,
Name: vistorInfo.Name, // Name: vistorInfo.Name,
ToId: kefuInfo.Name, // ToId: kefuInfo.Name,
Content: content, // Content: content,
Time: time.Now().Format("2006-01-02 15:04:05"), // Time: time.Now().Format("2006-01-02 15:04:05"),
IsKefu: "no", // IsKefu: "no",
}, // },
} //}
str, _ := json.Marshal(msg) //str, _ := json.Marshal(msg)
ws.OneKefuMessage(kefuInfo.Name, str) //ws.OneKefuMessage(kefuInfo.Name, str)
ws.KefuMessage(vistorInfo.VisitorId, content, kefuInfo)
go ws.SendServerJiang(vistorInfo.Name+"说", content, c.Request.Host) go ws.SendServerJiang(vistorInfo.Name+"说", content, c.Request.Host)
go SendAppGetuiPush(kefuInfo.Name, vistorInfo.Name, content) go SendAppGetuiPush(kefuInfo.Name, vistorInfo.Name, content)
kefus, ok := ws.KefuList[kefuInfo.Name] kefus, ok := ws.KefuList[kefuInfo.Name]
@ -214,9 +215,8 @@ func SendMessageV2(c *gin.Context) {
} }
go ws.VisitorAutoReply(vistorInfo, kefuInfo, content) go ws.VisitorAutoReply(vistorInfo, kefuInfo, content)
c.JSON(200, gin.H{ c.JSON(200, gin.H{
"code": 200, "code": 200,
"msg": "ok", "msg": "ok",
"result": msg,
}) })
} }

@ -116,6 +116,16 @@ new Vue({
} }
this.sendDisabled=true; this.sendDisabled=true;
let _this=this; let _this=this;
let content = {}
content.avator=_this.visitor.avator;
content.content = replaceContent(_this.messageContent);
content.name = _this.visitor.name;
content.is_kefu = true;
content.time = _this.getNowDate();
_this.msgList.push(content);
_this.scrollBottom();
let mes = {}; let mes = {};
mes.type = "visitor"; mes.type = "visitor";
mes.content = this.messageContent; mes.content = this.messageContent;
@ -126,21 +136,13 @@ new Vue({
$.post("/2/message",mes,function(res){ $.post("/2/message",mes,function(res){
_this.sendDisabled=false; _this.sendDisabled=false;
if(res.code!=200){ if(res.code!=200){
_this.msgList.pop();
_this.$message({ _this.$message({
message: res.msg, message: res.msg,
type: 'error' type: 'error'
}); });
return; return;
} }
let content = {}
content.avator=_this.visitor.avator;
content.content = replaceContent(_this.messageContent);
content.name = _this.visitor.name;
content.is_kefu = true;
content.time = res.result.data.time;
_this.msgList.push(content);
//_this.saveHistory(content);
_this.scrollBottom();
_this.messageContent = ""; _this.messageContent = "";
clearInterval(_this.timer); clearInterval(_this.timer);
_this.sendSound(); _this.sendSound();

@ -155,7 +155,7 @@ func VisitorAutoReply(vistorInfo models.Visitor, kefuInfo models.User, content s
kefus, ok := KefuList[kefuInfo.Name] kefus, ok := KefuList[kefuInfo.Name]
reply := models.FindReplyItemByUserIdTitle(kefuInfo.Name, content) reply := models.FindReplyItemByUserIdTitle(kefuInfo.Name, content)
if reply.Content != "" { if reply.Content != "" {
time.Sleep(2 * time.Second) time.Sleep(1 * time.Second)
VisitorMessage(vistorInfo.VisitorId, reply.Content, kefuInfo) VisitorMessage(vistorInfo.VisitorId, reply.Content, kefuInfo)
KefuMessage(vistorInfo.VisitorId, reply.Content, kefuInfo) KefuMessage(vistorInfo.VisitorId, reply.Content, kefuInfo)
models.CreateMessage(kefuInfo.Name, vistorInfo.VisitorId, reply.Content, "kefu") models.CreateMessage(kefuInfo.Name, vistorInfo.VisitorId, reply.Content, "kefu")

Loading…
Cancel
Save