var wHeight;
|
var headerHeight;
|
var colorIndex = 0; //菜单色块
|
var menuItemData = [];
|
var url = "management/menuItem/indexMenuItem?menuId=";
|
|
$(function () {
|
|
getMenuData(menuId);
|
forceModifyPassword();
|
passwordExpired();
|
$('#tt').tabs({
|
border: false,
|
tools: [{
|
iconCls: 'fa fa-times-circle',
|
handler: function () {
|
closeAllPanel();
|
}
|
}],
|
onSelect: function (title, index) {
|
var tab = $('#tt').tabs('getTab', index);
|
var id = $(tab).panel("options").id;
|
if (id != null) {
|
//判断是否为系统list页面,如果是则调用 一下list的刷新方法
|
var iframeId = id.replace("tab_", "iframe_");
|
|
setTimeout(function () {
|
if (document.getElementById(iframeId).contentWindow.resizeDataGrid) {
|
document.getElementById(iframeId).contentWindow.resizeDataGrid();
|
}
|
if (document.getElementById(iframeId).contentWindow.computeBtns) {
|
document.getElementById(iframeId).contentWindow.computeBtns();
|
}
|
}, 100);
|
}
|
|
}
|
});
|
|
/*为选项卡绑定右键*/
|
$(".tabs").on('contextmenu', "li", function (e) {
|
/*选中当前触发事件的选项卡*/
|
var subtitle = $(this).text();
|
if (subtitle == "首页") {
|
return;
|
}
|
$('#tt').tabs('select', subtitle);
|
|
//显示快捷菜单
|
$('#contextMenu').menu('show', {
|
left: e.pageX,
|
top: e.pageY
|
});
|
|
return false;
|
});
|
|
if ($("#ul_MainMenu").length > 0) {
|
var oul = $("#ul_MainMenu");
|
var upOpen = true;
|
var downOpen = true;
|
$("#div_up").click(function () { //向上按钮
|
if (upOpen) {
|
upOpen = false;
|
} else {
|
|
return;
|
}
|
var ultop = $("#ul_MainMenu").position().top;
|
ultop = Math.round(ultop);
|
if (maiMenuCeng == 1) return;
|
if (ultop >= 0) {
|
upOpen = true;
|
return;
|
} else {
|
oul.animate({
|
top: '+=60'
|
}, "slow", function () {
|
upOpen = true;
|
});
|
|
}
|
});
|
|
$("#div_down").click(function () { //向下按钮
|
if (downOpen) {
|
downOpen = false;
|
} else {
|
|
return;
|
}
|
|
var ultop = $("#ul_MainMenu").position().top;
|
ultop = Math.round(ultop);
|
if (maiMenuCeng == 1) return;
|
var maxtop = -(maiMenuCeng - 1) * 60;
|
if (ultop <= maxtop) {
|
downOpen = true;
|
return;
|
} else {
|
oul.animate({
|
top: '-=60'
|
}, "slow", function () {
|
downOpen = true;
|
});
|
}
|
});
|
}
|
|
if ($(".pt_system_menu_btn").length > 0) {
|
//打开菜单
|
$(".pt_system_menu_btn").click(function () {
|
menuTimer = null;
|
if ($(this).hasClass("open")) {
|
$(this).removeClass("open");
|
$(".pt_system_submenu").css({
|
"maxHeight": 0
|
});
|
} else {
|
$(".pt_system_submenu").css({
|
"display": "block",
|
"maxHeight": 560
|
});
|
$(this).addClass("open");
|
}
|
|
})
|
|
//菜单离开自动伸缩
|
$(".pt_system_submenu").mouseleave(function () {
|
menuTimer = window.setTimeout(function () {
|
$(".pt_system_submenu").css({
|
"maxHeight": 0
|
});
|
$(".pt_system_menu_btn").removeClass("open");
|
}, 400);
|
|
});
|
$(".pt_system_submenu").mouseenter(function () {
|
menuTimer = null;
|
$(".pt_system_submenu").css("maxHeight", 560);
|
});
|
|
//加滚动条
|
$('.pt_system_sublist ul').slimScroll({
|
height: "560px",
|
railOpacity: .9,
|
alwaysVisible: false
|
});
|
|
$('.pt_system_subbtn').slimScroll({
|
height: "560px",
|
railOpacity: .9,
|
alwaysVisible: false
|
});
|
}
|
|
$(window).resize(function () {
|
var handleResize = function () {
|
// The timer kid
|
if (this.kid) {
|
window.clearTimeout(this.kid);
|
this.kid = null;
|
}
|
|
this.kid = window.setTimeout(function () {
|
autoHeight();
|
}, 100);
|
};
|
|
handleResize();
|
});
|
|
autoHeight();
|
});
|
|
function loadMenu(mId) {
|
getMenuData(mId);
|
}
|
|
function getMenuData(mId) {
|
if ($(".f_left").length > 0) {
|
wcp.ui.setBusy(".f_left", wcp.ajax({
|
url: url + mId
|
}).done(function (result) {
|
menuItemData = result;
|
|
//判断是否有头部顶级菜单
|
if ($("#ul_MainMenu").length > 0) {
|
loadFirstMenuData(menuItemData);
|
} else {
|
loadMenuData(menuItemData);
|
}
|
}));
|
} else if ($(".pt_top_menu").length > 0) {
|
wcp.ui.setBusy(".pt_system_menu", wcp.ajax({
|
url: url + mId
|
}).done(function (result) {
|
menuItemData = result;
|
|
loadTopMenuData(menuItemData);
|
}));
|
}
|
}
|
|
function loadFirstMenuData(data) {
|
var sb = "";
|
for (var i = 0; i < data.length; i++) {
|
var item = data[i];
|
|
sb += '<li id="' + item.id + '"';
|
if (i == 0) {
|
sb += ' class="current"';
|
|
item.state = "open";
|
loadMenuData([item]);
|
}
|
sb += ">";
|
sb += ' <a href="javascript:;">';
|
sb += ' <i class="' + item.iconCls + '"></i>';
|
sb += ' ' + item.text;
|
sb += ' </a>';
|
sb += '</li>';
|
}
|
|
$("#ul_MainMenu").html(sb);
|
|
autoHeight();
|
|
$("#ul_MainMenu li").click(function () {
|
$(this).addClass("current");
|
$(this).siblings().removeClass("current");
|
var itemId = this.id;
|
for (var i in menuItemData) {
|
if (menuItemData[i].id == itemId) {
|
menuItemData[i].state = "open";
|
loadMenuData([menuItemData[i]]);
|
break;
|
}
|
}
|
});
|
}
|
|
function loadMenuData(data) {
|
var width = $("#leftbody").width();
|
|
$("#ul_menu").sidemenu({
|
data: data,
|
animate: true,
|
width: width,
|
multiple: false,
|
formatter: function (node) {
|
if (node.text.length >= 12) {
|
return "<span class='easyui-tooltip' title='" + node.text + "'>" + node.text + "</span>";
|
} else {
|
return node.text;
|
}
|
},
|
onSelect: function (node) {
|
if (!node) {
|
return;
|
}
|
|
if (node.domId) {
|
var domId = node.domId;
|
$("#" + domId).find(".tree-hit").click();
|
}
|
|
if (node.attributes) {
|
var url = node.attributes.url;
|
var text = node.text;
|
menuItemClick(url, node.attributes.target, text, node.attributes.width, node.attributes.height);
|
}
|
}
|
})
|
|
//如果有默认打开菜单项,则打开该菜单项
|
var item = getDefaultOpenMenu(data);
|
if (item != null && item.attributes) {
|
var url = item.attributes.url;
|
var text = item.text;
|
menuItemClick(url, item.attributes.target, text, item.attributes.width, item.attributes.height);
|
}
|
}
|
|
/**
|
* 获取默认打开菜单项
|
* @param data
|
* @returns {null|{checked}|*}
|
*/
|
function getDefaultOpenMenu(data) {
|
for (var i in data) {
|
var item = data[i];
|
if (item.checked) {
|
return item;
|
} else if (item.children && item.children.length > 0) {
|
var node = getDefaultOpenMenu(item.children);
|
if (node != null) {
|
return node;
|
}
|
}
|
}
|
|
return null;
|
}
|
|
function loadTopMenuData(data) {
|
var mainStr = "";
|
var subMenuStr = "";
|
if (data.length > 0) {
|
$.each(data, function (index, elem) {
|
if (index == 0) {
|
mainStr += '<li class="sublisthot" id="menu_' + elem.id + '"><a href="javascript:;"><i class="' + elem.iconCls + '"></i><span>' + elem.text + '</span></a></li>';
|
|
subMenuStr += '<div parentId="menu_' + elem.id + '"><ul class="clear">';
|
if (elem.children.length > 0) {
|
$.each(elem.children, function (i, el) {
|
if (!el.children) {
|
subMenuStr += '<li class="subtncolor' + colorIndex + '"><a href="javascript:menuItemClick(\'' + el.attributes.url + '\',\'' + el.attributes.target + '\',\'' + el.text + '\',' + el.attributes.width + ',' + el.attributes.width + ')"><i class="' + el.iconCls + '"></i><span>' + el.text + '</span></a></li>';
|
} else {
|
// 递归得到没有儿子的菜单集合
|
subMenuStr += getTopMenuChildren(el.children, colorIndex);
|
}
|
|
colorIndex = (colorIndex + 1) % 16;
|
});
|
}
|
subMenuStr += '</ul></div>';
|
} else {
|
mainStr += '<li id="menu_' + elem.id + '"><a href="javascript:;"><i class="' + elem.iconCls + '"></i><span>' + elem.text + '</span></a></li>';
|
subMenuStr += '<div parentId="menu_' + elem.id + '" class="hide"><ul class="clear">';
|
if (elem.children != null && elem.children.length > 0) {
|
$.each(elem.children, function (i, el) {
|
if (!el.children) {
|
subMenuStr += '<li class="subtncolor' + colorIndex + '"><a href="javascript:menuItemClick(\'' + el.attributes.url + '\',\'' + el.attributes.target + '\',\'' + el.text + '\',' + el.attributes.width + ',' + el.attributes.width + ')"><i class="' + el.iconCls + '"></i><span>' + el.text + '</span></a></li>';
|
} else {
|
// 递归得到没有儿子的菜单集合
|
subMenuStr += getTopMenuChildren(el.children, colorIndex);
|
}
|
|
colorIndex = (colorIndex + 1) % 16;
|
});
|
}
|
subMenuStr += '</ul></div>';
|
}
|
})
|
|
$(".pt_system_sublist ul").html(mainStr);
|
$(".pt_system_subbtn").html(subMenuStr);
|
}
|
|
$(".pt_system_sublist ul li").click(function () {
|
var id = $(this).attr("id").replace("menu_", "");
|
$(this).siblings("li").removeClass("sublisthot");
|
$(this).addClass("sublisthot");
|
|
$(".pt_system_subbtn").children().hide();
|
var parentdivId = "menu_" + id;
|
$("[parentId=" + parentdivId + "]").show();
|
})
|
}
|
|
//递归得到没有儿子的菜单集合
|
function getTopMenuChildren(data) { //data:菜单数组,
|
var retStr = "";
|
$.each(data, function (i, el) {
|
if (!el.children) {
|
retStr += '<li class="subtncolor' + colorIndex + '"><a href="javascript:menuItemClick(\'' + el.attributes.url + '\',\'' + el.attributes.target + '\',\'' + el.text + '\',' + el.attributes.width + ',' + el.attributes.width + ')"><i class="' + el.iconCls + '"></i><span>' + el.text + '</span></a></li>';
|
} else {
|
retStr += getMenuChildren(el.children, colorIndex);
|
}
|
|
colorIndex = (colorIndex + 1) % 16;
|
})
|
|
return retStr;
|
}
|
|
function menuItemClick(url, target, text, width, height) {
|
if (url != "") {
|
if (target == "_blank") {
|
window.open(url);
|
} else if (target == "_layer") {
|
openLayer(url, text + "信息", width, height);
|
} else if (target == "_tab") {
|
addPanel(url, text);
|
}
|
|
addVisitHistory(text, url);
|
}
|
|
$(".pt_system_menu_btn").removeClass("open");
|
$(".pt_system_submenu").css({
|
"maxHeight": 0,
|
"display": "none"
|
});
|
}
|
|
//弹出层
|
function openLayer(url, title, width, height) {
|
top.layer.open({
|
title: title,
|
type: 2,
|
area: [width + "px", height + "px"],
|
fixed: false,
|
content: url,
|
success: function (layero, index) {
|
var body = window.top.layer.getChildFrame('body', index);
|
var iframeWin = window.top[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象
|
|
}
|
});
|
}
|
|
//添加访问历史
|
function addVisitHistory(visitName, visitUrl) {
|
wcp.ajax({
|
url: "management/visitHistory/saveVisitHistory",
|
contentType: "application/x-www-form-urlencoded",
|
data: {
|
visitName: visitName,
|
visitUrl: visitUrl
|
}
|
}).done(function (result) {
|
});
|
|
|
}
|
|
function changeSkin(skin, theme) {
|
var hrefcss = $("#skinStyle").attr("href");
|
hrefcss = hrefcss.substring(0, hrefcss.lastIndexOf("-") + 1) + skin + ".css";
|
|
$("#skinStyle").attr("href", hrefcss);
|
|
//存入cookie
|
wcp.utils.setCookieValue(theme, skin);
|
}
|
|
function setLeftMenuScroll() {
|
var wHeight = $(window).height();
|
var headerHeight = $(".header").height();
|
|
//先进行销毁,防止重复生成
|
$(".f_left_bd").slimScroll({
|
destroy: true
|
});
|
|
$(".f_left_bd").slimScroll({
|
height: wHeight - headerHeight,
|
railOpacity: .9,
|
color: '#fff', //滚动条颜色
|
disableFadeOut: true //是否 鼠标经过可滚动区域时显示组件,离开时隐藏组件
|
});
|
}
|
|
function autoHeight() {
|
//高度的设置
|
wHeight = $(window).height();
|
headerHeight = $(".header").height();
|
$("#leftbody").height(wHeight - headerHeight);
|
$("#rightbody").height(wHeight - headerHeight);
|
|
//宽度的设置
|
if ($("#ul_MainMenu").length > 0) {
|
var wWidth = $(window).width();
|
var mainMenuDiv = wWidth - 250 - 290;
|
$(".misc-action").width(mainMenuDiv);
|
var mainMenuUl = mainMenuDiv - 16;
|
$("#ul_MainMenu").width(mainMenuUl);
|
var sl = $("#ul_MainMenu li").size();
|
|
if (sl * 88 > mainMenuUl) {
|
$("#div_up").show();
|
$("#div_down").show();
|
} else {
|
$("#div_up").hide();
|
$("#div_down").hide();
|
}
|
|
var yushu = (sl * 88) % mainMenuUl; //余数
|
var shang = (sl * 88) / mainMenuUl; //商
|
if (shang == 0) {
|
maiMenuCeng = 1;
|
} else if (shang >= 1 && yushu == 0) {
|
maiMenuCeng = Math.floor(shang);
|
|
} else if (shang >= 1 && yushu > 0) {
|
maiMenuCeng = Math.floor(shang) + 1;
|
}
|
|
$("#ul_MainMenu").css("top", "0");
|
}
|
|
setLeftMenuScroll();
|
|
//所有的iframe的高度改变
|
$("iframe").not("[id^=layui-layer]").height(wHeight - headerHeight - 35);
|
}
|
|
/*
|
* 添加页签
|
*/
|
function addPanel(url, text, scrolling) {
|
var text2 = text.length > 8 ? text.substring(0, 8) + "..." : text;
|
var text3 = "<span title='" + text + "'>" + text2 + "</span>";
|
|
var panels = $('#tt').tabs('tabs');
|
|
if (panels != null) {
|
var isexist = false;
|
$.each(panels, function (i, panel) {
|
var title = $(panel).panel('options').title;
|
if (title == text3) {
|
$('#tt').tabs('select', i);
|
|
//刷新页签
|
if (menuItemClickRefreshExistTab) {
|
var tab = $('#tt').tabs('getSelected');
|
var id = $(tab).panel("options").id;
|
if (id != null) {
|
var iframeId = id.replace("tab_", "iframe_");
|
|
document.getElementById(iframeId).contentWindow.location = url;
|
}
|
}
|
|
isexist = true;
|
return false;
|
}
|
});
|
|
if (!isexist) {
|
addTab(url, text3, scrolling);
|
isexist = true;
|
}
|
} else {
|
addTab(url, text3, scrolling);
|
}
|
}
|
|
function addTab(url, text, scrolling) {
|
if (scrolling === undefined) {
|
scrolling = "no";
|
}
|
var id = randomNum(100000, 1000000);
|
$('#tt').tabs('add', {
|
title: text,
|
id: "tab_" + id,
|
content: '<iframe id="iframe_' + id + '" src="' + url + '" width="100%" height="' + (wHeight - headerHeight - 35) + 'px" marginheight="0" marginwidth="0" frameborder="0" scrolling="' + scrolling + '"></iframe>',
|
closable: true
|
});
|
}
|
|
function randomNum(Min, Max) {
|
var Range = Max - Min;
|
var Rand = Math.random();
|
var num = Min + Math.floor(Rand * Range); //舍去
|
return num;
|
}
|
|
/**
|
* 页签右键菜单事件
|
* @param item
|
*/
|
function contextMenuHandler(item) {
|
switch (item.name) {
|
case "closeNowPanel":
|
closeNowPanel();
|
break;
|
case "closeOtherPanel":
|
closeOtherPanel();
|
break;
|
case "closeRightPanel":
|
closeRightPanel();
|
break;
|
case "closeLeftPanel":
|
closeLeftPanel();
|
break;
|
}
|
}
|
|
/*
|
* 关闭当前页签
|
*/
|
function closeNowPanel() {
|
var tab = $('#tt').tabs('getSelected');
|
var index = $('#tt').tabs('getTabIndex', tab);
|
$('#tt').tabs('close', index);
|
}
|
|
/**
|
* 关闭其他页签
|
*/
|
function closeOtherPanel() {
|
var selectedTab = $('#tt').tabs('getSelected');
|
var tableTitle = selectedTab.panel('options').title;
|
|
var tabs = $('#tt').tabs('tabs');
|
for (var i = tabs.length - 1; i > 0; i--) {
|
var tab = $('#tt').tabs('getTab', i);
|
var title = tab.panel('options').title;
|
if (tableTitle != title) {
|
$('#tt').tabs('close', title);
|
}
|
}
|
}
|
|
/**
|
* 关闭右侧页签
|
*/
|
function closeRightPanel() {
|
var selectedTab = $('#tt').tabs('getSelected');
|
var index = $('#tt').tabs('getTabIndex', selectedTab);
|
|
var tabs = $('#tt').tabs('tabs');
|
for (var i = tabs.length - 1; i > index; i--) {
|
$('#tt').tabs('close', i);
|
}
|
}
|
|
/**
|
* 关闭左侧页签
|
*/
|
function closeLeftPanel() {
|
var selectedTab = $('#tt').tabs('getSelected');
|
var index = $('#tt').tabs('getTabIndex', selectedTab);
|
|
for (var i = index - 1; i > 0; i--) {
|
var tab = $('#tt').tabs('getTab', i);
|
var title = tab.panel('options').title;
|
$('#tt').tabs('close', title);
|
}
|
}
|
|
/**
|
* 关闭所有页签
|
*/
|
function closeAllPanel() {
|
var tabs = $('#tt').tabs('tabs');
|
for (var i = tabs.length - 1; i > 0; i--) {
|
$('#tt').tabs('close', i);
|
}
|
}
|
|
$(function () {
|
//左侧菜单栏缩进
|
$(".f_mid").click(function () {
|
var that = this;
|
var opts = $('#ul_menu').sidemenu('options');
|
$('#ul_menu').sidemenu(opts.collapsed ? 'expand' : 'collapse');
|
opts = $('#ul_menu').sidemenu('options');
|
$('#ul_menu').sidemenu('resize', {
|
width: opts.collapsed ? 60 : 210
|
})
|
|
if (opts.collapsed) {
|
$("#rightbody").animate({
|
paddingLeft: 60
|
}, 200, 'linear', function () {
|
$("#tt").tabs("resize");
|
});
|
|
$("#leftbody").animate({
|
width: 60
|
}, 200, 'linear', function () {
|
});
|
} else {
|
$("#rightbody").animate({
|
paddingLeft: 210
|
}, 200, 'linear', function () {
|
$("#tt").tabs("resize");
|
});
|
|
$("#leftbody").animate({
|
width: 210
|
}, 200, 'linear', function () {
|
});
|
}
|
});
|
|
//更多弹出层
|
$(".t_more").click(function (e) {
|
$(".t_more_link").toggle();
|
$(".username_link").hide();
|
$(document).one("click", function () {
|
$(".t_more_link").hide();
|
});
|
|
e.stopPropagation();
|
});
|
|
//用户信息弹出层
|
$(".username").click(function (e) {
|
$(".username_link").toggle();
|
$(".t_more_link").hide();
|
$(document).one("click", function () {
|
$(".username_link").hide();
|
});
|
|
e.stopPropagation();
|
});
|
|
//更改菜单
|
$(".t_more_link li").hover(
|
function () {
|
$(this).children().show();
|
$(this).siblings().children('div').hide()
|
});
|
|
$(".t_more_link li").click(function (e) {
|
e.stopPropagation();
|
});
|
|
$(".t_more_menu a,.t_more_link a").click(function (e) {
|
setTimeout(function () {
|
$(".t_more_link").toggle();
|
}, 100);
|
|
//e.stopPropagation();
|
});
|
|
});
|
|
function loginOut() {
|
layer.confirm("确定要退出登录吗?", {
|
icon: 3,
|
title: '提示'
|
}, function (index) {
|
window.location = loginUrl + "/loginOut";
|
|
layer.close(index);
|
});
|
}
|
|
function updatePassword() {
|
var url = "management/user/updatePasswordIndex";
|
top.layer.open({
|
title: "修改密码",
|
type: 2,
|
area: ["500px", "430px"],
|
fixed: false,
|
content: url,
|
success: function (layero, index) {
|
var body = window.top.layer.getChildFrame('body', index);
|
var iframeWin = window.top[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象
|
|
}
|
});
|
|
}
|
|
var maxId = 0;
|
var IconUrl = "static/images/msg.png";
|
|
//获取未读消息设置消息提醒
|
function getMessageCount() {
|
//获取未读消息条数
|
$.ajax({
|
url: "management/message/getUnreadMessageCount",
|
}).done(function (result) {
|
var msgCount = result.count;
|
if (msgCount == 0) {
|
$("#messageDs").removeClass("badge-tip");
|
}
|
if (msgCount > 0 && maxId != result.maxId) {
|
$("#messageDs").addClass("badge-tip");
|
if (maxId == 0 && msgCount > 3) {
|
var msgContent = "您有" + msgCount + "条新消息,请点击查看!";
|
if (window.Notification) {
|
var n = new Notification("消息提醒", {
|
body: msgContent,
|
icon: IconUrl
|
});
|
n.onclick = function () {
|
viewNotReadMessage();
|
};
|
n.onshown = function () {
|
//10秒后关闭消息框
|
setTimeout(function () {
|
n.close();
|
}, 10000);
|
};
|
|
}
|
|
} else {
|
//获取未读消息
|
$.ajax({
|
url: "management/message/getMessageList?maxId=" + maxId,
|
}).done(function (result) {
|
if (result.length > 0) {
|
var ids = [];
|
for (var i = 0; i < result.length; i++) {
|
ids.push(result[i].messageId);
|
var msg = result[i];
|
(function (para) {
|
if (window.Notification) {
|
var messageId = para.messageId;
|
var n = new Notification("来自" + para.sendUser + "的消息", {
|
body: para.messageContent,
|
icon: IconUrl,
|
tag: para.messageId
|
});
|
n.onclick = function () {
|
viewMessage(para.messageId, para.url, para.openType);
|
n.close();
|
};
|
n.onshown = function () {
|
//10秒后关闭消息框
|
setTimeout(function () {
|
n.close();
|
}, 10000);
|
};
|
}
|
})(msg);
|
|
}
|
|
}
|
});
|
|
}
|
maxId = result.maxId;
|
}
|
|
});
|
|
setTimeout(getMessageCount, 20000);
|
}
|
|
|
function viewNotReadMessage() {
|
var url = "management/message/viewMessage?number=1";
|
top.addPanel(url, "未读消息")
|
}
|
|
function showUpdateRead(id) {
|
var ids = [];
|
ids.push(id);
|
//修改当前的信息状态
|
wcp.ajax({
|
url: "management/message/updateRead",
|
data: JSON.stringify(ids),
|
}).done(function (resul) {
|
});
|
}
|
|
$(function () {
|
//初始化消息提醒控件,用于兼容IE
|
waitForNotificationsAndInit();
|
});
|
|
//初始化消息提醒权限
|
function init(permission) {
|
permission = permission || "default";
|
if ("default" === permission) {
|
Notification.requestPermission(function (permission) {
|
init(permission);
|
});
|
} else {
|
//获取未读消息数量
|
getMessageCount();
|
}
|
}
|
|
var attempts = 0;
|
|
function waitForNotificationsAndInit() {
|
if (window['Notification'] === undefined) {
|
if (attempts < 50) {
|
attempts++;
|
setTimeout(waitForNotificationsAndInit, 100);
|
}
|
} else {
|
init(Notification.permission);
|
}
|
}
|
|
function viewMessage(messageId, url, openType) {
|
if (url != null && url != "") {
|
if (openType == null || openType == "0") {
|
openMessageByLayer(url);
|
} else if (openType == "1") {
|
window.open(url);
|
} else if (openType == "2") {
|
top.addPanel(url, "查看消息[" + messageId + "]");
|
}
|
} else {
|
showMessageInfo(messageId);
|
}
|
|
showUpdateRead(messageId);
|
}
|
|
function openMessageByLayer(url) {
|
var title = "消息查看";
|
top.layer.open({
|
title: title,
|
type: 2,
|
area: ["1000px", "600px"],
|
fixed: false,
|
content: url,
|
success: function (layero, index) {
|
var body = window.top.layer.getChildFrame('body', index);
|
var iframeWin = window.top[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象
|
}
|
});
|
}
|
|
//消息查看
|
function showMessageInfo(messageId) {
|
var url = "management/message/showMessage?messageId=" + messageId;
|
var title = "消息查看";
|
top.layer.open({
|
title: title,
|
type: 2,
|
area: ["650px", "540px"],
|
fixed: false,
|
content: url,
|
success: function (layero, index) {
|
var body = window.top.layer.getChildFrame('body', index);
|
var iframeWin = window.top[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象
|
|
//将回调函数传给子页面
|
iframeWin.params.callBack = refreshData;
|
}
|
});
|
|
//window.event ? window.event.returnValue == false : e.preventDefault();
|
}
|
|
function updateRead(ids) {
|
//已弹框的修改为未读已弹框
|
wcp.ajax({
|
url: "management/message/updateRead",
|
data: JSON.stringify(ids),
|
}).done(function (result) {
|
});
|
|
}
|
|
//访问历史
|
function showVisitHistory() {
|
var url = "management/visitHistory";
|
top.layer.open({
|
title: "访问历史",
|
type: 2,
|
area: ["700px", "500px"],
|
fixed: false,
|
content: url,
|
success: function (layero, index) {
|
var body = window.top.layer.getChildFrame('body', index);
|
var iframeWin = window.top[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象
|
|
}
|
});
|
|
}
|
|
//密码到期验证
|
function passwordExpired() {
|
wcp.ajax({
|
url: "management/user/passwordExpired"
|
}).done(function (result) {
|
var mag = result.mag;
|
if (mag == 1) {
|
var message = "您的密码将于" + result.day + "天后过期,是否立即修改?";
|
layer.confirm(message, {
|
icon: 3,
|
title: '提示'
|
}, function (index) {
|
var url = "management/user/updatePasswordIndex?type=" + mag + "&day=" + result.day;
|
top.layer.open({
|
title: "修改密码",
|
type: 2,
|
area: ["500px", "430px"],
|
fixed: false,
|
content: url,
|
success: function (layero, index) {
|
var body = window.top.layer.getChildFrame('body', index);
|
var iframeWin = window.top[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象
|
|
}
|
});
|
layer.close(index);
|
});
|
|
} else if (mag == 2) {
|
var url = "management/user/updatePasswordIndex?type=" + mag;
|
top.layer.open({
|
title: "修改密码",
|
type: 2,
|
area: ["500px", "430px"],
|
closeBtn: 0,
|
content: url,
|
success: function (layero, index) {
|
var body = window.top.layer.getChildFrame('body', index);
|
var iframeWin = window.top[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象
|
|
}
|
});
|
|
}
|
|
});
|
|
}
|
|
//首次登录修改密码验证
|
function forceModifyPassword() {
|
wcp.ajax({
|
url: "management/user/forceModifyPassword"
|
}).done(function (result) {
|
if (result == 1) {
|
var url = "management/user/updatePasswordIndex?type=3";
|
top.layer.open({
|
title: "修改密码",
|
type: 2,
|
area: ["500px", "430px"],
|
closeBtn: 0,
|
content: url,
|
success: function (layero, index) {
|
var body = window.top.layer.getChildFrame('body', index);
|
var iframeWin = window.top[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象
|
|
}
|
});
|
|
}
|
|
});
|
}
|