| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- var tab;
- $(function () {
- //加载弹出层
- layui.use(['form', 'element'], function () {
- layer = layui.layer;
- element = layui.element;
- //默认打开游戏管理
- // $('.left-nav #side-nav dd.layui-nav-item').each(function (index, item) {
- // $(item).children("dl").children("dd").each(function (i, e) {
- // if ($(e).children().find("cite").text() == "游戏分包") {
- // $(e).parent().css("display", "block");
- // $(e).parents().find('.nav_right').html('');
- // $(e).parents(".layui-nav-item").addClass("layui-this");
- // $(e).parents(".layui-nav-item").addClass("open");
- // e.click();
- // }
- // });
- // });
- });
- //触发事件
- tab = {
- tabAdd: function (title, url, id) {
- //新增一个Tab项
- element.tabAdd('xbs_tab', {
- title: title,
- content: '<iframe tab-id="' + id + '" frameborder="0" src="' + url + '" scrolling="yes" class="x-iframe"></iframe>',
- id: id
- });
- },
- tabDelete: function (index) {
- //删除指定Tab项
- element.tabDelete('xbs_tab', index); //删除:“商品管理”
- // othis.addClass('layui-btn-disabled');
- },
- tabChange: function (id) {
- //切换到指定Tab项
- element.tabChange('xbs_tab', id); //切换到:用户管理
- }
- };
- tableCheck = {
- init: function () {
- // $(".layui-form-checkbox").click(function (event) {
- // if ($(this).hasClass('layui-form-checked')) {
- // $(this).removeClass('layui-form-checked');
- // if ($(this).hasClass('header')) {
- // $(".layui-form-checkbox").removeClass('layui-form-checked');
- // }
- // } else {
- // $(this).addClass('layui-form-checked');
- // if ($(this).hasClass('header')) {
- // $(".layui-form-checkbox").addClass('layui-form-checked');
- // }
- // }
- // });
- },
- getData: function () {
- var obj = $(".layui-form-checked").not('.header');
- var arr = [];
- obj.each(function (index, el) {
- arr.push(obj.eq(index).attr('data-id'));
- });
- return arr;
- }
- }
- //开启表格多选
- tableCheck.init();
- $('.container .left_open i').click(function (event) {
- if ($('.left-nav').css('left') == '0px') {
- $('.left-nav').animate({
- left: '-221px'
- }, 100);
- $('.page-content').animate({
- left: '0px'
- }, 100);
- $('.page-content-bg').hide();
- } else {
- $('.left-nav').animate({
- left: '0px'
- }, 100);
- $('.page-content').animate({
- left: '221px'
- }, 100);
- if ($(window).width() < 768) {
- $('.page-content-bg').show();
- }
- }
- });
- //从221改成200
- $('.page-content-bg').click(function (event) {
- $('.left-nav').animate({
- left: '-221px'
- }, 100);
- $('.page-content').animate({
- left: '0px'
- }, 100);
- $(this).hide();
- });
- //tab上的新增li的关闭效果
- $('.layui-tab-close').click(function (event) {
- $('.layui-tab-title li').eq(0).find('i').remove();
- });
- //左侧菜单效果
- // $('#content').bind("click",function(event){
- // 将index的ul,li全部改成了dl,dd
- // $('.left-nav #nav2 dd').click(function (event) {
- $('.left-nav #nav2').on("click", "dd", function (event) {
- //换成了#nav2
-
- if ($(this).children('.sub-menu').length) {
- if ($(this).hasClass('open')) {
- $(this).removeClass('open');
- $(this).find('.nav_right').html('');
- $(this).children('.sub-menu').stop().slideUp();
- $(this).siblings().children('.sub-menu').slideUp();
- }
- else {
- $(this).addClass('open');
- $(this).children('a').find('.nav_right').html('');
- $(this).children('.sub-menu').stop().slideDown();
- $(this).siblings().children('.sub-menu').stop().slideUp();
- $(this).siblings().find('.nav_right').html('');
- $(this).siblings().removeClass('open');
- }
- } else {
- //当前选中样式
- $('#nav2 dd').removeClass('active');
- $(this).addClass('active').siblings().removeClass("active");
- var url = $(this).children('a').attr('_href');
- var title = $(this).find('cite').html();
- //改成了#nav
- var index = $('.sub-menu dd').index($(this));
- for (var i = 0; i < $('.x-iframe').length; i++) {
- if ($('.x-iframe').eq(i).attr('tab-id') == index + 1) {
- tab.tabChange(index + 1);
- event.stopPropagation();
- return;
- }
- };
- tab.tabAdd(title, url, index + 1);
- tab.tabChange(index + 1);
- // 判断是否过期,直接跳转到login页面
- $appiframe = $("[tab-id=" + (index + 1) + ']');
- $($appiframe).on('load', function () {
- var srcLoaded = $appiframe.get(0).contentWindow.location.href;
- if (srcLoaded.indexOf('/login/index') >= 0) {
- window.location.reload(true);
- }
- });
- }
- event.stopPropagation();
- });
-
- //针对子iframe
- $("body").on("click", function () {
- // for (var i = 0; i < window.parent.document.getElementsByTagName("iframe").length; i++) {
- // if (window.parent.document.getElementsByTagName("iframe")[i].src.indexOf('/login/index') >= 0) {
- // window.location.reload(true);
- // }
- // }
- if (window != window.top && window.location.href.indexOf('/login/index') >= 0) {
- window.top.location.href = window.location.href;
- }
- });
- });
- /*弹出层*/
- /*
- 参数解释:
- title 标题
- url 请求的url
- id 需要操作的数据id
- w 弹出层宽度(缺省调默认值)
- h 弹出层高度(缺省调默认值)
- */
- function x_admin_show(title, url, w, h) {
- if (title == null || title == '') {
- title = false;
- };
- if (url == null || url == '') {
- url = "404.html";
- };
- if (w == null || w == '') {
- w = ($(window).width() * 0.9);
- };
- if (h == null || h == '') {
- h = ($(window).height() - 50);
- };
- layer.open({
- type: 2,
- area: [w + 'px', h + 'px'],
- fix: false, //不固定
- maxmin: true,
- shadeClose: true,
- shade: 0.4,
- title: title,
- content: url
- });
- }
- function childController(title,url,parent) {
- //左侧菜单展开
- // var parent_nemu = $('#nav2 .tab1').find(".parent_nemu");
- var array = [];
- // for (var i = 0; i < parent_nemu.length; i++) {
- // array.push(parent_nemu[i].innerHTML)
- // }
- // var index = array.indexOf(parent);
- // var plam = $('#side-nav').find('.tab1').eq(index);
- // $(plam).addClass('open');
- // $(plam).children('a').find('.nav_right').html('');
- // $(plam).children('.sub-menu').stop().slideDown();
- // $(plam).siblings().children('.sub-menu').stop().slideUp();
- var nemu = $('#nav2 .sub-menu').find('dd');
- for (var i = 0; i < nemu.length; i++) {
- array.push($.trim(nemu[i].innerText))
- }
- var index = array.indexOf(title);
- for (var i = 0; i < $('.x-iframe').length; i++) {
- if ($('.x-iframe').eq(i).attr('tab-id') == index + 1) {
- tab.tabDelete(index+1);
- tab.tabAdd(title, url, index+1);
- tab.tabChange(index + 1);
- return;
- }
- };
- tab.tabAdd(title, url, index+1);
- tab.tabChange(index+1);
- }
- /*关闭弹出框口*/
- function x_admin_close() {
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- }
|