Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

185 linhas
6.7 KiB

  1. $(function () {
  2. "use strict";
  3. $('body').on('click', '.site-menu-li', function () {
  4. var $this = $(this);
  5. var data = $this[0].data;
  6. if (data.F_UrlType == 1) {// 内部页面
  7. window.location.href = $.rootUrl + '/Home/ChildIndex?id=' + data.F_Url + '&menuid=' + data.F_Id;
  8. }
  9. else {// 外部页面
  10. window.open(data.F_Url);
  11. }
  12. return false;
  13. });
  14. ////banner 轮播
  15. var bannerSwiper = new Swiper('.lr-site-banner-swiper-container', {
  16. direction: 'horizontal',
  17. autoplay: true,
  18. loop: true,
  19. speed: 600,
  20. // 分页器
  21. pagination: {
  22. el: '.swiper-pagination',
  23. clickable: true
  24. },
  25. });
  26. // 渲染顶部菜单
  27. var renderTopMenu = function (_topMenuList) {
  28. var $topUl = $('.lr-site-nav-ul');
  29. $('.lr-site-sub-nav-ul').remove();
  30. $.each(_topMenuList["0"] || [], function (_index, _item) {
  31. var $item = $('<li class="lr-site-nav-li site-menu-li childPage">\
  32. <a href="javascript:void(0);" class="lr-site-nav-item"><span class="text">' + _item.F_Name + '</span></a>\
  33. </li>');
  34. $item[0].data = _item;
  35. $topUl.append($item);
  36. // 加载子菜单
  37. if (_topMenuList[_item.F_Id]) {
  38. var $subList = $('<div class="lr-site-sub-nav-ul" data-value="' + _item.F_Id + '" ><div class="lr-site-content"><ul class="lr-site-sub-nav-menu"></ul></div></div>');
  39. var $subUl = $subList.find('ul');
  40. $.each(_topMenuList[_item.F_Id], function (_jindex, _jitem) {
  41. var $jitem = $('<li class="lr-site-sub-nav-li site-menu-li"><a href="javascript:void(0);" class="lr-site-sub-nav-item">' + _jitem.F_Name + '</a></li>');
  42. $jitem[0].data = _jitem;
  43. // 加载三级子菜单
  44. if (_topMenuList[_jitem.F_Id]) {
  45. var $ul = $('<ul class="lr-site-three-nav-menu"></ul>');
  46. $.each(_topMenuList[_jitem.F_Id], function (_mindex, _mitem) {
  47. var $mitem = $('<li class="lr-site-three-nav-li site-menu-li"><a href="javascript:void(0);" class="lr-site-three-nav-item">' + _mitem.F_Name + '</a></li>');
  48. $mitem[0].data = _mitem;
  49. $ul.append($mitem);
  50. });
  51. $jitem.append($ul);
  52. }
  53. $subUl.append($jitem);
  54. });
  55. $('body').append($subList);
  56. }
  57. });
  58. $topUl.find('.childPage').hover(function () {
  59. var $this = $(this);
  60. var data = $this[0].data;
  61. $('.lr-site-sub-nav-ul').hide();
  62. var $subList = $('.lr-site-sub-nav-ul[data-value="' + data.F_Id + '"]');
  63. if ($subList.length > 0) {
  64. $subList[0].isShow = false;
  65. $subList.show();
  66. }
  67. }, function () {
  68. var $this = $(this);
  69. var data = $this[0].data;
  70. setTimeout(function () {
  71. var $subList = $('.lr-site-sub-nav-ul[data-value="' + data.F_Id + '"]');
  72. if ($subList.length > 0) {
  73. if (!$subList[0].isShow) {
  74. $subList.hide();
  75. }
  76. }
  77. }, 100);
  78. });
  79. $('.lr-site-sub-nav-ul').hover(function () {
  80. $(this)[0].isShow = true;
  81. $(this).show();
  82. }, function () {
  83. $(this)[0].isShow = false;
  84. $(this).hide();
  85. });
  86. }
  87. // 渲染底部菜单
  88. var renderBottomMenu = function (_bottomMenuList) {
  89. var $list = $('.lr-site-footer-nav-menu');
  90. $list.html('');
  91. $.each(_bottomMenuList, function (_index, _item) {
  92. var $item = $('<li class="lr-site-footer-nav-li site-menu-li"><a href="javascript:void(0);" class="lr-site-footer-nav-item">' + _item.F_Name + '</a></li>');
  93. $item[0].data = _item;
  94. $list.append($item);
  95. });
  96. }
  97. // 轮播图片
  98. var renderPicture = function (_pictureList) {
  99. var $swrapper = $('.lr-site-banner-swiper-container .swiper-wrapper');
  100. $swrapper.html("");
  101. if (_pictureList.length > 0) {
  102. $('.lr-site-banner-swiper-container').show();
  103. $('.lr-site-banner-default').hide();
  104. $.each(_pictureList, function (_index, _item) {
  105. var src = _item.src || ($.rootUrl + '/Home/GetImg2?keyValue=' + _item.F_Id);
  106. var $item = $('<div class="swiper-slide">\
  107. <img class="img" src="' + src + '" />\
  108. </div>');
  109. $swrapper.append($item);
  110. });
  111. }
  112. else {
  113. $('.lr-site-banner-swiper-container').hide();
  114. $('.lr-site-banner-default').show();
  115. }
  116. bannerSwiper.update();
  117. }
  118. httpGet($.rootUrl + '/Home/GetAllList', function (res) {
  119. console.log(res);
  120. var topMenuList = {};
  121. var bottomMenuList = [];
  122. var pictureList = [];
  123. if (res && res.code == 200) {
  124. $.each(res.data, function (_index, _item) {
  125. switch (_item.F_Type) {
  126. case '1':// 顶部文字
  127. $('#lr_site_top_text').text(_item.F_Name);
  128. break;
  129. case '2':// 底部文字
  130. $('.lr-site-bottom').text(_item.F_Name);
  131. break;
  132. case '3':// 底部地址
  133. $('.lr-site-contactInfo').text(_item.F_Name);
  134. break;
  135. case '4':// logo图片
  136. break;
  137. case '5':// 微信图片
  138. break;
  139. case '6':// 顶部菜单
  140. topMenuList[_item.F_ParentId] = topMenuList[_item.F_ParentId] || [];
  141. topMenuList[_item.F_ParentId].push(_item);
  142. break;
  143. case '7':// 底部菜单
  144. bottomMenuList.push(_item);
  145. break;
  146. case '8':
  147. pictureList.push(_item);
  148. break;
  149. case '9':
  150. break;
  151. case '11':
  152. $('.lr-site-footer-wechat .text').text(_item.F_Name);
  153. break;
  154. }
  155. });
  156. renderTopMenu(topMenuList);
  157. renderBottomMenu(bottomMenuList);
  158. renderPicture(pictureList);
  159. }
  160. });
  161. });