暂无描述

viewcount.js 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /**
  2. * Created by TT on 2017/9/22.
  3. */
  4. ;
  5. spa_define(function () {
  6. return $.use(["spa", "code", "form", "util", "dict"], function (spa, code, form, util, dict) {
  7. return {
  8. main: function () {
  9. var root = spa.findInMain(".sys_article_viewcount");
  10. var qf = form.build(root.find(".queryForm"));
  11. var cr = code.parseCode(root.find(".dt-tpl"));
  12. var queryBtn = root.find(".queryForm .opt-query");
  13. var tableData = {data: []},
  14. allData = [],
  15. $data = {tn: "article"};
  16. var now = new Date(),
  17. nbt = new Date();
  18. nbt.setDate(now.getDate() - 7);
  19. var et1 = now.format("yyyyMMdd"),
  20. bt1 = nbt.format("yyyyMMdd");
  21. qf.val({bt: bt1, et: et1});
  22. $data.bt = bt1;
  23. $data.et = et1;
  24. var caption = function (dicts, code) {
  25. var items = dict.get(dicts);
  26. var cp = dict.getCap(items, code.toString());
  27. if (cp) {
  28. return cp;
  29. }else {
  30. return "不可翻译的";
  31. }
  32. // return dict.get(dicts)[code].caption;
  33. },
  34. showDay = function (day) {
  35. if (day) {
  36. return day.substring(0, 4) + "年" + day.substring(4, 6) + "月" + day.substring(6, 8) + "日";
  37. } else return "";
  38. },
  39. loadContent = function () {
  40. root.find(".hand-id").each(function () {
  41. var $e = $(this);
  42. var articleId = $e.attr("articleId");
  43. if (articleId) {
  44. util.get("../ajax/article/id",{id:articleId}, function (data) {
  45. if (data) {
  46. $e.parent().find(".articleTitle").text(data.articleTitle);
  47. $e.parent().find(".professorName").text(data.professorName || data.organizationName);
  48. $e.parent().find(".subject").text(data.subject);
  49. $e.parent().find(".colNum").text(caption("banner", data.colNum));
  50. $e.parent().find(".publishTime").text(showDay(data.publishTime));
  51. $e.parent().find(".sortNum").text(data.sortNum);
  52. $e.parent().find(".pageViews").text(data.pageViews);
  53. $e.parent().find(".articleAgree").text(data.articleAgree);
  54. }
  55. }, {});
  56. // // $e.removeClass("hand-id");
  57. }
  58. });
  59. },
  60. load = function () {
  61. // console.log($data);
  62. $.ajax({
  63. type: "GET",
  64. url: "http://www.ekexiu.com:8082/log/jsonp/qs",
  65. data: $data,
  66. dataType: "jsonp",
  67. success: function (data) {
  68. // console.log(data);
  69. allData = data.data || [];
  70. // allData = [{
  71. // id: "8F08D2EB366140BC85A6A4CE344A15A4"
  72. // }, {
  73. // id: "8DE678A43FFB4097B3E0DFF9C48CC737"
  74. // }];
  75. tableData.data = allData;
  76. cr.val(tableData.data);
  77. loadContent();
  78. }
  79. });
  80. },
  81. query = function () {
  82. // if (qf.val().bt || qf.val().et) {
  83. $data.bt = qf.val().bt;
  84. $data.et = qf.val().et;
  85. // }else {
  86. // $data.bt = "";
  87. // $data.et = "";
  88. // }
  89. load();
  90. };
  91. queryBtn.on("click", query);
  92. load();
  93. root.find(".dt-tpl").on("click", "th.opt-check>i.icon-st-check", function () {
  94. var $this = $(this);
  95. $this.toggleClass("checked");
  96. if ($this.hasClass("checked")) {
  97. root.find(".dt-tpl td.opt-check>i.icon-st-check").addClass("checked");
  98. } else {
  99. root.find(".dt-tpl td.opt-check>i.icon-st-check").removeClass("checked");
  100. }
  101. });
  102. root.find(".dt-tpl").on("click", "td.opt-check>i.icon-st-check", function () {
  103. var $this = $(this);
  104. $this.toggleClass("checked");
  105. });
  106. // root.find(".opt-count").on("click", function () {
  107. // var $article = root.find("td.opt-check>i.checked");
  108. // if ($article.length) {
  109. // if ($article.length>1) {
  110. // util.alert("只能选择一篇文章");
  111. // }else {
  112. // spa.showModal("sys_article_count", {
  113. // id: $article.attr("articleId"),
  114. // hand: function () {
  115. // pdg.reload();
  116. // }
  117. // });
  118. // }
  119. // }else {
  120. // util.alert("请选择一篇文章");
  121. // }
  122. // });
  123. root.on("click",".icon-line-chart",function () {
  124. var $this = $(this);
  125. var articleId = $this.parent().attr("articleId");
  126. spa.showModal("sys_article_count",{
  127. id:articleId,
  128. hand:function () {
  129. pdg.reload();
  130. }
  131. })
  132. })
  133. },
  134. mainDestory: function () {
  135. }
  136. };
  137. });
  138. });