You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

185 lines
7.0 KiB

  1. $(function () {
  2. "use strict";
  3. var articleId = request('id');
  4. $('body').on('click', '.site-menu-li', function () {
  5. var $this = $(this);
  6. var data = $this[0].data;
  7. if (data.F_UrlType == 1) {// 内部页面
  8. window.location.href = $.rootUrl + '/Home/ChildIndex?id=' + data.F_Url + '&menuid=' + data.F_Id;
  9. }
  10. else {// 外部页面
  11. window.open(data.F_Url);
  12. }
  13. return false;
  14. });
  15. $('.homePage').on('click', function () {
  16. window.location.href = $.rootUrl + '/Home/Index';
  17. });
  18. // 渲染顶部菜单
  19. var renderTopMenu = function (_topMenuList) {
  20. var $topUl = $('.lr-site-nav-ul');
  21. $('.lr-site-sub-nav-ul').remove();
  22. $.each(_topMenuList["0"] || [], function (_index, _item) {
  23. var $item = $('<li class="lr-site-nav-li site-menu-li childPage">\
  24. <a href="javascript:void(0);" class="lr-site-nav-item"><span class="text">' + _item.F_Name + '</span></a>\
  25. </li>');
  26. $item[0].data = _item;
  27. $topUl.append($item);
  28. // 加载子菜单
  29. if (_topMenuList[_item.F_Id]) {
  30. 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>');
  31. var $subUl = $subList.find('ul');
  32. $.each(_topMenuList[_item.F_Id], function (_jindex, _jitem) {
  33. 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>');
  34. $jitem[0].data = _jitem;
  35. // 加载三级子菜单
  36. if (_topMenuList[_jitem.F_Id]) {
  37. var $ul = $('<ul class="lr-site-three-nav-menu"></ul>');
  38. $.each(_topMenuList[_jitem.F_Id], function (_mindex, _mitem) {
  39. 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>');
  40. $mitem[0].data = _mitem;
  41. $ul.append($mitem);
  42. });
  43. $jitem.append($ul);
  44. }
  45. $subUl.append($jitem);
  46. });
  47. $('body').append($subList);
  48. }
  49. });
  50. $topUl.find('.childPage').hover(function () {
  51. var $this = $(this);
  52. var data = $this[0].data;
  53. $('.lr-site-sub-nav-ul').hide();
  54. var $subList = $('.lr-site-sub-nav-ul[data-value="' + data.F_Id + '"]');
  55. if ($subList.length > 0) {
  56. $subList[0].isShow = false;
  57. $subList.show();
  58. }
  59. }, function () {
  60. var $this = $(this);
  61. var data = $this[0].data;
  62. setTimeout(function () {
  63. var $subList = $('.lr-site-sub-nav-ul[data-value="' + data.F_Id + '"]');
  64. if ($subList.length > 0) {
  65. if (!$subList[0].isShow) {
  66. $subList.hide();
  67. }
  68. }
  69. }, 100);
  70. });
  71. $('.lr-site-sub-nav-ul').hover(function () {
  72. $(this)[0].isShow = true;
  73. $(this).show();
  74. }, function () {
  75. $(this)[0].isShow = false;
  76. $(this).hide();
  77. });
  78. }
  79. // 渲染底部菜单
  80. var renderBottomMenu = function (_bottomMenuList) {
  81. var $list = $('.lr-site-footer-nav-menu');
  82. $list.html('');
  83. $.each(_bottomMenuList, function (_index, _item) {
  84. 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>');
  85. $item[0].data = _item;
  86. $list.append($item);
  87. });
  88. }
  89. var formatDate = function (v, format) {
  90. if (!v) return "";
  91. var d = v;
  92. if (typeof v === 'string') {
  93. if (v.indexOf("/Date(") > -1)
  94. d = new Date(parseInt(v.replace("/Date(", "").replace(")/", ""), 10));
  95. else
  96. d = new Date(Date.parse(v.replace(/-/g, "/").replace("T", " ").split(".")[0]));//.split(".")[0] 用来处理出现毫秒的情况,截取掉.xxx,否则会出错
  97. }
  98. var o = {
  99. "M+": d.getMonth() + 1, //month
  100. "d+": d.getDate(), //day
  101. "h+": d.getHours(), //hour
  102. "m+": d.getMinutes(), //minute
  103. "s+": d.getSeconds(), //second
  104. "q+": Math.floor((d.getMonth() + 3) / 3), //quarter
  105. "S": d.getMilliseconds() //millisecond
  106. };
  107. if (/(y+)/.test(format)) {
  108. format = format.replace(RegExp.$1, (d.getFullYear() + "").substr(4 - RegExp.$1.length));
  109. }
  110. for (var k in o) {
  111. if (new RegExp("(" + k + ")").test(format)) {
  112. format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
  113. }
  114. }
  115. return format;
  116. };
  117. // 获取页面公共部分数据
  118. httpGet($.rootUrl + '/Home/GetAllList', function (res) {
  119. var topMenuList = {};
  120. var bottomMenuList = [];
  121. if (res && res.code == 200) {
  122. $.each(res.data, function (_index, _item) {
  123. switch (_item.F_Type) {
  124. case '1':// 顶部文字
  125. $('#lr_site_top_text').text(_item.F_Name);
  126. break;
  127. case '2':// 底部文字
  128. $('.lr-site-bottom').text(_item.F_Name);
  129. break;
  130. case '3':// 底部地址
  131. $('.lr-site-contactInfo').text(_item.F_Name);
  132. break;
  133. case '6':// 顶部菜单
  134. topMenuList[_item.F_ParentId] = topMenuList[_item.F_ParentId] || [];
  135. topMenuList[_item.F_ParentId].push(_item);
  136. break;
  137. case '7':// 底部菜单
  138. bottomMenuList.push(_item);
  139. break;
  140. case '11':
  141. $('.lr-site-footer-wechat .text').text(_item.F_Name);
  142. break;
  143. }
  144. });
  145. renderTopMenu(topMenuList);
  146. renderBottomMenu(bottomMenuList);
  147. }
  148. });
  149. httpGet($.rootUrl + '/Home/GetArticle?keyValue=' + articleId, function (res) {
  150. if (res && res.code == 200) {
  151. console.log(res.data);
  152. //var $list = $('#lr_body_cotent');
  153. // 图片地址切换
  154. var _content = res.data.F_Content.replace(/\/ueditor\/upload\/image/g, $.rootUrl + '/Home/GetUeditorImg?id=');
  155. $('.lr-site-body-container').append(_content);
  156. $('#title').text(res.data.F_Title);
  157. }
  158. });
  159. });