item.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title></title>
  7. <link rel="stylesheet" href="./bootstrap/css/bootstrap.min.css" />
  8. <link rel="stylesheet" href="./bootstrap/css/bootstrap-theme.min.css" />
  9. <link rel="stylesheet" href="./css/index.css" />
  10. <script src="./js/jquery.js"></script>
  11. <script src="./js/f2.min.js"></script>
  12. <script src="./bootstrap/js/bootstrap.min.js"></script>
  13. <style>
  14. .pageAccess .row {
  15. padding-left: 15px;
  16. }
  17. .pageAccess .col-md-6 {
  18. padding-left: 0;
  19. }
  20. .totalNum {
  21. font-size: 14px;
  22. text-align: center;
  23. }
  24. .totalNum .head {
  25. font-size: 42px;
  26. color: #91afc8;
  27. }
  28. .head {
  29. padding: 5px 5px 5px 10px;
  30. font-size: 17px;
  31. margin-top: 20px;
  32. margin-bottom: 10px;
  33. }
  34. .head .after {
  35. width: 3px;
  36. height: 1.1em;
  37. margin-left: -5px;
  38. display: inline-block;
  39. vertical-align: middle;
  40. background-color: #333;
  41. }
  42. .keyTotle,
  43. .valTotle {
  44. height: 30px;
  45. line-height: 30px;
  46. }
  47. .keyTotle {
  48. text-align: right;
  49. }
  50. </style>
  51. </head>
  52. <body class="pageAccess">
  53. <div class="panel panel-default total">
  54. <div class="panel-heading">传播数据</div>
  55. </div>
  56. <div class="row">
  57. <div class="col-md-6">
  58. <div class="panel panel-default">
  59. <div class="panel-heading">传播量趋势</div>
  60. <canvas id="container" style="width: 100%;height: 100%;" class=""></canvas>
  61. </div>
  62. </div>
  63. <div class="col-md-6">
  64. <div class="panel panel-default">
  65. <div class="panel-heading ">
  66. <div class="row">
  67. <div class="col-xs-6" style="padding-left: 0;">部门传播量排行</div>
  68. <div class="col-xs-6" style="text-align: right;">
  69. <div class="btn-group btn-group-xs " role="group">
  70. <div class="btn btn-default typeclick ALL">全部</div>
  71. <div class="btn btn-default typeclick MONTH">月</div>
  72. <div class="btn btn-default typeclick WEEK">周</div>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. <canvas id="barChart" style="width: 100%;height: 70vw;" class=""></canvas>
  78. </div>
  79. </div>
  80. <div class="col-md-6">
  81. <div class="panel panel-default">
  82. <div class="panel-heading">任务统计</div>
  83. <table class="table table-striped">
  84. <thead>
  85. <tr>
  86. <td>话题</td>
  87. <td>传播量</td>
  88. </tr>
  89. </thead>
  90. <tbody class="summary">
  91. </tbody>
  92. </table>
  93. </div>
  94. </div>
  95. <div class="col-md-6">
  96. <div class="panel panel-default">
  97. <div class="panel-heading">任务统计</div>
  98. <table class="table table-striped">
  99. <thead>
  100. <tr>
  101. <td>部门</td>
  102. <td>账号</td>
  103. <td>平台</td>
  104. <td>时间</td>
  105. </tr>
  106. </thead>
  107. <tbody class="summary1">
  108. </tbody>
  109. </table>
  110. </div>
  111. </div>
  112. </div>
  113. </body>
  114. <script src="./js/base.js"></script>
  115. <script>
  116. let linechart = null, barchart = null, type = "ALL";
  117. let searchObj = getsearch();
  118. function line1(li) {
  119. if (linechart) linechart.destroy();
  120. // 传播量趋势
  121. linechart = new F2.Chart({
  122. id: 'container',
  123. pixelRatio: window.devicePixelRatio
  124. });
  125. linechart.source(li, {
  126. dt: {
  127. tickCount: 3,
  128. },
  129. playCount: {
  130. tickCount: 5,
  131. }
  132. });
  133. linechart.axis('playCount', {
  134. label: function label(text, index, total) {
  135. const textCfg = {};
  136. textCfg.text = formatnum(text);
  137. return textCfg;
  138. },
  139. grid: null
  140. });
  141. linechart.axis('dt', {
  142. label: function label(text, index, total) {
  143. const textCfg = {};
  144. if (index === 0) {
  145. textCfg.textAlign = 'left';
  146. } else if (index === total - 1) {
  147. textCfg.textAlign = 'right';
  148. }
  149. return textCfg;
  150. }
  151. });
  152. linechart.tooltip({
  153. triggerOn: ['touchstart', 'touchmove'],
  154. onShow: function onShow(ev) {
  155. const items = ev.items;
  156. items[0].name = items[0].title;
  157. items[0].value = formatnum(text);
  158. items[1].name = null;
  159. items[1].value = 0;
  160. }
  161. });
  162. linechart.area()
  163. .position('dt*playCount')
  164. .color('l(90) 0:#1890FF 1:#f7f7f7')
  165. .shape('smooth');
  166. linechart.line()
  167. .position('dt*playCount')
  168. .color('l(90) 0:#1890FF 1:#f7f7f7')
  169. .shape('smooth');
  170. linechart.render();
  171. }
  172. function bar1(li) {
  173. if (barchart) barchart.destroy();
  174. barchart = new F2.Chart({
  175. id: 'barChart',
  176. pixelRatio: window.devicePixelRatio
  177. });
  178. barchart.source(li, {
  179. readCount: {
  180. tickCount: 3
  181. }
  182. });
  183. barchart.axis('readCount', {
  184. label: function label(text, index, total) {
  185. const textCfg = {};
  186. textCfg.text = formatnum(text);
  187. return textCfg;
  188. },
  189. grid: null
  190. });
  191. barchart.axis('depName', {
  192. label: function label(text, index, total) {
  193. const textCfg = {};
  194. if (index === 0) {
  195. textCfg.textAlign = 'left';
  196. } else if (index === total - 1) {
  197. textCfg.textAlign = 'right';
  198. }
  199. return textCfg;
  200. }
  201. });
  202. barchart.coord({
  203. transposed: true
  204. });
  205. barchart.tooltip({
  206. showItemMarker: false,
  207. triggerOn: ['touchstart', 'touchmove'],
  208. onShow: function onShow(ev) {
  209. const items = ev.items;
  210. items[0].name = null;
  211. items[0].name = items[0].title;
  212. items[0].value = '¥ ' + items[0].value;
  213. }
  214. });
  215. barchart.interval()
  216. .position('depName*readCount')
  217. .color('l(180) 0:#1890ff 1:#70cdd0'); // 定义柱状图渐变色
  218. barchart.render();
  219. }
  220. function gethistory() {
  221. require('GET', {
  222. url: "/topic/history",
  223. data: {
  224. topic: searchObj.topic
  225. }
  226. }).then(li => {
  227. line1(li);
  228. })
  229. }
  230. function getstart() {
  231. require('POST', {
  232. url: "/topic/dep-platform",
  233. data: {
  234. depRange: "ALL",
  235. title: searchObj.topic
  236. }
  237. }).then(data => {
  238. const li = (data || []).sort((a, b) => {
  239. return b.readTotal - a.readTotal
  240. });
  241. for (let i = 0; i < li.length; i += 2) {
  242. const v = li[i];
  243. let tr = $("<tr></tr>");
  244. tr.append($(`<td>${v.depName}</td><td>${formatnum(v.readTotal)}</td>`));
  245. $(".summary").append(tr)
  246. }
  247. })
  248. }
  249. function getoverview() {
  250. require('GET', {
  251. url: "/topic/overview",
  252. data: {
  253. topic: searchObj.topic
  254. }
  255. }).then(data => {
  256. const li = data || [];
  257. let k = {};
  258. for (let i = 0; i < li.length; i++) {
  259. const v = li[i];
  260. if (k[v.platform]) {
  261. k[v.platform] += v.playCount
  262. } else {
  263. k[v.platform] = v.playCount
  264. }
  265. }
  266. let keys = Object.keys(k);
  267. let d = $("<div class='row'></div>");
  268. for (let i = 0; i < keys.length; i++) {
  269. const v = keys[i];
  270. if (v === '总传播量') d.append($("<div class='col-xs-3 keyTotle'>" + v + "</div><div class='col-xs-9 valTotle'>" + formatnum(k[v]) + "</div>"));
  271. else d.append($("<div class='col-xs-3 keyTotle'>" + v + "</div><div class='col-xs-3 valTotle'>" + formatnum(k[v]) + "</div>"))
  272. }
  273. $('.total').append(d);
  274. })
  275. }
  276. function getread() {
  277. require('POST', {
  278. url: "/topic/read",
  279. data: {
  280. depRange: type,
  281. title: searchObj.topic
  282. }
  283. }).then(data => {
  284. const li = data || [];
  285. bar1(li.reverse());
  286. })
  287. }
  288. function getdetail() {
  289. require('POST', {
  290. url: "/topic/detail",
  291. data: {
  292. depRange: "ALL",
  293. title: searchObj.topic
  294. }
  295. }).then(data => {
  296. const li = (data.data || []).sort((a, b) => {
  297. return b.readTotal - a.readTotal
  298. });
  299. for (let i = 0; i < li.length; i += 2) {
  300. const v = li[i];
  301. let tr = $("<tr></tr>");
  302. tr.append($(`<td>${v.depName}</td><td>${v.name}</td><td>${v.platform}</td><td>${v.publishTime}</td>`));
  303. $(".summary1").append(tr)
  304. }
  305. })
  306. }
  307. function init() {
  308. let h = $('.panel-body').width() * 9 / 16;
  309. $('.panel-body').height(h);
  310. $('.typeclick').click(function (e) {
  311. let t = $(e.target).text();
  312. if (t === '全部') type = "ALL";
  313. if (t === '周') type = "WEEK";
  314. if (t === '月') type = "MONTH";
  315. $('.btn-primary').removeClass("btn-primary");
  316. $('.' + type).addClass("btn-primary")
  317. getread();
  318. })
  319. $('.' + type).addClass("btn-primary")
  320. gethistory();
  321. getoverview();
  322. getread();
  323. getstart();
  324. getdetail();
  325. }
  326. init();
  327. </script>
  328. </html>