item.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  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: rgb(78, 216, 250);
  141. color: #fff;
  142. }
  143. </style>
  144. </head>
  145. <body class="pageAccess">
  146. <div class="panel panel-default total">
  147. <div class="panel-heading">传播数据</div>
  148. </div>
  149. <div class="row">
  150. <div class="col-xs-8" style="padding: 0;">
  151. <div class="panel panel-default">
  152. <div class="panel-heading">传播量趋势</div>
  153. <canvas id="container" style="width: 100%;height: 100%;" class=""></canvas>
  154. </div>
  155. </div>
  156. <div class="col-xs-4" style="padding-right: 0;padding-left: 5px;">
  157. <div class="panel panel-default">
  158. <div class="panel-heading">传播平台占比</div>
  159. <canvas id="piechart" style="width: 100%;height: 100%;" class=""></canvas>
  160. </div>
  161. </div>
  162. </div>
  163. <div class="panel panel-default">
  164. <div class="panel-heading ">
  165. <div class="row">
  166. <div class="col-xs-6" style="padding-left: 0;">部门传播量排行</div>
  167. <div class="col-xs-6" style="text-align: right;">
  168. <div class="btn-group btn-group-xs " role="group">
  169. <div class="btn btn-default typeclick ALL">全部</div>
  170. <div class="btn btn-default typeclick MONTH">月</div>
  171. <div class="btn btn-default typeclick WEEK">周</div>
  172. </div>
  173. </div>
  174. </div>
  175. </div>
  176. <canvas id="barChart" style="width: 100%;height: 70vw;" class=""></canvas>
  177. </div>
  178. <div class="panel panel-default">
  179. <div class="panel-heading">任务统计</div>
  180. <div class="table-bg">
  181. <table class="table">
  182. <thead class="table-head">
  183. <tr>
  184. <td>话题</td>
  185. <td>传播量</td>
  186. </tr>
  187. </thead>
  188. <tbody class="summary">
  189. </tbody>
  190. </table>
  191. </div>
  192. </div>
  193. <div class="panel panel-default">
  194. <div class="panel-heading">
  195. 任务统计
  196. <div class="dropdown" style="float: right;color: #2e2e2e;margin-right: 100px;">
  197. <div id="dLabel" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  198. 全部
  199. <span class="caret"></span>
  200. </div>
  201. <ul class="dropdown-menu" aria-labelledby="dLabel">
  202. </ul>
  203. </div>
  204. </div>
  205. <div class="table-bg">
  206. <table class="table">
  207. <thead class="table-head">
  208. <tr>
  209. <td>部门</td>
  210. <td>账号</td>
  211. <td>平台</td>
  212. <td>时间</td>
  213. </tr>
  214. </thead>
  215. <tbody class="summary1">
  216. </tbody>
  217. </table>
  218. <div class="paging"></div>
  219. </div>
  220. </div>
  221. </body>
  222. <script src="./js/base.js"></script>
  223. <script src="./js/page.js"></script>
  224. <script src="./js/loading.js"></script>
  225. <script>
  226. let linechart = null, barchart = null, piechart = null, type = "ALL";
  227. let page = 1, pageSize = 10, paging = null;
  228. let searchObj = getsearch();
  229. function line1(li) {
  230. if (linechart) linechart.destroy();
  231. // 传播量趋势
  232. linechart = new F2.Chart({
  233. id: 'container',
  234. pixelRatio: window.devicePixelRatio
  235. });
  236. linechart.source(li, {
  237. dt: {
  238. tickCount: 3,
  239. },
  240. playCount: {
  241. tickCount: 5,
  242. }
  243. });
  244. linechart.axis('playCount', {
  245. label: function label(text, index, total) {
  246. const textCfg = {};
  247. textCfg.text = formatnum(text);
  248. return textCfg;
  249. },
  250. grid: null
  251. });
  252. linechart.axis('dt', {
  253. label: function label(text, index, total) {
  254. const textCfg = {};
  255. if (index === 0) {
  256. textCfg.textAlign = 'left';
  257. } else if (index === total - 1) {
  258. textCfg.textAlign = 'right';
  259. }
  260. return textCfg;
  261. }
  262. });
  263. linechart.tooltip({
  264. triggerOn: ['touchstart', 'touchmove'],
  265. onShow: function onShow(ev) {
  266. const items = ev.items;
  267. items[0].name = items[0].title;
  268. items[0].value = formatnum(text);
  269. items[1].name = null;
  270. items[1].value = 0;
  271. }
  272. });
  273. linechart.area()
  274. .position('dt*playCount')
  275. .color('l(90) 0:#1890FF 1:#f7f7f7')
  276. .shape('smooth');
  277. linechart.line()
  278. .position('dt*playCount')
  279. .color('l(90) 0:#1890FF 1:#f7f7f7')
  280. .shape('smooth');
  281. linechart.render();
  282. }
  283. function pie1(li) {
  284. if (piechart) piechart.destroy();
  285. piechart = new F2.Chart({
  286. id: 'piechart',
  287. pixelRatio: window.devicePixelRatio,
  288. height: 325
  289. });
  290. let lis = [];
  291. for (let i = 0; i < li.length; i++) {
  292. const v = li[i];
  293. if (!v.readCount || v.readCount <= 0) continue;
  294. lis.push(v);
  295. }
  296. piechart.source(lis, {
  297. readCount: {
  298. formatter: function formatter(val) {
  299. return val + '%';
  300. }
  301. }
  302. });
  303. piechart.tooltip(false);
  304. piechart.legend(false);
  305. piechart.coord('polar', {
  306. transposed: true,
  307. innerRadius: 0.7,
  308. radius: 0.85
  309. });
  310. // 配置文本饼图
  311. piechart.pieLabel && piechart.pieLabel({
  312. sidePadding: 75,
  313. label1: function label1(data) {
  314. return {
  315. text: data.platform,
  316. fill: '#808080'
  317. };
  318. },
  319. label2: function label2(data) {
  320. return {
  321. fill: '#000000',
  322. text: formatnum(data.readCount),
  323. fontWeight: 500,
  324. fill: '#808080',
  325. fontSize: 10
  326. };
  327. }
  328. });
  329. piechart.axis(false);
  330. piechart.interval()
  331. .position('a*readCount')
  332. .color('platform', ['#1890FF', '#13C2C2', '#2FC25B', '#FACC14', '#F04864', '#8543E0', '#3436C7', '#223273'])
  333. .adjust('stack');
  334. piechart.render();
  335. }
  336. function bar1(li) {
  337. if (barchart) barchart.destroy();
  338. barchart = new F2.Chart({
  339. id: 'barChart',
  340. pixelRatio: window.devicePixelRatio
  341. });
  342. barchart.source(li, {
  343. readCount: {
  344. tickCount: 3
  345. }
  346. });
  347. barchart.axis('readCount', {
  348. label: function label(text, index, total) {
  349. const textCfg = {};
  350. textCfg.text = formatnum(text);
  351. return textCfg;
  352. },
  353. grid: null
  354. });
  355. barchart.axis('depName', {
  356. label: function label(text, index, total) {
  357. const textCfg = {};
  358. if (index === 0) {
  359. textCfg.textAlign = 'left';
  360. } else if (index === total - 1) {
  361. textCfg.textAlign = 'right';
  362. }
  363. return textCfg;
  364. }
  365. });
  366. barchart.coord({
  367. transposed: true
  368. });
  369. barchart.tooltip({
  370. showItemMarker: false,
  371. triggerOn: ['touchstart', 'touchmove'],
  372. onShow: function onShow(ev) {
  373. const items = ev.items;
  374. items[0].name = null;
  375. items[0].name = items[0].title;
  376. items[0].value = '¥ ' + items[0].value;
  377. }
  378. });
  379. barchart.interval()
  380. .position('depName*readCount')
  381. .color('l(180) 0:#1890ff 1:#70cdd0'); // 定义柱状图渐变色
  382. barchart.render();
  383. }
  384. function gethistory() {
  385. require('GET', {
  386. url: "/topic/history",
  387. data: {
  388. topic: searchObj.topic
  389. }
  390. }).then(li => {
  391. line1(li);
  392. })
  393. }
  394. function getstart() {
  395. require('POST', {
  396. url: "/topic/dep-platform",
  397. data: {
  398. depRange: "ALL",
  399. title: searchObj.topic
  400. }
  401. }).then(data => {
  402. const li = (data || []).sort((a, b) => {
  403. return b.readTotal - a.readTotal
  404. }), obj = {}, list = [];
  405. for (let i = 0; i < li.length; i += 2) {
  406. const v = li[i];
  407. let tr = $("<tr></tr>");
  408. tr.append($(`<td>${v.depName}</td><td>${formatnum(v.readTotal)}</td>`));
  409. $(".summary").append(tr);
  410. (v.list || []).map(p => {
  411. if (obj[p.platform]) {
  412. list[obj[p.platform]].readCount += Number(p.readCount || 0);
  413. list[obj[p.platform]].publishCount += Number(p.publishCount || 0);
  414. } else {
  415. obj[p.platform] = list.length;
  416. list.push({ readCount: p.readCount, publishCount: p.publishCount, platform: p.platform, a: '1' })
  417. }
  418. })
  419. }
  420. pie1(list)
  421. })
  422. }
  423. function getoverview() {
  424. require('GET', {
  425. url: "/topic/overview",
  426. data: {
  427. topic: searchObj.topic
  428. }
  429. }).then(data => {
  430. const li = data || [];
  431. let k = {};
  432. for (let i = 0; i < li.length; i++) {
  433. const v = li[i];
  434. if (k[v.platform]) {
  435. k[v.platform] += v.playCount
  436. } else {
  437. k[v.platform] = v.playCount
  438. }
  439. }
  440. let keys = Object.keys(k);
  441. let d = $("<div class='row'></div>"), s = $("<div class='col-xs-10 '></div>"), n = $("<div class='flex'></div>");
  442. let c = ['#FB6161', '#EC72DC', '#F98E53', '#49BED0', '#4BCA8B']
  443. for (let i = 0; i < keys.length; i++) {
  444. const v = keys[i];
  445. 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>"));
  446. 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>"));
  447. }
  448. s.append(n)
  449. d.append(s)
  450. $('.total').append(d);
  451. })
  452. }
  453. function getread() {
  454. require('POST', {
  455. url: "/topic/read",
  456. data: {
  457. depRange: type,
  458. title: searchObj.topic
  459. }
  460. }).then(data => {
  461. const li = data || [];
  462. bar1(li.reverse());
  463. })
  464. }
  465. function getdetail() {
  466. console.log('--',$('body').loading)
  467. $('body').loading({
  468. loadingWidth: 240,
  469. title: '请稍等!',
  470. name: 'test',
  471. discription: '',
  472. direction: 'column',
  473. type: 'origin',
  474. // originBg:'#71EA71',
  475. originDivWidth: 40,
  476. originDivHeight: 40,
  477. originWidth: 6,
  478. originHeight: 6,
  479. smallLoading: false,
  480. loadingMaskBg: 'rgba(0,0,0,0.2)'
  481. });
  482. require('POST', {
  483. url: "/topic/detail",
  484. data: {
  485. depRange: "ALL",
  486. page,
  487. pageSize,
  488. title: searchObj.topic
  489. }
  490. }).then(data => {
  491. const li = (data.data || []).sort((a, b) => {
  492. return b.readTotal - a.readTotal
  493. });
  494. $(".summary1").html("");
  495. for (let i = 0; i < li.length; i++) {
  496. const v = li[i];
  497. let tr = $("<tr></tr>");
  498. tr.append($(`<td>${v.depName}</td><td>${v.name}</td><td>${v.platform}</td><td>${v.publishTime}</td>`));
  499. $(".summary1").append(tr)
  500. }
  501. removeLoading('test')
  502. if (paging) return
  503. paging = new Paging({
  504. total: data.total,
  505. pageChange(p) {
  506. console.log(p)
  507. page = p;
  508. getdetail()
  509. }
  510. })
  511. })
  512. }
  513. function init() {
  514. let h = $('.panel-body').width() * 9 / 16;
  515. $('.panel-body').height(h);
  516. $('.typeclick').click(function (e) {
  517. let t = $(e.target).text();
  518. if (t === '全部') type = "ALL";
  519. if (t === '周') type = "WEEK";
  520. if (t === '月') type = "MONTH";
  521. $('.btn-primary').removeClass("btn-primary");
  522. $('.' + type).addClass("btn-primary")
  523. getread();
  524. })
  525. $('.' + type).addClass("btn-primary")
  526. gethistory();
  527. getoverview();
  528. getread();
  529. getstart();
  530. getdetail();
  531. }
  532. init();
  533. </script>
  534. </html>