item.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  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/loading.css">
  10. <link rel="stylesheet" href="./css/index.css" />
  11. <script src="./js/jquery.js"></script>
  12. <script src="./js/f2.min.js"></script>
  13. <script src="./bootstrap/js/bootstrap.min.js"></script>
  14. <style>
  15. .pageAccess {
  16. padding-right: 5px;
  17. overflow-y: scroll;
  18. }
  19. .pageAccess .row {
  20. width: 100%;
  21. margin: 0;
  22. }
  23. .pageAccess .panel {
  24. margin-bottom: 5px;
  25. }
  26. .totalNum {
  27. font-size: 14px;
  28. text-align: center;
  29. }
  30. .totalNum .head {
  31. font-size: 42px;
  32. color: #91afc8;
  33. }
  34. .head {
  35. padding: 5px 5px 5px 10px;
  36. font-size: 17px;
  37. margin-top: 20px;
  38. margin-bottom: 10px;
  39. }
  40. .head .after {
  41. width: 3px;
  42. height: 1.1em;
  43. margin-left: -5px;
  44. display: inline-block;
  45. vertical-align: middle;
  46. background-color: #333;
  47. }
  48. .numTotle {
  49. /* height: 30px;
  50. line-height: 30px; */
  51. text-align: center;
  52. box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.2);
  53. margin: 10px 0;
  54. padding: 23px 0 18px 0;
  55. position: relative;
  56. }
  57. .colflex::after {
  58. content: " ";
  59. top: 45px;
  60. display: block;
  61. position: absolute;
  62. width: 1px;
  63. height: 30px;
  64. background: #EAEAEA;
  65. }
  66. .numTitle {
  67. font-size: 24px;
  68. height: 1em;
  69. color: #1A89B3;
  70. font-weight: bold;
  71. }
  72. .numValue {
  73. margin-top: 8px;
  74. font-size: 12px;
  75. color: #919191;
  76. }
  77. .flex {
  78. margin: 10px 0;
  79. display: flex;
  80. padding-top: 23px;
  81. padding-bottom: 18px;
  82. box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.2);
  83. }
  84. .colflex {
  85. flex: 1;
  86. }
  87. .flex .numTotle {
  88. box-shadow: none;
  89. }
  90. .colflex .numTotle {
  91. margin: 0;
  92. padding: 0;
  93. }
  94. .panel-default>.panel-heading {
  95. background: #fff;
  96. border-bottom: none;
  97. font-size: 14px;
  98. font-family: Adobe Heiti Std;
  99. font-weight: normal;
  100. color: #1A89B3;
  101. position: relative;
  102. }
  103. .panel-heading::after {
  104. content: " ";
  105. left: 0;
  106. top: 8px;
  107. display: block;
  108. position: absolute;
  109. width: 3px;
  110. height: 25px;
  111. background: #1A89B3;
  112. }
  113. .table-bg {
  114. margin: 17px;
  115. }
  116. .table-head {
  117. background-color: #ECEFF5;
  118. color: #3B3B3B;
  119. border-bottom: none;
  120. }
  121. .paging {
  122. display: flex;
  123. align-items: center;
  124. }
  125. .paging div {
  126. border: 1px solid rgb(211, 211, 211);
  127. padding: 10px;
  128. border-radius: 10px;
  129. cursor: pointer;
  130. margin: 0 10px;
  131. font-size: 14px;
  132. }
  133. .paging div.disable {
  134. color: #fff;
  135. cursor: not-allowed;
  136. background-color: rgb(211, 211, 211);
  137. }
  138. .paging div.active {
  139. border: none;
  140. background-color: #1989fa;
  141. color: #fff;
  142. }
  143. .bm li,
  144. #dLabel {
  145. cursor: pointer;
  146. }
  147. </style>
  148. </head>
  149. <body class="pageAccess">
  150. <div class="panel panel-default total">
  151. <div class="panel-heading">传播数据</div>
  152. </div>
  153. <div class="row">
  154. <div class="col-xs-8" style="padding: 0;">
  155. <div class="panel panel-default">
  156. <div class="panel-heading">传播量趋势</div>
  157. <canvas id="container" style="width: 100%;height: 100%;" class=""></canvas>
  158. </div>
  159. </div>
  160. <div class="col-xs-4" style="padding-right: 0;padding-left: 5px;">
  161. <div class="panel panel-default">
  162. <div class="panel-heading">传播平台占比</div>
  163. <canvas id="piechart" style="width: 100%;height: 100%;" class=""></canvas>
  164. </div>
  165. </div>
  166. </div>
  167. <div class="panel panel-default">
  168. <div class="panel-heading ">
  169. <div class="row">
  170. <div class="col-xs-6" style="padding-left: 0;">部门传播量排行</div>
  171. <div class="col-xs-6" style="text-align: right;">
  172. <div class="btn-group btn-group-xs " role="group">
  173. <div class="btn btn-default typeclick ALL">全部</div>
  174. <div class="btn btn-default typeclick MONTH">月</div>
  175. <div class="btn btn-default typeclick WEEK">周</div>
  176. </div>
  177. </div>
  178. </div>
  179. </div>
  180. <canvas id="barChart" style="width: 100%;height: 70vw;" class=""></canvas>
  181. </div>
  182. <div class="panel panel-default">
  183. <div class="panel-heading">任务统计</div>
  184. <div class="table-bg">
  185. <table class="table">
  186. <thead class="table-head">
  187. <tr>
  188. <td>话题</td>
  189. <td>传播量</td>
  190. </tr>
  191. </thead>
  192. <tbody class="summary">
  193. </tbody>
  194. </table>
  195. </div>
  196. </div>
  197. <div class="panel panel-default">
  198. <div class="panel-heading" style="padding-right: 110px;">
  199. 任务统计
  200. <div class="dropdown" style="float: right;color: #2e2e2e;">
  201. <div id="dLabel" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  202. <span class="bmTitle"></span>
  203. <span class="caret"></span>
  204. </div>
  205. <ul class="dropdown-menu bm" aria-labelledby="dLabel">
  206. </ul>
  207. </div>
  208. </div>
  209. <div class="table-bg">
  210. <table class="table">
  211. <thead class="table-head">
  212. <tr>
  213. <td>部门</td>
  214. <td>账号</td>
  215. <td>平台</td>
  216. <td>时间</td>
  217. </tr>
  218. </thead>
  219. <tbody class="summary1">
  220. </tbody>
  221. </table>
  222. <div class="paging"></div>
  223. </div>
  224. </div>
  225. </body>
  226. <script src="./js/base.js"></script>
  227. <script src="./js/page.js"></script>
  228. <script src="./js/loading.js"></script>
  229. <script>
  230. let linechart = null, barchart = null, piechart = null, type = "ALL";
  231. let page = 1, pageSize = 10, paging = null, bm = { id: undefined, depName: '全部' };
  232. let searchObj = getsearch();
  233. function line1(li) {
  234. if (linechart) linechart.destroy();
  235. // 传播量趋势
  236. linechart = new F2.Chart({
  237. id: 'container',
  238. pixelRatio: window.devicePixelRatio
  239. });
  240. linechart.source(li, {
  241. dt: {
  242. tickCount: 3,
  243. },
  244. playCount: {
  245. tickCount: 5,
  246. }
  247. });
  248. linechart.axis('playCount', {
  249. label: function label(text, index, total) {
  250. const textCfg = {};
  251. textCfg.text = formatnum(text);
  252. return textCfg;
  253. },
  254. grid: null
  255. });
  256. linechart.axis('dt', {
  257. label: function label(text, index, total) {
  258. const textCfg = {};
  259. if (index === 0) {
  260. textCfg.textAlign = 'left';
  261. } else if (index === total - 1) {
  262. textCfg.textAlign = 'right';
  263. }
  264. return textCfg;
  265. }
  266. });
  267. linechart.tooltip({
  268. triggerOn: ['touchstart', 'touchmove'],
  269. onShow: function onShow(ev) {
  270. const items = ev.items;
  271. items[0].name = items[0].title;
  272. items[0].value = formatnum(text);
  273. items[1].name = null;
  274. items[1].value = 0;
  275. }
  276. });
  277. linechart.area()
  278. .position('dt*playCount')
  279. .color('l(90) 0:#1890FF 1:#f7f7f7')
  280. .shape('smooth');
  281. linechart.line()
  282. .position('dt*playCount')
  283. .color('l(90) 0:#1890FF 1:#f7f7f7')
  284. .shape('smooth');
  285. linechart.render();
  286. }
  287. function pie1(li) {
  288. if (piechart) piechart.destroy();
  289. piechart = new F2.Chart({
  290. id: 'piechart',
  291. pixelRatio: window.devicePixelRatio,
  292. height: 325
  293. });
  294. let lis = [];
  295. for (let i = 0; i < li.length; i++) {
  296. const v = li[i];
  297. if (!v.readCount || v.readCount <= 0) continue;
  298. lis.push(v);
  299. }
  300. piechart.source(lis, {
  301. readCount: {
  302. formatter: function formatter(val) {
  303. return val + '%';
  304. }
  305. }
  306. });
  307. piechart.tooltip(false);
  308. piechart.legend(false);
  309. piechart.coord('polar', {
  310. transposed: true,
  311. innerRadius: 0.7,
  312. radius: 0.85
  313. });
  314. // 配置文本饼图
  315. piechart.pieLabel && piechart.pieLabel({
  316. sidePadding: 75,
  317. label1: function label1(data) {
  318. return {
  319. text: data.platform,
  320. fill: '#808080'
  321. };
  322. },
  323. label2: function label2(data) {
  324. return {
  325. fill: '#000000',
  326. text: formatnum(data.readCount),
  327. fontWeight: 500,
  328. fill: '#808080',
  329. fontSize: 10
  330. };
  331. }
  332. });
  333. piechart.axis(false);
  334. piechart.interval()
  335. .position('a*readCount')
  336. .color('platform', ['#1890FF', '#13C2C2', '#2FC25B', '#FACC14', '#F04864', '#8543E0', '#3436C7', '#223273'])
  337. .adjust('stack');
  338. piechart.render();
  339. }
  340. function bar1(li) {
  341. if (barchart) barchart.destroy();
  342. barchart = new F2.Chart({
  343. id: 'barChart',
  344. pixelRatio: window.devicePixelRatio
  345. });
  346. barchart.source(li, {
  347. readCount: {
  348. tickCount: 3
  349. }
  350. });
  351. barchart.axis('readCount', {
  352. label: function label(text, index, total) {
  353. const textCfg = {};
  354. textCfg.text = formatnum(text);
  355. return textCfg;
  356. },
  357. grid: null
  358. });
  359. barchart.axis('depName', {
  360. label: function label(text, index, total) {
  361. const textCfg = {};
  362. if (index === 0) {
  363. textCfg.textAlign = 'left';
  364. } else if (index === total - 1) {
  365. textCfg.textAlign = 'right';
  366. }
  367. return textCfg;
  368. }
  369. });
  370. barchart.coord({
  371. transposed: true
  372. });
  373. barchart.tooltip({
  374. showItemMarker: false,
  375. triggerOn: ['touchstart', 'touchmove'],
  376. onShow: function onShow(ev) {
  377. const items = ev.items;
  378. items[0].name = null;
  379. items[0].name = items[0].title;
  380. items[0].value = '¥ ' + items[0].value;
  381. }
  382. });
  383. barchart.interval()
  384. .position('depName*readCount')
  385. .color('l(180) 0:#1890ff 1:#70cdd0'); // 定义柱状图渐变色
  386. barchart.render();
  387. }
  388. function gethistory() {
  389. require('GET', {
  390. url: "/topic/history",
  391. data: {
  392. topic: searchObj.topic
  393. }
  394. }).then(li => {
  395. line1(li);
  396. })
  397. }
  398. function getstart() {
  399. require('POST', {
  400. url: "/topic/dep-platform",
  401. data: {
  402. depRange: "ALL",
  403. title: searchObj.topic
  404. }
  405. }).then(data => {
  406. const li = (data || []).sort((a, b) => {
  407. return b.readTotal - a.readTotal
  408. }), obj = {}, list = [];
  409. for (let i = 0; i < li.length; i += 2) {
  410. const v = li[i];
  411. let tr = $("<tr></tr>");
  412. tr.append($(`<td>${v.depName}</td><td>${formatnum(v.readTotal)}</td>`));
  413. $(".summary").append(tr);
  414. (v.list || []).map(p => {
  415. if (obj[p.platform]) {
  416. list[obj[p.platform]].readCount += Number(p.readCount || 0);
  417. list[obj[p.platform]].publishCount += Number(p.publishCount || 0);
  418. } else {
  419. obj[p.platform] = list.length;
  420. list.push({ readCount: p.readCount, publishCount: p.publishCount, platform: p.platform, a: '1' })
  421. }
  422. })
  423. }
  424. pie1(list)
  425. })
  426. }
  427. function getoverview() {
  428. require('GET', {
  429. url: "/topic/overview",
  430. data: {
  431. topic: searchObj.topic
  432. }
  433. }).then(data => {
  434. const li = data || [];
  435. let k = {};
  436. for (let i = 0; i < li.length; i++) {
  437. const v = li[i];
  438. if (k[v.platform]) {
  439. k[v.platform] += v.playCount
  440. } else {
  441. k[v.platform] = v.playCount
  442. }
  443. }
  444. let keys = Object.keys(k);
  445. let d = $("<div class='row'></div>"), s = $("<div class='col-xs-10 '></div>"), n = $("<div class='flex'></div>");
  446. let c = ['#FB6161', '#EC72DC', '#F98E53', '#49BED0', '#4BCA8B']
  447. for (let i = 0; i < keys.length; i++) {
  448. const v = keys[i];
  449. if (v === '总传播量') d.append($("<div class='col-xs-2' style='padding-right: 0'><div class='numTotle'><div class='numTitle'>" + formatnum(k[v]) + "</div><div class='numValue'>" + v + "</div></div></div>"));
  450. else n.append($("<div class='colflex'><div class='numTotle'><div class='numTitle' style='color: " + c[i - 1] + "'>" + formatnum(k[v]) + "</div><div class='numValue'>" + v + "</div></div></div>"));
  451. }
  452. s.append(n)
  453. d.append(s)
  454. $('.total').append(d);
  455. })
  456. }
  457. function getread() {
  458. require('POST', {
  459. url: "/topic/read",
  460. data: {
  461. depRange: type,
  462. title: searchObj.topic
  463. }
  464. }).then(data => {
  465. const li = data || [];
  466. bar1(li.reverse());
  467. })
  468. }
  469. function getdetail() {
  470. $('body').loading({
  471. loadingWidth: 240,
  472. title: '请稍等!',
  473. name: 'test',
  474. discription: '',
  475. direction: 'column',
  476. type: 'origin',
  477. // originBg:'#71EA71',
  478. originDivWidth: 40,
  479. originDivHeight: 40,
  480. originWidth: 6,
  481. originHeight: 6,
  482. smallLoading: false,
  483. loadingMaskBg: 'rgba(0,0,0,0.2)'
  484. });
  485. const p = {
  486. page,
  487. pageSize,
  488. title: searchObj.topic,
  489. }
  490. if (bm.depName && bm.depName !== '全部') p.depName = bm.depName;
  491. require('POST', {
  492. url: "/topic/detail",
  493. data: p
  494. }).then(data => {
  495. const li = (data.data || []).sort((a, b) => {
  496. return b.readTotal - a.readTotal
  497. });
  498. $(".summary1").html("");
  499. for (let i = 0; i < li.length; i++) {
  500. const v = li[i];
  501. let tr = $("<tr></tr>");
  502. tr.append($(`<td>${v.depName}</td><td>${v.name}</td><td>${v.platform}</td><td>${v.publishTime}</td>`));
  503. $(".summary1").append(tr)
  504. }
  505. removeLoading('test')
  506. if (paging) return
  507. paging = new Paging({
  508. total: data.total,
  509. pageChange(p) {
  510. if(p == page) return
  511. page = p;
  512. getdetail()
  513. }
  514. })
  515. })
  516. }
  517. function getbm() {
  518. require('GET', {
  519. url: "/topic/dep-dict",
  520. data: {
  521. depRange: "ALL",
  522. page,
  523. pageSize,
  524. title: searchObj.topic
  525. }
  526. }).then(data => {
  527. let li = data || [];
  528. $('.bm').append($(" <li><a href='##' id='-1'>全部</a></li>"))
  529. for (let i = 0; i < li.length; i++) {
  530. const v = li[i];
  531. $('.bm').append($(" <li><a href='##' id='" + v.id + "'>" + v.depName + "</a></li>"))
  532. }
  533. $('.bmTitle').text(bm.depName)
  534. })
  535. }
  536. function init() {
  537. let h = $('.panel-body').width() * 9 / 16;
  538. $('.panel-body').height(h);
  539. $('.typeclick').click(function (e) {
  540. let t = $(e.target).text();
  541. if (t === '全部') type = "ALL";
  542. if (t === '周') type = "WEEK";
  543. if (t === '月') type = "MONTH";
  544. $('.btn-primary').removeClass("btn-primary");
  545. $('.' + type).addClass("btn-primary")
  546. getread();
  547. })
  548. $('.bm').on("click", "li", function (e) {
  549. bm = {
  550. id: $(e.target).attr("id"), depName: $(this).text()
  551. }
  552. $('.bmTitle').text(bm.depName);
  553. paging = null;
  554. $('.paging').html("")
  555. getdetail()
  556. })
  557. $('.' + type).addClass("btn-primary")
  558. gethistory();
  559. getoverview();
  560. getread();
  561. getstart();
  562. getdetail();
  563. getbm();
  564. }
  565. init();
  566. </script>
  567. </html>