优化发信息问题

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

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

@ -116,6 +116,16 @@ new Vue({
}
this.sendDisabled=true;
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 = {};
mes.type = "visitor";
mes.content = this.messageContent;
@ -126,21 +136,13 @@ new Vue({
$.post("/2/message",mes,function(res){
_this.sendDisabled=false;
if(res.code!=200){
_this.msgList.pop();
_this.$message({
message: res.msg,
type: 'error'
});
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 = "";
clearInterval(_this.timer);
_this.sendSound();

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

Loading…
Cancel
Save