complain.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>用户统计</title>
  8. <link rel="stylesheet" href="/static/antv/f2.style.css" />
  9. <script type="text/javascript" src="/static/jquery-2.2.4.min.js"></script>
  10. <script src="/static/antv/f2.min.js"></script>
  11. <link rel="stylesheet" href="/static/h5/css/common.css">
  12. <style>
  13. html,body {
  14. margin: 0;
  15. padding: 0;
  16. overflow-y: scroll;
  17. -webkit-overflow-scrolling: touch;
  18. background: #f1f1f1;
  19. }
  20. .chart-wrapper {
  21. margin: 10px;
  22. border-radius: 10px;
  23. }
  24. ul {
  25. margin: 0;
  26. padding: 0;
  27. }
  28. .nav-tabs>li>a {
  29. margin-right: 0;
  30. border-radius: 0;
  31. }
  32. a {
  33. text-align: center;
  34. font-size: 16px;
  35. font-weight:bold;
  36. color: #999;
  37. text-decoration: none;
  38. }
  39. .daily-record {
  40. margin: 0 10px;
  41. background-color: #fff;
  42. border-radius: 10px;
  43. }
  44. .record-data {
  45. display: flex;
  46. display: -webkit-flex;
  47. justify-content: space-between;
  48. align-items: center;
  49. height: 7vh;
  50. }
  51. .line {
  52. margin: 0 15px;
  53. height: 1px;
  54. background-color: #CCCCCC;
  55. }
  56. .daily-title, .daily-nums {
  57. display: inline;
  58. font-size: 17px;
  59. font-weight: 500;
  60. }
  61. .daily-title {
  62. margin-left: 25px;
  63. display: flex;
  64. display: -webkit-flex;
  65. align-items: center;
  66. }
  67. .daily-nums {
  68. margin-right: 25px;
  69. color:rgba(153,153,153,1);
  70. }
  71. .select-tab {
  72. margin: 10px 10px 0;
  73. border-radius: 10px;
  74. background: #fff;
  75. }
  76. .nav {
  77. display: flex;
  78. display: -webkit-flex;
  79. justify-content: center;
  80. -webkit-justify-content: center;
  81. align-items: center;
  82. border:1px solid var(--themeColor);
  83. border-radius:5px;
  84. list-style: none;
  85. }
  86. .nav>li {
  87. width: 100%;
  88. flex: 1;
  89. text-align: center;
  90. display: block;
  91. }
  92. .nav-tabs>li.active>a {
  93. line-height: 2;
  94. font-size: 16px;
  95. color: #fff;
  96. font-weight: 500;
  97. cursor: default;
  98. background-color: var(--themeColor);
  99. }
  100. .nav-tabs>li>a {
  101. line-height: 2;
  102. font-size: 16px;
  103. color: #999999;
  104. font-weight: 500;
  105. }
  106. a {
  107. display: block;
  108. text-decoration: none;
  109. }
  110. </style>
  111. </head>
  112. <body>
  113. <div class="select-tab">
  114. <ul class="nav nav-tabs">
  115. <li {eq name="type" value="0"}class="active"{/eq}>
  116. <a href="{:url('complain',['type'=>0,'orgId'=>$orgId])}">周统计</a>
  117. </li>
  118. <li {eq name="type" value="1"}class="active"{/eq}>
  119. <a href="{:url('complain',['type'=>1,'orgId'=>$orgId])}">月统计</a>
  120. </li>
  121. <li {eq name="type" value="2"}class="active"{/eq}>
  122. <a href="{:url('complain',['type'=>2,'orgId'=>$orgId])}">总统计</a>
  123. </li>
  124. </ul>
  125. </div>
  126. <div class="chart-wrapper">
  127. <canvas id="mountNode" style="width: 100%;"></canvas>
  128. </div>
  129. <div class="daily-record">
  130. <div class="record-data first" onclick="complainList(this)" data-orgId="{$orgId}" data-status="-1" data-type="{$type}" >
  131. <span class="daily-title">历史总投诉数</span>
  132. <span class="daily-nums">{$count}</span>
  133. </div>
  134. {foreach $list as $k=>$v}
  135. <div class="line"></div>
  136. <div class="record-data" onclick="complainList(this)" data-orgId="{$orgId}" data-status="{$v['status']}" data-type="{$type}">
  137. <span class="daily-title"><span style="display: inline-block;margin-right:10px;width: 6px;height: 6px;border-radius:5px;"></span>{$v['name']}</span>
  138. <span class="daily-nums">{$v['cost']}</span>
  139. </div>
  140. {/foreach}
  141. </div>
  142. <script>
  143. var Util = F2.Util;
  144. var G = F2.G;
  145. var Group = G.Group;
  146. function drawLabel(shape, coord, canvas) {
  147. var center = coord.center;
  148. var origin = shape.get('origin');
  149. var points = origin.points;
  150. var x1 = (points[2].x - points[1].x) * 0.75 + points[1].x;
  151. var x2 = (points[2].x - points[1].x) * 1.8 + points[1].x;
  152. var y = (points[0].y + points[1].y) / 2;
  153. var point1 = coord.convertPoint({
  154. x: x1,
  155. y: y
  156. });
  157. var point2 = coord.convertPoint({
  158. x: x2,
  159. y: y
  160. });
  161. var group = new Group();
  162. group.addShape('Line', {
  163. attrs: {
  164. x1: point1.x,
  165. y1: point1.y,
  166. x2: point2.x,
  167. y2: point2.y,
  168. lineDash: [0, 2, 2],
  169. stroke: '#808080'
  170. }
  171. });
  172. var text = group.addShape('Text', {
  173. attrs: {
  174. x: point2.x,
  175. y: point2.y,
  176. text: origin._origin.type + ' ' + origin._origin.cost,
  177. fill: '#808080',
  178. textAlign: 'start',
  179. textBaseline: 'bottom'
  180. }
  181. });
  182. var textWidth = text.getBBox().width;
  183. var baseLine = group.addShape('Line', {
  184. attrs: {
  185. x1: point2.x,
  186. y1: point2.y,
  187. x2: point2.x,
  188. y2: point2.y,
  189. stroke: '#808080'
  190. }
  191. });
  192. if (point2.x > center.x) {
  193. baseLine.attr('x2', point2.x + textWidth);
  194. } else if (point2.x < center.x) {
  195. text.attr('textAlign', 'end');
  196. baseLine.attr('x2', point2.x - textWidth);
  197. } else {
  198. text.attr('textAlign', 'center');
  199. text.attr('textBaseline', 'top');
  200. }
  201. canvas.add(group);
  202. shape.label = group;
  203. }
  204. var data = {:json_encode($list)};
  205. var sum = 0;
  206. data.map(function(obj) {
  207. sum += obj.cost;
  208. });
  209. var chart = new F2.Chart({
  210. id: 'mountNode',
  211. pixelRatio: window.devicePixelRatio
  212. });
  213. chart.source(data);
  214. var lastClickedShape;
  215. chart.legend({
  216. position: 'bottom',
  217. offsetY: -5,
  218. marker: 'circle',
  219. align: 'center',
  220. onClick: function onClick(ev) {
  221. var clickedItem = ev.clickedItem;
  222. var dataValue = clickedItem.get('dataValue');
  223. var canvas = chart.get('canvas');
  224. var coord = chart.get('coord');
  225. var geom = chart.get('geoms')[0];
  226. var container = geom.get('container');
  227. var shapes = geom.get('shapes'); // 只有带精细动画的 geom 才有 shapes 这个属性
  228. var clickedShape;
  229. // 找到被点击的 shape
  230. Util.each(shapes, function(shape) {
  231. var origin = shape.get('origin');
  232. if (origin && origin._origin.type === dataValue) {
  233. clickedShape = shape;
  234. return false;
  235. }
  236. });
  237. if (lastClickedShape) {
  238. lastClickedShape.animate().to({
  239. attrs: {
  240. lineWidth: 0
  241. },
  242. duration: 200
  243. }).onStart(function() {
  244. if (lastClickedShape.label) {
  245. lastClickedShape.label.hide();
  246. }
  247. }).onEnd(function() {
  248. lastClickedShape.set('selected', false);
  249. });
  250. }
  251. if (clickedShape.get('selected')) {
  252. clickedShape.animate().to({
  253. attrs: {
  254. lineWidth: 0
  255. },
  256. duration: 200
  257. }).onStart(function() {
  258. if (clickedShape.label) {
  259. clickedShape.label.hide();
  260. }
  261. }).onEnd(function() {
  262. clickedShape.set('selected', false);
  263. });
  264. } else {
  265. var color = clickedShape.attr('fill');
  266. clickedShape.animate().to({
  267. attrs: {
  268. lineWidth: 5
  269. },
  270. duration: 350,
  271. easing: 'bounceOut'
  272. }).onStart(function() {
  273. clickedShape.attr('stroke', color);
  274. clickedShape.set('zIndex', 1);
  275. container.sort();
  276. }).onEnd(function() {
  277. clickedShape.set('selected', true);
  278. clickedShape.set('zIndex', 0);
  279. container.sort();
  280. lastClickedShape = clickedShape;
  281. if (clickedShape.label) {
  282. clickedShape.label.show();
  283. } else {
  284. drawLabel(clickedShape, coord, canvas);
  285. }
  286. canvas.draw();
  287. });
  288. }
  289. }
  290. });
  291. chart.coord('polar', {
  292. transposed: true,
  293. innerRadius: 0.8,
  294. radius: 1
  295. });
  296. chart.axis(false);
  297. chart.tooltip(false);
  298. chart.interval().position('a*cost').color('name', ['#F7B762','#1EC498','#775cff']).adjust('stack');
  299. chart.guide().html({
  300. position: ['50%', '50%'],
  301. html: '<div style="width: 250px;height: 40px;text-align: center;">' + '<div style="font-size: 24px;color:#089875;">{$count}</div>' + '<div style="font-size: 16px;color:#089875;">投诉总数</div>' + '</div>'
  302. });
  303. chart.render();
  304. </script>
  305. </body>
  306. </html>
  307. <script>
  308. function complainList(obj) {
  309. var type = $(obj).attr('data-type');
  310. var orgId = $(obj).attr('data-orgId');
  311. var status = $(obj).attr('data-status');
  312. var url = "{:url('Statistics/complainList')}?type="+type+'&orgId='+orgId+'&status='+status;
  313. window.location.href=url;
  314. }
  315. </script>