$(function () { // $(document).ready(function () { //加载弹出层 layui.use(['form', 'element'], function () { layer = layui.layer; element = layui.element; //默认打开游戏推荐 // .left-nav #nav>li $('.countLi').each(function (index, item) { // console.log($(item).children("a").find("cite").text()); if ($(item).children("a").text() == "主页") { // $(item).parent("ul").css("display", "block"); // $(item).parent().parent().addClass('open'); // $(item).parent().parent().find('.nav_right').html(''); item.click(); } }) }); //触发事件 var tab = { tabAdd: function (title, url, id) { //新增一个Tab项 element.tabAdd('xbs_tab', { title: title, content: '', id: id }) }, tabDelete: function (othis) { //删除指定Tab项 element.tabDelete('xbs_tab', '44'); //删除:“商品管理” 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: '-261px' }, 100); $('.page-content').animate({ left: '0px' }, 100); $('.page-content-bg').hide(); } else { $('.left-nav').animate({ left: '0px' }, 100); $('.page-content').animate({ left: '261px' }, 100); if ($(window).width() < 768) { $('.page-content-bg').show(); } } if ($('.logo').css('left') == '0px') { //是0所以要变成不为0的 $('.logo').animate({ left: '-260px' }, 100); // $('.bar').css("width","unset"); setTimeout(function () { $('.bar').css("width", "100%"); }) // $(".bar").css("width", 'calc(100% - 260px)'); // $(".container").css("background-color","#2a364f !important") // $('.bar').css("width", "100%"); // $(".left_open").css("left","50px") $('.bar').animate({ left: '0px' }, 100); // $('.page-content-bg').hide(); } else { //不是0所以要变成为0的 setTimeout(function () { $(".bar").css("width", 'calc(100% - 260px)'); }, 100) // $(".container").css("background-color","#fff") // $('.bar').css("width", "auto"); // $('.bar').css("width", "100%"); $('.logo').animate({ left: '0px' }, 100); $('.bar').animate({ left: '260px' }, 100); // if ($(window).width() < 768) { // $('.page-content-bg').show(); // } } }); $('.page-content-bg').click(function (event) { $('.left-nav').animate({ left: '-261px' }, 100); $('.page-content').animate({ left: '0px' }, 100); $(this).hide(); }); $('.layui-tab-close').click(function (event) { $('.layui-tab-title li').eq(0).find('i').remove(); }); // console.log($(".x-iframe")); // console.log($("iframe")); // $("iframe")[0].contentWindow.document.getElementByClassName('.gameName') // console.log($("iframe")[0].contentWindow.document.getElementByClassName('.gameName')); $(".countLi").addClass("refreshThis"); //左侧菜单效果 // console.log($('.left-nav #nav li')) // console.log(1111); // console.log($(".countLi")); var sub_ul_li = $(".sub-ul").find("li"); // console.log(sub_ul_li); var sub_ul_li_cite = $(".sub-ul").find("li").children().children("cite"); // console.log(sub_ul_li_cite); // $('.countLi') // $('.left-nav #nav li') $('.countLi').click(function (event) { // $("iframe").each(function (index,item) { // console.log(index); // console.log(item.contentWindow.document.getElementByClassName('.gameName')); // }) if ($(this).children('.sub-menu').length) { if ($(this).hasClass('open')) { $(this).removeClass('open'); $(this).find('.nav_right').html(''); $(this).children('.sub-menu').stop().slideUp("fast"); $(this).siblings().children('.sub-menu').slideUp("fast"); } else { $(this).addClass('open'); $(this).children('a').find('.nav_right').html(''); $(this).children('.sub-menu').stop().slideDown("fast"); $(this).siblings().children('.sub-menu').stop().slideUp("fast"); $(this).siblings().find('.nav_right').html(''); $(this).siblings().removeClass('open'); } } else { // console.log(this); // $(".sub-ul").show(); // $(".page-content .layui-tab-content").css("top", "81px"); var url = $(this).children('a').attr('_href'); var dataTitle = $(this).attr('data-title'); var title = $(this).find('cite').html(); // console.log(title); // var index = $('.left-nav #nav li').index($(this)); var index = $('.countLi').index($(this)); // console.log(index); var _that=$(this); // var allChildMenu = $(this).children(".sub-menu-hide").children(); // console.log(allChildMenu); for (var i = 0; i < sub_ul_li.length; i++) { if ($(sub_ul_li).eq(i).attr("data-title") == dataTitle) { $(sub_ul_li).eq(i).show(); } else { $(sub_ul_li).eq(i).hide(); } } $(".childMenuBar").show(); // $(".page-content .layui-tab-content").css("top", "11px"); //麻花网络资讯 点位管理 if (dataTitle == "ly_information"||dataTitle == "point_management"||dataTitle=="childChannel_management"||dataTitle=="recharge_management"||dataTitle == "data_statistics") { $(".childMenuBar").hide(); // $(".page-content .layui-tab-content").css("top", "0px"); } else { $(".childMenuBar").show(); // $(".page-content .layui-tab-content").css("top", "11px"); } //点位管理 // console.log($(".sub-ul").children()); //点击左侧导航是重置激活状态 if (dataTitle == "information_summary") { $(".sub-ul").children().each(function (index, item) { if ($(item).attr("data-title") == dataTitle) { if (index == 1) { $(item).addClass("chosenActive").siblings().removeClass("chosenActive") } } }); } if (dataTitle == "game_management") { $(".sub-ul").children().each(function (index, item) { if ($(item).attr("data-title") == dataTitle) { if (index == 6) { $(item).addClass("chosenActive").siblings().removeClass("chosenActive") } } }); } //充值管理 // if (dataTitle == "recharge_management") { // $(".sub-ul").children().each(function (index, item) { // if ($(item).attr("data-title") == dataTitle) { // if (index == 14) { // $(item).addClass("chosenActive").siblings().removeClass("chosenActive") // } // } // }); // } //平台币管理 if (dataTitle == "coin_management") { $(".sub-ul").children().each(function (index, item) { if ($(item).attr("data-title") == dataTitle) { if (index == 15) { $(item).addClass("chosenActive").siblings().removeClass("chosenActive") } } }); } //用户管理 if (dataTitle == "user_management") { $(".sub-ul").children().each(function (index, item) { if ($(item).attr("data-title") == dataTitle) { if (index == 10) { $(item).addClass("chosenActive").siblings().removeClass("chosenActive") } } }); } //个人中心 if (dataTitle == "personal_center") { $(".sub-ul").children().each(function (index, item) { if ($(item).attr("data-title") == dataTitle) { if (index == 21) { $(item).addClass("chosenActive").siblings().removeClass("chosenActive") } } }); } var activeNav=$(".J_for_active").length; //0-9是左侧导航栏里的li,剩余的是sub-ul里的li if(index>activeNav){ $(this).addClass("chosenActive"); $(this).siblings().removeClass("chosenActive"); }else{ $(this).addClass("active"); $(this).siblings().removeClass("active"); } // $('li.J_for_active li').removeClass('active'); // $(this).addClass('active').siblings().removeClass("active"); // 点击导航重加载功能 if ($(this).hasClass("refreshThis")) { $(this).removeClass("refreshThis"); $(this).siblings().addClass("refreshThis"); for (var i = 0; i < $('.x-iframe').length; i++) { if ($('.x-iframe').eq(i).attr('tab-id') == index + 1) { $('.x-iframe').eq(i)[0].contentWindow.location = url; } }; setTimeout(function () { _that.addClass("refreshThis"); }, 10000) } else { layer.msg("慢点!"); } 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(); }) // console.log($('.left-nav #nav li')); // $(".sub-ul").on("click", "li", function () { // // console.log($(".countLi")); // var url = $(this).children().attr("_href"); // console.log(url); // var title = $(this).find('cite').html(); // // console.log(title); // var index = $('.countLi').index($(this)); // console.log(index); // $(this).addClass("chosenActive"); // $(this).siblings().removeClass("chosenActive"); // // chosenActive // 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); // }) // $(".sub-menu li").click(function () { // console.log(this) // }) }) /*弹出层*/ /* 参数解释: 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 x_admin_close() { var index = parent.layer.getFrameIndex(window.name); parent.layer.close(index); }