/* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn) * Copyright (c) 2013-2018 北京泉江科技有限公司 * 创建人:陈彬彬 * 日 期:2017.03.16 * 描 述:经典风格皮肤 */ var autoopenid = request('autoopen'); var pwd = request("pwd"); var bootstrap = function ($, learun) { "use strict"; // 菜单操作 var meuns = { init: function () { this.load(); this.bind(); }, load: function () { var modulesTree = learun.clientdata.get(['modulesTree']); // 第一级菜单 var parentId = '0'; var modules = modulesTree[parentId] || []; var $firstmenus = $(''); for (var i = 0, l = modules.length; i < l; i++) { var item = modules[i]; if (item.F_IsMenu == 1) { var $firstMenuItem = $('
  • '); if (!!item.F_Description) { $firstMenuItem.attr('title', item.F_Description); } var menuItemHtml = ''; menuItemHtml += ''; menuItemHtml += '' + item.F_FullName + ''; menuItemHtml += ''; $firstMenuItem.append(menuItemHtml); // 第二级菜单 // var secondModules = modulesTree[item.F_ModuleId] || []; // var $secondMenus = $(''); // var secondMenuHad = false; // for (var j = 0, sl = secondModules.length; j < sl; j++) { // var secondItem = secondModules[j]; // if (secondItem.F_IsMenu == 1) { // secondMenuHad = true; // var $secondMenuItem = $('
  • '); // if (!!secondItem.F_Description) { // $secondMenuItem.attr('title', secondItem.F_Description); // } // var secondItemHtml = ''; // secondItemHtml += ''; // secondItemHtml += '' + secondItem.F_FullName + ''; // secondItemHtml += ''; // // $secondMenuItem.append(secondItemHtml); // // 第三级菜单 // var threeModules = modulesTree[secondItem.F_ModuleId] || []; // var $threeMenus = $(''); // var threeMenuHad = false; // for (var m = 0, tl = threeModules.length; m < tl; m++) { // var threeItem = threeModules[m]; // if (threeItem.F_IsMenu == 1) { // threeMenuHad = true; // var $threeMenuItem = $('
  • '); // $threeMenuItem.attr('title', threeItem.F_FullName); // var threeItemHtml = ''; // threeItemHtml += ''; // threeItemHtml += '' + threeItem.F_FullName + ''; // threeItemHtml += ''; // $threeMenuItem.append(threeItemHtml); // //第四级菜单 // var fourModules = modulesTree[threeItem.F_ModuleId] || []; // var $fourMenus = $(''); // var fourMenuHad = false; // for (var n = 0, fl = fourModules.length; n < fl; n++) { // var fourItem = fourModules[n]; // if (fourItem.F_IsMenu == 1) { // fourMenuHad = true; // var $fourMenuItem = $('
  • '); // $fourMenuItem.attr('title', fourItem.F_FullName); // var fourItemHtml = ''; // fourItemHtml += ''; // fourItemHtml += '' + fourItem.F_FullName + ''; // fourItemHtml += ''; // $fourMenuItem.append(fourItemHtml); // $fourMenus.append($fourMenuItem); // } // } // if (fourMenuHad) { // $threeMenuItem.addClass('lr-meun-had'); // $threeMenuItem.append($fourMenus); // } // $threeMenus.append($threeMenuItem); // } // } // if (threeMenuHad) { // $secondMenuItem.addClass('lr-meun-had'); // $secondMenuItem.append($threeMenus); // } // $secondMenus.append($secondMenuItem); // } // } // if (secondMenuHad) { // $firstMenuItem.append($secondMenus); // } $firstmenus.append($firstMenuItem); } } $('#lr_frame_menu').html($firstmenus); // 语言包翻译 $('.lr-menu-item-text').each(function () { var $this = $(this); var text = $this.text(); learun.language.get(text, function (text) { $this.text(text); $this.parent().parent().attr('title', text); }); }); }, bind: function () { $("#lr_frame_menu").lrscroll(); $("#lr_frame_menu .lr-first-menu-list > li").hover(function (e) {// 一级菜单选中的时候判断二级菜单的位置 //$('#lr_frame_menu').width(4000); var $secondMenu = $(this).find('.lr-second-menu-list'); var length = $secondMenu.find('li').length; if (length > 0) { $secondMenu.css('top', '0px'); var secondMenuTop = $(this).offset().top + $secondMenu.height() + 23; var bodyHeight = $(window).height(); if (secondMenuTop > bodyHeight) { $secondMenu.css('top', '-' + (secondMenuTop - bodyHeight) + 'px'); } } }, function (e) { $('#lr_frame_menu').width(80); }); $("#lr_frame_menu .lr-second-menu-list > li.lr-meun-had").hover(function (e) {// 二级菜单选中的时候判断三级菜单的位置 var $ul = $(this).find('.lr-three-menu-list'); $ul.css('top', '-9px'); var ulTop = $(this).offset().top + $ul.height() + 23; var bodyHeight = $(window).height(); if (ulTop > bodyHeight) { $ul.css('top', '-' + (ulTop - bodyHeight) + 'px'); } }); $("#lr_frame_menu .lr-three-menu-list > li.lr-meun-had").hover(function (e) {// 二级菜单选中的时候判断三级菜单的位置 var $ul = $(this).find('.lr-four-menu-list'); $ul.css('top', '-9px'); var ulTop = $(this).offset().top + $ul.height() + 23; var bodyHeight = $(window).height(); if (ulTop > bodyHeight) { $ul.css('top', '-' + (ulTop - bodyHeight) + 'px'); } }); var desktopnavigation = learun.clientdata.get(['modulesMap', "be81bdde-8bbc-4080-b976-84faefc414d2"]); // 添加点击事件 $('#lr_frame_menu .lr-menu-item').on('click', function () { var $obj = $(this); var id = $obj.attr('id'); if ($('#lr_tab_be81bdde-8bbc-4080-b976-84faefc414d2').length != 0) { learun.frameTab.close('be81bdde-8bbc-4080-b976-84faefc414d2'); } var _module = learun.clientdata.get(['modulesMap', id]); learun.frameTab.open({ F_ModuleId: desktopnavigation.F_ModuleId, F_Icon: desktopnavigation.F_Icon, F_FullName: desktopnavigation.F_FullName, F_UrlAddress: desktopnavigation.F_UrlAddress + '?id=' + id }, false); }); //使用引导页 var guide = learun.clientdata.get(['modulesMap', "44e91494-942d-482d-949e-ae8af5333956"]); if (guide) { //learun.frameTab.open(guide); learun.frameTab.open({ F_ModuleId: guide.F_ModuleId, F_Icon: guide.F_Icon, F_FullName: guide.F_FullName, F_UrlAddress: guide.F_UrlAddress }, true); } //上网认证 if (ACIp != null && ACIp != "") { //Ip上网 sendToAc(ACIp, 'logon', Ip, learun.clientdata.get(['userinfo']).account, ''); } if (ACIp2 != null && ACIp2 != "") { //Ip上网 sendToAc(ACIp2, 'logon', Ip, learun.clientdata.get(['userinfo']).account, ''); } //桌面导航 // var desktopnavigation = learun.clientdata.get(['modulesMap', "be81bdde-8bbc-4080-b976-84faefc414d2"]); // if (desktopnavigation) { // learun.frameTab.open({ F_ModuleId: desktopnavigation.F_ModuleId, F_Icon: desktopnavigation.F_Icon, F_FullName: desktopnavigation.F_FullName, F_UrlAddress: desktopnavigation.F_UrlAddress }, true); // } //var needtodo = learun.clientdata.get(['modulesMap', "021a59b0-2589-4f9e-8140-6052177a967c"]); //if (needtodo) { // //自动弹出待办事项 // top.layer.open({ // id: 'ntdform', // title: '我的待办事项', // type: 2, // skin: 'lr-layer', // btn: ['关闭'], // content: top.$.rootUrl + '/Home/NeedToDoForm', // area: ['500px', '300px'] // }); //} if (pwd == "true") { top.layer.open({ id: 'pwdform', title: '密码修改', closeBtn: 0, resize: false, type: 2, skin: 'lr-layer', btn: ['确定'], content: top.$.rootUrl + '/Home/ChangePwd', area: ['500px', '300px'], success: function (layero, index) { top['layer_pwdform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames); layero[0].learun_layerid = 'layer_pwdform'; }, yes: function (index, layero) { var flag = top['layer_pwdform'].acceptClick(function () { top.location.href = "/Login/Index"; }); if (!!flag) { learun.layerClose('', index); } }, end: function () { top['layer_pwdform'] = null; } }); } if (!!autoopenid) { var _module = learun.clientdata.get(['modulesMap', autoopenid]); switch (_module.F_Target) { case 'iframe':// 窗口 if (learun.validator.isNotNull(_module.F_UrlAddress).code) { learun.frameTab.open(_module); var keyValue = request('keyValue'); //内部邮件 if (autoopenid == '252878d7-d807-497f-b01e-839bb1b869c6' && !!keyValue) { var iframe = document.getElementById('lr_iframe_' + autoopenid); top.layer.open({ id: 'viewform', title: '查看', type: 2, skin: 'lr-layer', btn: ['回复', '转发', '关闭'], content: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/FormView?keyValue=' + keyValue, area: ['800px', '700px'], success: function (layero, index) { top['viewform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames); //自动已读 learun.postFormSilence(top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/Read', { keyValue: keyValue }, function () { iframe.contentWindow.refreshreceivetableGirdData(); }); }, yes: function (index, layero) { top.layer.open({ id: 'resendform', title: '回复邮件', type: 2, skin: 'lr-layer', btn: ['发送', '保存草稿', '关闭'], content: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/Form?keyValue=' + keyValue, area: ['800px', '700px'], success: function (layero, index) { top['resendform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames); }, yes: function (index, layero) { top['resendform'].acceptClick(iframe.contentWindow.sendthismessage); top['resendform'] = null; top.layer.close(index); } , btn2: function (index, layero) { top['resendform'].acceptClick(iframe.contentWindow.refreshsendtableGirdData); top['resendform'] = null; top.layer.close(index); } , btn3: function (index, layero) { top['resendform'] = null; top.layer.close(index); } }); top['viewform'] = null; top.layer.close(index); }, btn2: function (index, layero) { top.layer.open({ id: 'chsendform', title: '转发邮件', type: 2, skin: 'lr-layer', btn: ['发送', '保存草稿', '关闭'], content: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/FormCh?keyValue=' + keyValue, area: ['800px', '700px'], success: function (layero, index) { top['chsendform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames); }, yes: function (index, layero) { top['chsendform'].acceptClick(iframe.contentWindow.sendthismessage); top['chsendform'] = null; top.layer.close(index); } , btn2: function (index, layero) { top['chsendform'].acceptClick(iframe.contentWindow.refreshsendtableGirdData); top['chsendform'] = null; top.layer.close(index); } , btn3: function (index, layero) { top['chsendform'] = null; top.layer.close(index); } }); top['viewform'] = null; top.layer.close(index); }, btn3: function (index, layero) { top['viewform'] = null; top.layer.close(index); } }); } //我的任务 if (autoopenid == '021a59b0-2589-4f9e-8140-6052177a967c' && !!request('F_Id')) { var processId = request('F_Id'); var taskId = request('F_TaskId'); var taskType = request('F_TaskType'); if (taskType == 4) { if (learun.checkrow(taskId)) { learun.frameTab.open({ F_ModuleId: taskId, F_Icon: 'fa magic', F_FullName: '审核流程', F_UrlAddress: '/LR_WorkFlowModule/WfMyTask/CustmerWorkFlowForm?tabIframeId=' + taskId + '&type=4' + "&processId=" + processId + "&taskId=" + taskId }); } } else if (taskType == 1) { if (learun.checkrow(taskId)) { learun.frameTab.open({ F_ModuleId: taskId, F_Icon: 'fa magic', F_FullName: '审核流程', F_UrlAddress: '/LR_WorkFlowModule/WfMyTask/CustmerWorkFlowForm?tabIframeId=' + taskId + '&type=1' + "&processId=" + processId + "&taskId=" + taskId }); } } else if (taskType == 2) { learun.alert.warning('请点击重新发起'); } else { if (learun.checkrow(taskId)) { learun.frameTab.open({ F_ModuleId: taskId, F_Icon: 'fa magic', F_FullName: '审核流程', F_UrlAddress: '/LR_WorkFlowModule/WfMyTask/CustmerWorkFlowForm?tabIframeId=' + taskId + '&type=3' + "&processId=" + processId + "&taskId=" + taskId }); } } } //办事大厅 if (autoopenid == '56ce34c2-882e-47d1-b12d-5036e3b79fcf' && !!request('shcemeCode')) { var id = request('id'); var shcemeCode = request('shcemeCode'); //learun.frameTab.open({ F_ModuleId: id, F_Icon: 'fa magic', F_FullName: '发起流程【快捷发起】', F_UrlAddress: '/LR_WorkFlowModule/WfMyTask/CustmerWorkFlowForm?shcemeCode=' + shcemeCode + '&tabIframeId=' + id + '&type=0' }); learun.frameTab.open({ F_ModuleId: id, F_Icon: 'fa magic', F_FullName: '发起流程【快捷发起】', F_UrlAddress: '/LR_NewWorkFlow/NWFProcess/NWFContainerForm?shcemeCode=' + shcemeCode + '&tabIframeId=' + id + '&type=create' }); } //公告 if (autoopenid == '6252983c-52f5-402c-991b-ad19a9cb1f94' && !!keyValue) { learun.frameTab.open({ F_ModuleId: "dtlist" + keyValue, F_FullName: '通知公告', F_UrlAddress: "/Utility/ListContentIndex?id=" + keyValue }); } } break; case 'open':// 窗口 var newWin = window.open(_module.F_UrlAddress); newWin.location.replace(_module.F_UrlAddress); break; } } } }; meuns.init(); var companyMap = {}; var departmentMap = {}; var userMap = {}; var sysUserMap = {}; var imUserId = ''; //获取头像 var getHeadImg = function (user) { var url = top.$.rootUrl; switch (user.img) { case '0': url += '/Content/images/head/on-girl.jpg'; break; case '1': url += '/Content/images/head/on-boy.jpg'; break; default: url += '/LR_OrganizationModule/User/GetImg?userId=' + user.id; break; } return url; }; // 发送聊天信息 var sendMsg = function (msg, time) { var loginInfo = learun.clientdata.get(['userinfo']); learun.clientdata.getAsync('user', { key: loginInfo.userId, callback: function (data, op) { data.id = op.key; var _html = '\
    \
    \
    \ '+ msg + '\
    '; if (time && time != '') { $('.lr-im-msgcontent .lr-scroll-box').append('
    ' + time + '
    '); } $('.lr-im-msgcontent .lr-scroll-box').append(_html); $('.lr-im-msgcontent').lrscrollSet('moveBottom'); } }); }; // 接收聊天消息 var revMsg = function (userId, msg, time) { learun.clientdata.getAsync('user', { key: userId, callback: function (data, op) { data.id = op.key; var _html = '\
    \
    \
    \ '+ msg + '\
    '; if (time && time != '') { $('.lr-im-msgcontent .lr-scroll-box').append('
    ' + time + '
    '); } $('.lr-im-msgcontent .lr-scroll-box').append(_html); $('.lr-im-msgcontent').lrscrollSet('moveBottom'); } }); }; // 即时通讯 var im = { init: function () { this.bind(); this.load(); }, load: function () { // 获取下公司列表 learun.clientdata.getAllAsync('company', { callback: function (data) { $.each(data, function (_id, _item) { companyMap[_item.parentId] = companyMap[_item.parentId] || []; _item.id = _id; companyMap[_item.parentId].push(_item); }); var $list = $('#lr_im_content_userlist .lr-scroll-box'); $list.html(""); $.each(companyMap["0"], function (_index, _item) { var _html = '\
    \
    \ '+ _item.name + '\
    \
    '; $list.append(_html); }); // 获取部门列表 learun.clientdata.getAllAsync('department', { callback: function (data) { $.each(data, function (_id, _item) { _item.id = _id; if (_item.parentId == "0") { departmentMap[_item.companyId] = departmentMap[_item.companyId] || []; departmentMap[_item.companyId].push(_item); } else { departmentMap[_item.parentId] = departmentMap[_item.parentId] || []; departmentMap[_item.parentId].push(_item); } }); // 获取人员数据 learun.clientdata.getAllAsync('user', { callback: function (data) { $.each(data, function (_id, _item) { _item.id = _id; if (_item.departmentId) { userMap[_item.departmentId] = userMap[_item.departmentId] || []; userMap[_item.departmentId].push(_item); } else if (_item.companyId) { userMap[_item.companyId] = userMap[_item.companyId] || []; userMap[_item.companyId].push(_item); } }); // 获取最近联系人列表 learun.im.getContacts(function (data, sysUserList) { $.each(sysUserList, function (_index, _item) { sysUserMap[_item.F_Code] = _item; }); var $userList = $('#lr_immsg_userlist .lr-scroll-box'); $userList.html(""); $.each(data, function (_index, _item) { var html = '
    '; if (sysUserMap[_item.F_OtherUserId]) { html += '
    '; } else { html += '
    '; } html += '
    '; html += '
    '; $userList.append(html); if (sysUserMap[_item.F_OtherUserId]) { var _$item = $userList.find('[data-value="' + _item.F_OtherUserId + '"]'); _$item.attr('title', sysUserMap[_item.F_OtherUserId].F_Name); if (_index == 0) { _$item.trigger('click'); } _$item = null; } else { learun.clientdata.getAsync('user', { key: _item.F_OtherUserId, index: _index, callback: function (data, op) { var $item = $userList.find('[data-value="' + op.key + '"]'); $item.attr('title', data.name); data.id = op.key; $item.find('img').attr('src', getHeadImg(data)); if (op.index == 0) { $item.trigger('click'); } $item = null; } }); } }); }); } }); } }); } }); }, bind: function () { // 最近消息 与 联系人之间的切换 $('.lr-im-title .title-item').on('click', function () { var $this = $(this); if (!$this.hasClass('active')) { $('.lr-im-body>.active').removeClass('active'); $('.lr-im-title>.active').removeClass('active'); $this.addClass('active'); var v = $this.attr('data-value'); $('#' + v).addClass('active'); } }); $(".lr-lzca-user").on('click', function () { learun.httpPost(top.$.rootUrl + '/Home/GetOnlineUserInfo', {}, function (op) { if (op.data) { var content = ''; $.each(op.data, function (i, item) { content += '
  • ' + item.F_RealName + '(' + item.Source + ')' + '
  • '; console.log(item.F_RealName + "(" + item.Source + ")") }) $(".lr-lzca-user-ul").html(content); } }); }); $("#btn_daiban").on('click', function () { learun.frameTab.open({ F_ModuleId: '101', F_Icon: 'fa fa-user', F_FullName: '流程任务', F_UrlAddress: '/LR_NewWorkFlow/NWFProcess/Index' }); }); $("#btn_youjian").on('click', function () { learun.frameTab.open({ F_ModuleId: '102', F_Icon: 'fa fa-user', F_FullName: '内部邮件', F_UrlAddress: '/EducationalAdministration/LanMail/Index' }); }); $("#btn_tonggao").on('click', function () { learun.frameTab.open({ F_ModuleId: '103', F_Icon: 'fa fa-user', F_FullName: '下发通知公告', F_UrlAddress: '/LR_OAModule/Notice/Index' }); }); $("#btn_gongwen").on('click', function () { learun.frameTab.open({ F_ModuleId: '104', F_Icon: 'fa fa-user', F_FullName: '公文查阅', F_UrlAddress: '/EducationalAdministration/Sys_ReceiveFile/Index' }); }); // 打开关闭聊天窗 $('.lr-im-bell').off('click').on('click', function () { var $this = $(this); if ($this.hasClass('open')) { $this.removeClass('open'); $('.lr-im-body').removeClass('open'); } else { $this.addClass('open'); $('.lr-im-bell .point').hide(); $('.lr-im-body').addClass('open'); } return false; }); // 联系人 $('#lr_im_content_userlist').lrscroll(); $('#lr_immsg_userlist').lrscroll(); $('.lr-im-msgcontent').lrscroll(); // 联系人列表点击 $('#lr_im_content_userlist .lr-scroll-box').on('click', function (e) { e = e || window.event; var et = e.target || e.srcElement; var $et = $(et); if (et.tagName == 'IMG' || et.tagName == 'I') { $et = $et.parent(); } if ($et.hasClass('lr-im-company')) {// 点击公司项 // 判断是否是打开的状态 if ($et.hasClass('open')) { $et.removeClass('open'); $et.parent().find('.lr-im-user-list').remove(); } else { var id = $et.attr('data-value'); var deep = parseInt($et.attr('data-deep')); var $list = $('
    '); $list.css({ 'padding-left': '10px' }); var flag = false; // 加载员工 var loginInfo = learun.clientdata.get(['userinfo']); $.each(userMap[id] || [], function (_index, _item) { if (_item.id != loginInfo.userId) { var _html = '\
    \
    \ ' + _item.name + '\
    \
    '; $list.append(_html); flag = true; } }); // 加载部门 $.each(departmentMap[id] || [], function (_index, _item) { var _html = '\
    \
    \ '+ _item.name + '\
    \
    '; $list.append(_html); flag = true; }); // 加载下属公司 $.each(companyMap[id] || [], function (_index, _item) { var _html = '\
    \
    \ '+ _item.name + '\
    \
    '; $list.append(_html); flag = true; }); if (flag) { $et.parent().append($list); } $et.addClass('open'); } return false; } else if ($et.hasClass('lr-im-department')) { // 判断是否是打开的状态 if ($et.hasClass('open')) { $et.removeClass('open'); $et.parent().find('.lr-im-user-list').remove(); } else { var id = $et.attr('data-value'); var deep = parseInt($et.attr('data-deep')); var $list = $('
    '); $list.css({ 'padding-left': '10px' }); var flag = false; // 加载员工 var loginInfo = learun.clientdata.get(['userinfo']); $.each(userMap[id] || [], function (_index, _item) { if (_item.id != loginInfo.userId) { var _html = '\
    \
    \ ' + _item.name + '\
    \
    '; $list.append(_html); flag = true; } }); // 加载部门 $.each(departmentMap[id] || [], function (_index, _item) { var _html = '\
    \
    \ '+ _item.name + '\
    \
    '; $list.append(_html); flag = true; }); if (flag) { $et.parent().append($list); } $et.addClass('open'); } } else if ($et.hasClass('lr-im-user')) { // 如果是用户列表 // 1.打开聊天窗口 // 2.添加一条最近联系人数据(如果没有添加的话) // 3.获取最近的20条聊天数据或者最近的聊天信息 var id = $et.attr('data-value'); var $userList = $('#lr_immsg_userlist .lr-scroll-box'); var $userItem = $userList.find('[data-value="' + id + '"]'); // 更新下最近的联系人列表数据 $('.lr-im-title .title-item').eq(0).trigger('click'); $('#lr_im_msglist .lr-im-right').removeClass('lr-im-nouser'); imUserId = id; if ($userItem.length > 0) { $userList.prepend($userItem); $userItem.trigger('click'); } else { $userList.find('.active').removeClass('active'); var imgurl = $et.find('img').attr('src'); var _html = '\
    \
    \
    \
    '; $userList.prepend(_html); // 获取人员数据 learun.clientdata.getAsync('user', { key: id, callback: function (data, op) { $userList.find('[data-value="' + op.key + '"]').attr('title', data.name).addClass('active'); $('#lr_im_msglist .lr-im-right .lr-im-touser').text(data.name); } }); learun.im.addContacts(id); $('.lr-im-msgcontent .lr-scroll-box').html(''); } $('#lr_im_input').val(''); $('#lr_im_input').select(); } }); // 最近联系人列表点击 $('#lr_immsg_userlist .lr-scroll-box').on('click', function (e) { e = e || window.event; var et = e.target || e.srcElement; var $et = $(et); if (!$et.hasClass('userlist-item')) { $et = $et.parents('.userlist-item'); } if ($et.length > 0) { if (!$et.hasClass('active')) { var name = $et.attr('title'); if (name == undefined) { name = ""; } imUserId = $et.attr('data-value'); $('#lr_immsg_userlist .lr-scroll-box .active').removeClass('active'); $et.addClass('active'); $('#lr_im_msglist .lr-im-right .lr-im-touser').text(name); $('#lr_im_msglist .lr-im-right').removeClass('lr-im-nouser'); $('#lr_im_input').val(''); $('#lr_im_input').select(); $('.lr-im-msgcontent .lr-scroll-box').html(''); // 获取聊天信息 learun.im.getMsgList(imUserId, function (data) { var len = data.length; if (len > 0) { for (var i = len - 1; i >= 0; i--) { var _item = data[i]; learun.clientdata.getAsync('user', { key: _item.userId, msg: _item.content, time: _item.time, callback: function (data, op) { data.id = op.key; var loginInfo = learun.clientdata.get(['userinfo']); var _html = '\
    \
    \
    \ '+ op.msg + '\
    '; $('.lr-im-msgcontent .lr-scroll-box').prepend(_html); $('.lr-im-msgcontent .lr-scroll-box').prepend('
    ' + op.time + '
    '); } }); } $('.lr-im-msgcontent').lrscrollSet('moveBottom'); } }, $et.hasClass('imHasMsg')); $et.removeClass('imHasMsg'); learun.im.updateContacts(imUserId); } } }); // 联系人搜索 $('.lr-im-search input').on("keypress", function (e) { e = e || window.event; if (e.keyCode == "13") { var $this = $(this); var keyword = $this.val(); var $list = $('#lr_im_content_userlist .lr-scroll-box'); $list.html(""); if (keyword) { learun.clientdata.getAllAsync('user', { callback: function (data) { var loginInfo = learun.clientdata.get(['userinfo']); $.each(data, function (_index, _item) { if (_index != loginInfo.userId) { if (_item.name.indexOf(keyword) != -1) { _item.id = _index; var _html = '\
    \
    \ ' + _item.name + '\
    \
    '; $list.append(_html); } } }); } }); } else { $.each(companyMap["0"], function (_index, _item) { var _html = '\
    \
    \ '+ _item.name + '\
    \
    '; $list.append(_html); }); } } }); // 发送消息 $('#lr_im_input').on("keypress", function (e) { e = e || window.event; if (e.keyCode == "13") { var text = $(this).val(); $(this).val(''); if (text.replace(/(^\s*)|(\s*$)/g, "") != '') { //var time = learun.im.sendMsg(imUserId, text); var checked = $('#lr_immsg_userlist .userlist-item.active'); if (!checked) { learun.alert.warning("请选择聊天人员!"); return false; } var checkedVal = checked.attr('data-value'); var time = learun.im.sendMsg(checkedVal, text); sendMsg(text, time); } return false; } }); // 注册消息接收 learun.im.registerRevMsg(function (userId, msg, dateTime) { // 判断当前账号是否打开聊天窗口 if (userId == imUserId) { revMsg(userId, msg, dateTime); learun.im.updateContacts(userId); } else { var $userList = $('#lr_immsg_userlist .lr-scroll-box'); var $userItem = $userList.find('[data-value="' + userId + '"]'); $('#lr_im_msglist .lr-im-right').removeClass('lr-im-nouser'); if ($userItem.length > 0) { $userList.prepend($userItem); if (!$userItem.hasClass('imHasMsg')) { $userItem.addClass('imHasMsg'); } } else { var html = '
    '; if (sysUserMap[userId]) { html += '
    '; } else { html += '
    '; } html += '
    '; html += '
    '; $userList.prepend(html); if (sysUserMap[userId]) { var _$item = $userList.find('[data-value="' + userId + '"]'); _$item.attr('title', sysUserMap[userId].F_Name); _$item = null; } else { learun.clientdata.getAsync('user', { key: userId, callback: function (data, op) { var $item = $userList.find('[data-value="' + op.key + '"]'); $item.attr('title', data.name); data.id = op.key; $item.find('img').attr('src', getHeadImg(data)); $item = null; } }); } var _$userItem = $userList.find('.userlist-item'); if (_$userItem.length == 1) { _$userItem.trigger('click'); } } $('#lr_im_input').val(''); $('#lr_im_input').select(); } if (!$('.lr-im-bell').hasClass('open')) { $('.lr-im-bell .point').show(); } }); // 查看聊天记录 $('#lr_im_look_msg_btn').on('click', function () { //获取聊天用户编号 var checked = $('#lr_immsg_userlist .userlist-item.active'); if (!checked) { learun.alert.warning("请选择聊天人员!"); return false; } var checkedVal = checked.attr('data-value'); learun.layerForm({ id: 'LookMsgIndex', title: '查看聊天记录-' + $('#lr_im_msglist .lr-im-right .lr-im-touser').text(), //url: top.$.rootUrl + '/LR_IM/IMMsg/Index?userId=' + imUserId, url: top.$.rootUrl + '/LR_IM/IMMsg/Index?userId=' + checkedVal, width: 800, height: 500, maxmin: true, btn: null }); }); } }; im.init(); };