Commit 1c3f4f35 by 施宇

1

parent 8341f47b
Showing with 16 additions and 10 deletions
...@@ -62,10 +62,11 @@ $(function () { ...@@ -62,10 +62,11 @@ $(function () {
if (JSON.stringify(this.templateObj) == '{}') { if (JSON.stringify(this.templateObj) == '{}') {
$(".notice_classify[userid=" + this.defaultName + "]").click(); $(".notice_classify[userid=" + this.defaultName + "]").click();
} else { } else {
Util.delCookie('template', cookieHostname);
this.addUser(this.templateObj.userId); this.addUser(this.templateObj.userId);
$(".notice_classify[userid=" + this.templateObj.userId + "]").attr('isTemplate',true);//先获取历史纪录再发送模板,否则可能出现发送的消息显示两条
$(".notice_classify[userid=" + this.templateObj.userId + "]").click(); $(".notice_classify[userid=" + this.templateObj.userId + "]").click();
this.sendCmd(this.templateObj);
Util.delCookie('template', cookieHostname);
} }
}, },
...@@ -374,6 +375,7 @@ $(function () { ...@@ -374,6 +375,7 @@ $(function () {
}, //收到表情消息; }, //收到表情消息;
onCmdMessage: function (message) { onCmdMessage: function (message) {
self.receiveData(1, message, true); self.receiveData(1, message, true);
self.addChatMember(message.from) self.addChatMember(message.from)
}, //收到命令消息; }, //收到命令消息;
...@@ -467,7 +469,7 @@ $(function () { ...@@ -467,7 +469,7 @@ $(function () {
action: "template", action: "template",
ext: params, ext: params,
success: function () { success: function () {
self.addChatMember(userId) self.addChatMember(userId);
$('#' + userId).find('.notice_item_content').append(self.messageHtml(1, $('#' + userId).find('.notice_item_content').append(self.messageHtml(1,
params, true)); params, true));
var contentHeight = $('#' + userId).find('.notice_item_content') var contentHeight = $('#' + userId).find('.notice_item_content')
...@@ -560,13 +562,15 @@ $(function () { ...@@ -560,13 +562,15 @@ $(function () {
}) })
$('.notice_left').on('click', '.notice_classify', function () { $('.notice_left').on('click', '.notice_classify', function () {
var id = $(this).attr('userid'); var id = $(this).attr('userid');
var isTemplate = $(this).attr('isTemplate');
$('#' + id).addClass('active').siblings('.chat_item').removeClass('active'); $('#' + id).addClass('active').siblings('.chat_item').removeClass('active');
$(this).find('.num').remove(); $(this).find('.num').remove();
$(this).addClass('active').siblings('.notice_classify').removeClass('active'); $(this).addClass('active').siblings('.notice_classify').removeClass('active');
var contentHeight = $('#' + id).find('.notice_item_content').height(); if(isTemplate){
$('#' + id).find('.notice_list').scrollTop(contentHeight); $(this).removeAttr('isTemplate');
}
if (self.isLoginSuccess) { //登入成功 获取聊天记录 if (self.isLoginSuccess) { //登入成功 获取聊天记录
self.getHistoryData(id) self.getHistoryData(id,isTemplate)
} else { } else {
layer.msg('获取聊天记录失败'); layer.msg('获取聊天记录失败');
return; return;
...@@ -577,15 +581,17 @@ $(function () { ...@@ -577,15 +581,17 @@ $(function () {
}) })
}, },
getHistoryData: function (id) { getHistoryData: function (id,isTemplate) {
var self = this; var self = this;
this.conn.fetchHistoryMessages({ this.conn.fetchHistoryMessages({
queue: id, queue: id,
count: "50", count: "100",
success: function (data) { success: function (data) {
console.log(data) console.log('xixixi')
self.rendHistoryMessage(id, data) self.rendHistoryMessage(id, data)
if(isTemplate){
self.sendCmd(self.templateObj);
}
}, },
fail: function (e) { fail: function (e) {
console.log(e) console.log(e)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment