Commit 1c3f4f35 by 施宇

1

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