news.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* var informationsMap = Object.create(MAP); */
  2. function displayinformation(informations) {
  3. var html = "";
  4. for ( var i in informations) {
  5. if (i == 0 && informations[i].weight == 0) {
  6. html += "<li class='first_news' >"
  7. + "<table style='width:100%;height:100%;padding-bottom:40px;'><tr><td style='width:30%;background: url("
  8. + imageurl
  9. + informations[i].informationTime
  10. + "-1.jpg) no-repeat;background-size: contain;'></td><td style='padding-left:40px;'>"
  11. + "<p style='font-family: arial,\"Microsoft Yahei\",\"Hiragino Sans GB\",sans-serif;font-size: 22px;color: #000;'>"
  12. + informations[i].title
  13. + "</p>"
  14. + "<p style='font-family: arial,\"Microsoft Yahei\",\"Hiragino Sans GB\",sans-serif;font-size: 14px;color: #999;'>"
  15. + informations[i].informationTime
  16. + "</p>"
  17. + "<p style='font-family: arial,\"Microsoft Yahei\",\"Hiragino Sans GB\",sans-serif;font-size: 12px;color: #8c8c8c;line-height:24px;margin-bottom: 0;'>"
  18. + informations[i].subContent
  19. + "</p>"
  20. + "<p style='text-align: right;margin-top: 0;'><a href='javascript:void(0);' name="
  21. + informations[i].id
  22. + " id='news_more'>【详情】</a></p>"
  23. + "</td></tr></table>" + "</li>";
  24. /* informationsMap.Set(informations[i].id,
  25. informations[i].informationContent); */
  26. } else {
  27. html += "<li class='common_news' id="+informations[i].id+"><table style='width:100%;height:100%'><tr><td class='td_left'><span class='round'>•</span></td><td class='td_middle'>"
  28. + informations[i].title
  29. + "</td><td class='td_right'>"
  30. + informations[i].informationTime
  31. + "</td></tr></table></li>";
  32. /* informationsMap.Set(informations[i].id,
  33. informations[i].informationContent); */
  34. }
  35. }
  36. $("#all_news").html(html);
  37. $("#news_more").on("click", function() {
  38. /* var html = informationsMap.Get(this.name);
  39. html = html.replace(new RegExp(/(imageurl)/g), imageurl);
  40. $("#company_dynamic").html(html); */
  41. window.open(newsDetailUrl + this.name + ".html", '_blank');
  42. // 防止事件冒泡
  43. event.stopPropagation();
  44. });
  45. $(".common_news").on("click", function() {
  46. /* var html = informationsMap.Get(this.id); */
  47. /* html = html.replace(new RegExp(/(imageurl)/g), imageurl); */
  48. window.open(newsDetailUrl + this.id + ".html", '_blank');
  49. /* $("#company_dynamic").html(html); */
  50. });
  51. }
  52. function getinformation(pagesize, nextpage) {
  53. $.ajax({
  54. type : "GET",
  55. url : url + "informations/" + pagesize + "/" + nextpage
  56. + ".json",
  57. dataType : "json",
  58. contentType : "application/json",
  59. success : function(data) {
  60. if (data != null) {
  61. totalPage = data.pageCount;
  62. totalRecords = data.allrecodesCount;
  63. setpage(data.currentPage);
  64. //设置内容
  65. displayinformation(data.informations);
  66. }
  67. }
  68. });
  69. }
  70. var pagesize = 15;
  71. if (pageNo == null || pageNo == "") {
  72. getinformation(pagesize, 1);
  73. } else {
  74. getinformation(pagesize, pageNo);
  75. }
  76. var totalPage = 20;
  77. var totalRecords = 390;
  78. function setpage(currentpage) {
  79. if (!pageNo) {
  80. pageNo = currentpage;
  81. }
  82. //生成分页
  83. //有些参数是可选的,比如lang,若不传有默认值
  84. kkpager.generPageHtml({
  85. pno : pageNo,
  86. //总页码
  87. total : totalPage,
  88. //总数据条数
  89. totalRecords : totalRecords,
  90. mode : 'link',//默认值是link,可选link或者click
  91. getLink : function(n) {
  92. return "/about/news/" + n;
  93. }
  94. /* click : function(n) {
  95. // do something
  96. getinformation(pagesize, n);
  97. //手动选中按钮
  98. this.selectPage(n);
  99. return false;
  100. } */
  101. /*
  102. ,lang : {
  103. firstPageText : '首页',
  104. firstPageTipText : '首页',
  105. lastPageText : '尾页',
  106. lastPageTipText : '尾页',
  107. prePageText : '上一页',
  108. prePageTipText : '上一页',
  109. nextPageText : '下一页',
  110. nextPageTipText : '下一页',
  111. totalPageBeforeText : '共',
  112. totalPageAfterText : '页',
  113. currPageBeforeText : '当前第',
  114. currPageAfterText : '页',
  115. totalInfoSplitStr : '/',
  116. totalRecordsBeforeText : '共',
  117. totalRecordsAfterText : '条数据',
  118. gopageBeforeText : ' 转到',
  119. gopageButtonOkText : '确定',
  120. gopageAfterText : '页',
  121. buttonTipBeforeText : '第',
  122. buttonTipAfterText : '页'
  123. }*/
  124. });
  125. }