cps.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. $(function () {
  2. // $(document).ready(function () {
  3. //加载弹出层
  4. layui.use(['form', 'element'], function () {
  5. layer = layui.layer;
  6. element = layui.element;
  7. //默认打开游戏推荐
  8. // .left-nav #nav>li
  9. $('.countLi').each(function (index, item) {
  10. // console.log($(item).children("a").find("cite").text());
  11. if ($(item).children("a").text() == "主页") {
  12. // $(item).parent("ul").css("display", "block");
  13. // $(item).parent().parent().addClass('open');
  14. // $(item).parent().parent().find('.nav_right').html('');
  15. item.click();
  16. }
  17. })
  18. });
  19. //触发事件
  20. var tab = {
  21. tabAdd: function (title, url, id) {
  22. //新增一个Tab项
  23. element.tabAdd('xbs_tab', {
  24. title: title,
  25. content: '<iframe tab-id="' + id + '" frameborder="0" src="' + url + '" scrolling="yes" class="x-iframe"></iframe>',
  26. id: id
  27. })
  28. },
  29. tabDelete: function (othis) {
  30. //删除指定Tab项
  31. element.tabDelete('xbs_tab', '44'); //删除:“商品管理”
  32. othis.addClass('layui-btn-disabled');
  33. },
  34. tabChange: function (id) {
  35. //切换到指定Tab项
  36. element.tabChange('xbs_tab', id); //切换到:用户管理
  37. }
  38. };
  39. tableCheck = {
  40. init: function () {
  41. $(".layui-form-checkbox").click(function (event) {
  42. if ($(this).hasClass('layui-form-checked')) {
  43. $(this).removeClass('layui-form-checked');
  44. if ($(this).hasClass('header')) {
  45. $(".layui-form-checkbox").removeClass('layui-form-checked');
  46. }
  47. } else {
  48. $(this).addClass('layui-form-checked');
  49. if ($(this).hasClass('header')) {
  50. $(".layui-form-checkbox").addClass('layui-form-checked');
  51. }
  52. }
  53. });
  54. },
  55. getData: function () {
  56. var obj = $(".layui-form-checked").not('.header');
  57. var arr = [];
  58. obj.each(function (index, el) {
  59. arr.push(obj.eq(index).attr('data-id'));
  60. });
  61. return arr;
  62. }
  63. }
  64. //开启表格多选
  65. tableCheck.init();
  66. $('.container .left_open i').click(function (event) {
  67. if ($('.left-nav').css('left') == '0px') {
  68. $('.left-nav').animate({
  69. left: '-261px'
  70. }, 100);
  71. $('.page-content').animate({
  72. left: '0px'
  73. }, 100);
  74. $('.page-content-bg').hide();
  75. } else {
  76. $('.left-nav').animate({
  77. left: '0px'
  78. }, 100);
  79. $('.page-content').animate({
  80. left: '261px'
  81. }, 100);
  82. if ($(window).width() < 768) {
  83. $('.page-content-bg').show();
  84. }
  85. }
  86. if ($('.logo').css('left') == '0px') {
  87. //是0所以要变成不为0的
  88. $('.logo').animate({
  89. left: '-260px'
  90. }, 100);
  91. // $('.bar').css("width","unset");
  92. setTimeout(function () {
  93. $('.bar').css("width", "100%");
  94. })
  95. // $(".bar").css("width", 'calc(100% - 260px)');
  96. // $(".container").css("background-color","#2a364f !important")
  97. // $('.bar').css("width", "100%");
  98. // $(".left_open").css("left","50px")
  99. $('.bar').animate({
  100. left: '0px'
  101. }, 100);
  102. // $('.page-content-bg').hide();
  103. } else {
  104. //不是0所以要变成为0的
  105. setTimeout(function () {
  106. $(".bar").css("width", 'calc(100% - 260px)');
  107. }, 100)
  108. // $(".container").css("background-color","#fff")
  109. // $('.bar').css("width", "auto");
  110. // $('.bar').css("width", "100%");
  111. $('.logo').animate({
  112. left: '0px'
  113. }, 100);
  114. $('.bar').animate({
  115. left: '260px'
  116. }, 100);
  117. // if ($(window).width() < 768) {
  118. // $('.page-content-bg').show();
  119. // }
  120. }
  121. });
  122. $('.page-content-bg').click(function (event) {
  123. $('.left-nav').animate({
  124. left: '-261px'
  125. }, 100);
  126. $('.page-content').animate({
  127. left: '0px'
  128. }, 100);
  129. $(this).hide();
  130. });
  131. $('.layui-tab-close').click(function (event) {
  132. $('.layui-tab-title li').eq(0).find('i').remove();
  133. });
  134. // console.log($(".x-iframe"));
  135. // console.log($("iframe"));
  136. // $("iframe")[0].contentWindow.document.getElementByClassName('.gameName')
  137. // console.log($("iframe")[0].contentWindow.document.getElementByClassName('.gameName'));
  138. $(".countLi").addClass("refreshThis");
  139. //左侧菜单效果
  140. // console.log($('.left-nav #nav li'))
  141. // console.log(1111);
  142. // console.log($(".countLi"));
  143. var sub_ul_li = $(".sub-ul").find("li");
  144. // console.log(sub_ul_li);
  145. var sub_ul_li_cite = $(".sub-ul").find("li").children().children("cite");
  146. // console.log(sub_ul_li_cite);
  147. // $('.countLi')
  148. // $('.left-nav #nav li')
  149. $('.countLi').click(function (event) {
  150. // $("iframe").each(function (index,item) {
  151. // console.log(index);
  152. // console.log(item.contentWindow.document.getElementByClassName('.gameName'));
  153. // })
  154. if ($(this).children('.sub-menu').length) {
  155. if ($(this).hasClass('open')) {
  156. $(this).removeClass('open');
  157. $(this).find('.nav_right').html('&#xe697;');
  158. $(this).children('.sub-menu').stop().slideUp("fast");
  159. $(this).siblings().children('.sub-menu').slideUp("fast");
  160. } else {
  161. $(this).addClass('open');
  162. $(this).children('a').find('.nav_right').html('&#xe6a6;');
  163. $(this).children('.sub-menu').stop().slideDown("fast");
  164. $(this).siblings().children('.sub-menu').stop().slideUp("fast");
  165. $(this).siblings().find('.nav_right').html('&#xe697;');
  166. $(this).siblings().removeClass('open');
  167. }
  168. } else {
  169. // console.log(this);
  170. // $(".sub-ul").show();
  171. // $(".page-content .layui-tab-content").css("top", "81px");
  172. var url = $(this).children('a').attr('_href');
  173. var dataTitle = $(this).attr('data-title');
  174. var title = $(this).find('cite').html();
  175. // console.log(title);
  176. // var index = $('.left-nav #nav li').index($(this));
  177. var index = $('.countLi').index($(this));
  178. // console.log(index);
  179. var _that=$(this);
  180. // var allChildMenu = $(this).children(".sub-menu-hide").children();
  181. // console.log(allChildMenu);
  182. for (var i = 0; i < sub_ul_li.length; i++) {
  183. if ($(sub_ul_li).eq(i).attr("data-title") == dataTitle) {
  184. $(sub_ul_li).eq(i).show();
  185. } else {
  186. $(sub_ul_li).eq(i).hide();
  187. }
  188. }
  189. $(".childMenuBar").show();
  190. // $(".page-content .layui-tab-content").css("top", "11px");
  191. //麻花网络资讯 点位管理
  192. if (dataTitle == "ly_information"||dataTitle == "point_management"||dataTitle=="childChannel_management"||dataTitle=="recharge_management"||dataTitle == "data_statistics") {
  193. $(".childMenuBar").hide();
  194. // $(".page-content .layui-tab-content").css("top", "0px");
  195. } else {
  196. $(".childMenuBar").show();
  197. // $(".page-content .layui-tab-content").css("top", "11px");
  198. }
  199. //点位管理
  200. // console.log($(".sub-ul").children());
  201. //点击左侧导航是重置激活状态
  202. if (dataTitle == "information_summary") {
  203. $(".sub-ul").children().each(function (index, item) {
  204. if ($(item).attr("data-title") == dataTitle) {
  205. if (index == 1) {
  206. $(item).addClass("chosenActive").siblings().removeClass("chosenActive")
  207. }
  208. }
  209. });
  210. }
  211. if (dataTitle == "game_management") {
  212. $(".sub-ul").children().each(function (index, item) {
  213. if ($(item).attr("data-title") == dataTitle) {
  214. if (index == 6) {
  215. $(item).addClass("chosenActive").siblings().removeClass("chosenActive")
  216. }
  217. }
  218. });
  219. }
  220. //充值管理
  221. // if (dataTitle == "recharge_management") {
  222. // $(".sub-ul").children().each(function (index, item) {
  223. // if ($(item).attr("data-title") == dataTitle) {
  224. // if (index == 14) {
  225. // $(item).addClass("chosenActive").siblings().removeClass("chosenActive")
  226. // }
  227. // }
  228. // });
  229. // }
  230. //平台币管理
  231. if (dataTitle == "coin_management") {
  232. $(".sub-ul").children().each(function (index, item) {
  233. if ($(item).attr("data-title") == dataTitle) {
  234. if (index == 15) {
  235. $(item).addClass("chosenActive").siblings().removeClass("chosenActive")
  236. }
  237. }
  238. });
  239. }
  240. //用户管理
  241. if (dataTitle == "user_management") {
  242. $(".sub-ul").children().each(function (index, item) {
  243. if ($(item).attr("data-title") == dataTitle) {
  244. if (index == 10) {
  245. $(item).addClass("chosenActive").siblings().removeClass("chosenActive")
  246. }
  247. }
  248. });
  249. }
  250. //个人中心
  251. if (dataTitle == "personal_center") {
  252. $(".sub-ul").children().each(function (index, item) {
  253. if ($(item).attr("data-title") == dataTitle) {
  254. if (index == 21) {
  255. $(item).addClass("chosenActive").siblings().removeClass("chosenActive")
  256. }
  257. }
  258. });
  259. }
  260. var activeNav=$(".J_for_active").length;
  261. //0-9是左侧导航栏里的li,剩余的是sub-ul里的li
  262. if(index>activeNav){
  263. $(this).addClass("chosenActive");
  264. $(this).siblings().removeClass("chosenActive");
  265. }else{
  266. $(this).addClass("active");
  267. $(this).siblings().removeClass("active");
  268. }
  269. // $('li.J_for_active li').removeClass('active');
  270. // $(this).addClass('active').siblings().removeClass("active");
  271. // 点击导航重加载功能
  272. if ($(this).hasClass("refreshThis")) {
  273. $(this).removeClass("refreshThis");
  274. $(this).siblings().addClass("refreshThis");
  275. for (var i = 0; i < $('.x-iframe').length; i++) {
  276. if ($('.x-iframe').eq(i).attr('tab-id') == index + 1) {
  277. $('.x-iframe').eq(i)[0].contentWindow.location = url;
  278. }
  279. };
  280. setTimeout(function () {
  281. _that.addClass("refreshThis");
  282. }, 10000)
  283. } else {
  284. layer.msg("慢点!");
  285. }
  286. for (var i = 0; i < $('.x-iframe').length; i++) {
  287. if ($('.x-iframe').eq(i).attr('tab-id') == index + 1) {
  288. tab.tabChange(index + 1);
  289. event.stopPropagation();
  290. return;
  291. }
  292. };
  293. tab.tabAdd(title, url, index + 1);
  294. tab.tabChange(index + 1);
  295. // 判断是否过期,直接跳转到login页面
  296. $appiframe = $("[tab-id=" + (index + 1) + ']');
  297. $($appiframe).on('load', function () {
  298. var srcLoaded = $appiframe.get(0).contentWindow.location.href;
  299. if (srcLoaded.indexOf('/login/index') >= 0) {
  300. window.location.reload(true);
  301. }
  302. })
  303. }
  304. event.stopPropagation();
  305. })
  306. // console.log($('.left-nav #nav li'));
  307. // $(".sub-ul").on("click", "li", function () {
  308. // // console.log($(".countLi"));
  309. // var url = $(this).children().attr("_href");
  310. // console.log(url);
  311. // var title = $(this).find('cite').html();
  312. // // console.log(title);
  313. // var index = $('.countLi').index($(this));
  314. // console.log(index);
  315. // $(this).addClass("chosenActive");
  316. // $(this).siblings().removeClass("chosenActive");
  317. // // chosenActive
  318. // for (var i = 0; i < $('.x-iframe').length; i++) {
  319. // if ($('.x-iframe').eq(i).attr('tab-id') == index + 1) {
  320. // tab.tabChange(index + 1);
  321. // event.stopPropagation();
  322. // return;
  323. // }
  324. // };
  325. // tab.tabAdd(title, url, index + 1);
  326. // tab.tabChange(index + 1);
  327. // })
  328. // $(".sub-menu li").click(function () {
  329. // console.log(this)
  330. // })
  331. })
  332. /*弹出层*/
  333. /*
  334. 参数解释:
  335. title 标题
  336. url 请求的url
  337. id 需要操作的数据id
  338. w 弹出层宽度(缺省调默认值)
  339. h 弹出层高度(缺省调默认值)
  340. */
  341. function x_admin_show(title, url, w, h) {
  342. if (title == null || title == '') {
  343. title = false;
  344. };
  345. if (url == null || url == '') {
  346. url = "404.html";
  347. };
  348. if (w == null || w == '') {
  349. w = ($(window).width() * 0.9);
  350. };
  351. if (h == null || h == '') {
  352. h = ($(window).height() - 50);
  353. };
  354. layer.open({
  355. type: 2,
  356. area: [w + 'px', h + 'px'],
  357. fix: false, //不固定
  358. maxmin: true,
  359. shadeClose: true,
  360. shade: 0.4,
  361. title: title,
  362. content: url
  363. });
  364. }
  365. /*关闭弹出框口*/
  366. function x_admin_close() {
  367. var index = parent.layer.getFrameIndex(window.name);
  368. parent.layer.close(index);
  369. }