| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 | var $, tab, skyconsWeather;layui.config({	base: "js/"}).use(['bodyTab', 'form', 'element', 'layer', 'jquery'], function() {	var form = layui.form,		layer = layui.layer,		element = layui.element;	$ = layui.jquery;	tab = layui.bodyTab();	//用户昵称	var userInfo = layui.sessionData(window.hywa.sessionTable.tableName);	$('#userName').html(JSON.stringify(userInfo) != '{}' ? userInfo[window.hywa.sessionTable.userData].name :		'游客用户');	//退出	$('#dropOut,#dropOut1').on("click", function() {		layer.msg('注销中……', {			icon: 6,			time: 5000		});		$.ajax({			type: "DELETE",			url: 'loginOut?userId=' + userInfo[window.hywa.sessionTable.userData].userId,			success: function(res) {				if (!(res.code - 0)) {					layui.sessionData(window.hywa.sessionTable.tableName, null);					window.sessionStorage.removeItem("menu");					let path = top.location.pathname.split('/');					path.splice(-1,1,'');					path = path.join('/');					top.location.href = path + window.hywa.jumpPage.login;				} else {				}			}		});	});	$('#clickReturn').on('click', function() {		location.href = "login/index.html"	})	//隐藏左侧导航	$(".hideMenu").click(function() {		$(".layui-layout-admin").toggleClass("showMenu");		//渲染顶部窗口		tab.tabMove();	})	//渲染左侧菜单	tab.render();	//锁屏	function lockPage() {		layer.open({			title: false,			type: 1,			content: $("#lock-box"),			closeBtn: 0,			shade: 0.9		})	}	//手机设备的简单适配	var treeMobile = $('.site-tree-mobile'),		shadeMobile = $('.site-mobile-shade')	treeMobile.on('click', function() {		$('body').addClass('site-mobile');	});	shadeMobile.on('click', function() {		$('body').removeClass('site-mobile');	});	// 添加新窗口	$(".layui-nav .layui-nav-item a").on("click", function() {		addTab($(this));		$(this).parent("li").siblings().removeClass("layui-nav-itemed");	});	//判断是否处于锁屏状态(如果关闭以后则未关闭浏览器之前不再显示)	if (window.sessionStorage.getItem("lockcms") != "true" && window.sessionStorage.getItem("showNotice") !=		"true") {		if (typeof showNotice !== 'undefined') showNotice();	}	$(".showNotice").on("click", function() {		showNotice();	})	//刷新当前	$(".refresh").on("click", function() { //此处添加禁止连续点击刷新一是为了降低服务器压力,另外一个就是为了防止超快点击造成chrome本身的一些js文件的报错(不过貌似这个问题还是存在,不过概率小了很多)		if ($(this).hasClass("refreshThis")) {			$(this).removeClass("refreshThis");			$(".clildFrame .layui-tab-item.layui-show").find("iframe")[0].contentWindow.location.reload(true);			setTimeout(function() {				$(".refresh").addClass("refreshThis");			}, 2000)		} else {			layer.msg("您点击的速度超过了服务器的响应速度,还是等两秒再刷新吧!");		}	})	//关闭其他	$(".closePageOther").on("click", function() {		if ($("#top_tabs li").length > 2 && $("#top_tabs li.layui-this cite").text() != "后台首页") {			var menu = JSON.parse(window.sessionStorage.getItem("menu"));			$("#top_tabs li").each(function() {				if ($(this).attr("lay-id") != '' && !$(this).hasClass("layui-this")) {					element.tabDelete("bodyTab", $(this).attr("lay-id")).init();					//此处将当前窗口重新获取放入session,避免一个个删除来回循环造成的不必要工作量					for (var i = 0; i < menu.length; i++) {						if ($("#top_tabs li.layui-this cite").text() == menu[i].title) {							menu.splice(0, menu.length, menu[i]);							window.sessionStorage.setItem("menu", JSON.stringify(menu));						}					}				}			})		} else if ($("#top_tabs li.layui-this cite").text() == "后台首页" && $("#top_tabs li").length > 1) {			$("#top_tabs li").each(function() {				if ($(this).attr("lay-id") != '' && !$(this).hasClass("layui-this")) {					element.tabDelete("bodyTab", $(this).attr("lay-id")).init();					window.sessionStorage.removeItem("menu");					menu = [];					window.sessionStorage.removeItem("curmenu");				}			})		} else {			layer.msg("没有可以关闭的窗口了@_@");		}		//渲染顶部窗口		tab.tabMove();	})	//关闭全部	$(".closePageAll").on("click", function() {		if ($("#top_tabs li").length > 1) {			$("#top_tabs li").each(function() {				if ($(this).attr("lay-id") != '') {					element.tabDelete("bodyTab", $(this).attr("lay-id")).init();					window.sessionStorage.removeItem("menu");					menu = [];					window.sessionStorage.removeItem("curmenu");				}			})			$('.layui-nav-tree').find('.layui-this').removeClass('layui-this')		} else {			layer.msg("没有可以关闭的窗口了@_@");		}		//渲染顶部窗口		tab.tabMove();	})})//打开新窗口function addTab(_this) {	tab.tabAdd(_this);}
 |