网站
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

125 行
4.4 KiB

  1. define(['jquery', "template", "Tools", 'LeftNav'], function ($, template, Tools, LeftNav) {
  2. //数据存储
  3. var module = {
  4. data: {
  5. //服务器地址
  6. serverApi: '',
  7. //焦点图数据
  8. focusList: [],
  9. communicateList: [],
  10. knowledgeOptions: [],
  11. noticeList: [],
  12. policyList: [],
  13. newList: [],
  14. dataList: {
  15. children: [],
  16. haschildren: true,
  17. isopen: false,
  18. level: "0",
  19. name: "",
  20. url: "#",
  21. },
  22. switchTab:'expert'
  23. },
  24. };
  25. var tools = new Tools();
  26. module.init = function (page) {
  27. //新闻管理列表
  28. tools.doGet(knowledgeClassification, {}, module.projectList, true);
  29. tools.doPost(expertDatabase, {}, module.expertDatabaseList, true);
  30. tools.doPost(articleLibrary, {}, module.articleLibraryList, true);
  31. tools.doPost(videoLibrary, {}, module.videoLibraryList, true);
  32. };
  33. //新闻列表
  34. module.projectList = function (data) {
  35. if (data.code == 200) {
  36. var content = data.data;
  37. content.forEach(res => {
  38. module.data.dataList.children.push(res);
  39. })
  40. leftNav(".left", module.data.dataList);
  41. }
  42. }
  43. //专家列表
  44. module.expertDatabaseList = function (data) {
  45. if (data.code == 200) {
  46. var content = data.data;
  47. for ( var i = 0 ; i < content.length ; i++ ){
  48. content[i].expertsImage = serverApi + content[i].expertsImage;
  49. }
  50. module.data.directoriesList = content;
  51. var directoriesData = template('directoriesData', module.data);
  52. $("#directoriesContent").html(directoriesData);
  53. }
  54. }
  55. //文章列表
  56. module.articleLibraryList = function (data) {
  57. if (data.code == 200) {
  58. var content = data.data;
  59. for ( var i = 0 ; i < content.length ; i++ ){
  60. content[i].cover = serverApi + content[i].cover;
  61. }
  62. module.data.articleList = content;
  63. var articleData = template('articleData', module.data);
  64. $("#articleContent").html(articleData);
  65. }
  66. }
  67. //视频列表
  68. module.videoLibraryList = function (data) {
  69. if (data.code == 200) {
  70. var content = data.data;
  71. for ( var i = 0 ; i < content.length ; i++ ){
  72. content[i].cover = serverApi + content[i].cover;
  73. }
  74. module.data.videoList = content;
  75. var videoData = template('videoData', module.data);
  76. $("#videoContent").html(videoData);
  77. }
  78. }
  79. switchTab = function (type) {
  80. $(".left .left_nav_name").removeClass("nav_open");
  81. $(".left .nav_li").removeClass("nav_li_open");
  82. tools.doPost(expertDatabase, {}, module.expertDatabaseList, true);
  83. tools.doPost(articleLibrary, {}, module.articleLibraryList, true);
  84. tools.doPost(videoLibrary, {}, module.videoLibraryList, true);
  85. $("#"+type+"Tit").addClass("active").siblings().removeClass("active");
  86. $("#"+type+"").css('display','block').siblings().css('display','none');
  87. module.data.switchTab = type;
  88. }
  89. goSearch = function (type) {
  90. if (type == 'expert'){
  91. tools.doPost(expertDatabase, {name: $("#searchInput").val()}, module.expertDatabaseList, true);
  92. }
  93. if (type == 'article'){
  94. tools.doPost(articleLibrary, {headline: $("#articleSearchInput").val()}, module.articleLibraryList, true);
  95. }
  96. if (type == 'video'){
  97. tools.doPost(videoLibrary, {headline: $("#videoSearchInput").val()}, module.videoLibraryList, true);
  98. }
  99. }
  100. searchType = function (id) {
  101. console.log(module.data.switchTab)
  102. $(".left .left_nav_name").removeClass("nav_open");
  103. if (module.data.switchTab == 'expert'){
  104. tools.doPost(expertDatabase, {field: id}, module.expertDatabaseList, true);
  105. }
  106. if (module.data.switchTab == 'article'){
  107. console.log('article------'+id)
  108. tools.doPost(articleLibrary, {knowledgeType: id}, module.articleLibraryList, true);
  109. }
  110. if (module.data.switchTab == 'video'){
  111. console.log('video------'+id)
  112. tools.doPost(videoLibrary, {knowledgeType: id}, module.videoLibraryList, true);
  113. }
  114. }
  115. return module;
  116. })