function messages(type) { if (!type) { type = $('.right-tab li.active').index(); } var html = $('#tab-' + (type + 1)).find('.chat_box'); html.html(''); helper.init.isload = 0; $.ajax({ type: "get", url: huayi.config.callcenter_url + "Index/GetChatLists", async: true, dataType: 'json', data: { token: $.cookie("token"), isread: type, top: 50, fromid: 0 }, success: function (data) { helper.init.isload = 1; $('#tab-1').find('.message_count').html(data.total); if (type == 0) { if (data.total == 0) { $('.readed').hide(); $('.chat_count').hide(); } else { $('.chat_count').show(); $('.chat_count').html(data.total); $('.readed').show(); } $('.close_chat').show(); } $(data.rows).each(function (i, n) { var str = ''; str = '
' html.append(str); }) } }); } function closed(a) { var id = $(a).attr('data-index'); $.ajax({ type: "post", url: huayi.config.callcenter_url + "Index/CloseChat", async: true, dataType: 'json', data: { token: $.cookie("token"), id: id }, success: function (data) { if (data.total > 0) { messages() } else { layer.msg("关闭消息失败!"); } } }); } $(document).ready(function(){ $('.right-tab li').click(function(){ messages($(this).index()); }) //全部已读 $('.readed').click(function(){ $.ajax({ type:"get", url:huayi.config.callcenter_url+"Index/CloseChat", async:true, dataType:'json', data:{ token:$.cookie("token"), id:0 }, success:function(data){ if(data.total>0){ messages() }else{ layer.msg("设置失败!"); } } }); }) }) //回复 function resply(a) { var userId = $(a).attr('data-FromUserId') var toId = $(a).attr('data-ToUserId') var roleId = $(a).attr('data-roleId') layer.open({ type: 2, content: "replyChat.html?userId=" + userId + "&roleId=" + roleId + "&toId=" + toId, //iframe的url,no代表不显示滚动条 title: '回复消息', area: ['50%', '60%'], //宽高 }); } //主动发消息 $('.sele_send').click(function () { layer.open({ type: 2, content: "replyChat.html", //iframe的url,no代表不显示滚动条 title: '发送消息', area: ['50%', '60%'], //宽高 }); }) //回复 function GetCont(val) { if (val) { var str = '