leftNav.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. function navBar(data) {
  2. var ulHtml = '<ul class="layui-nav layui-nav-tree">';
  3. for (var i = 0; i < data.length; i++) {
  4. if (data[i].spread) {
  5. ulHtml += '<li class="layui-nav-item layui-nav-itemed">';
  6. } else {
  7. ulHtml += '<li class="layui-nav-item">';
  8. }
  9. if (data[i].subMenuList != undefined && data[i].subMenuList.length > 0) {
  10. ulHtml += '<a href="javascript:;">';
  11. if (data[i].ico != undefined && data[i].ico != '') {
  12. if (data[i].ico - 0 == 0) {
  13. data[i].ico = "&nbsp;";
  14. }
  15. if (data[i].ico.indexOf("icon-") != -1) {
  16. ulHtml += '<i class="iconfont ' + data[i].ico + '" data-icon="' + data[i].ico + '"></i>';
  17. } else {
  18. ulHtml += '<i class="layui-icon" data-icon="' + data[i].ico + '">' + data[i].ico + '</i>';
  19. }
  20. }
  21. ulHtml += '<cite>' + data[i].funName + '</cite>';
  22. ulHtml += '<span class="layui-nav-more"></span>';
  23. ulHtml += '</a>'
  24. ulHtml += '<dl class="layui-nav-child">';
  25. for (var j = 0; j < data[i].subMenuList.length; j++) {
  26. ulHtml += '<dd><a href="javascript:;" data-url="' + data[i].subMenuList[j].fileUrl + '?id=' + data[i].subMenuList[j].id + '&ver=' + SYS_VER + '">';
  27. if (data[i].subMenuList[j].ico != undefined && data[i].subMenuList[j].ico != '') {
  28. if (data[i].subMenuList[j].ico - 0 == 0) {
  29. data[i].subMenuList[j].ico = "&nbsp;";
  30. }
  31. if (data[i].subMenuList[j].ico.indexOf("icon-") != -1) {
  32. ulHtml += '<i class="iconfont ' + data[i].subMenuList[j].ico + '" data-icon="' + data[i].subMenuList[j].ico + '"></i>';
  33. } else {
  34. ulHtml += '<i class="layui-icon" data-icon="' + data[i].subMenuList[j].ico + '">' + data[i].subMenuList[j].ico + '</i>';
  35. }
  36. }
  37. ulHtml += '<cite>' + data[i].subMenuList[j].funName + '</cite></a></dd>';
  38. }
  39. ulHtml += "</dl>"
  40. } else {
  41. ulHtml += '<a href="javascript:;" data-url="' + data[i].fileUrl + '?id=' + data[i].id + '&ver=' + SYS_VER + '">';
  42. if (data[i].ico != undefined && data[i].ico != '') {
  43. if (data[i].ico - 0 == 0) {
  44. data[i].ico = "&nbsp;";
  45. }
  46. if (data[i].ico.indexOf("icon-") != -1) {
  47. ulHtml += '<i class="iconfont ' + data[i].ico + '" data-icon="' + data[i].ico + '"></i>';
  48. } else {
  49. ulHtml += '<i class="layui-icon" data-icon="' + data[i].ico + '">' + data[i].ico + '</i>';
  50. }
  51. }
  52. ulHtml += '<cite>' + data[i].funName + '</cite></a>';
  53. }
  54. ulHtml += '</li>'
  55. }
  56. ulHtml += '</ul>';
  57. return ulHtml;
  58. }