index.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. {extend name="common/base"/}
  2. {block name="style"}
  3. <style type="text/css">
  4. /* 这段样式只是用于演示 */
  5. .layui-card-header span {
  6. position: absolute;
  7. right: 10px;
  8. top: 10px;
  9. }
  10. .layui-sales {
  11. margin-bottom: 0;
  12. overflow: hidden;
  13. color: rgba(0,0,0,.85);
  14. font-size: 30px;
  15. }
  16. .layui-sales-info {
  17. padding-top: 16px;
  18. color: rgba(0,0,0,.65);
  19. white-space: nowrap;
  20. text-overflow: ellipsis;
  21. }
  22. fieldset.layui-field-title {
  23. margin-bottom: 10px;
  24. }
  25. </style>
  26. {/block}
  27. <!-- 主体 -->
  28. {block name="body"}
  29. <div class="p-3">
  30. <div class="layui-row layui-col-space15">
  31. <div class="layui-col-xs6 layui-col-md3">
  32. <div class="layui-card">
  33. <div class="layui-card-header">今日访问</div>
  34. <div class="layui-card-body">
  35. <div class="layui-sales">126,560</div>
  36. <div class="layui-sales-info" style="height: 125px;">
  37. 周同比 <span>12%</span>
  38. <i class="layui-edge layui-edge-top" style="border-bottom-color: green"></i>
  39. 日同比 <span>3%</span>
  40. <i class="layui-edge layui-edge-bottom" style="border-top-color: red"></i>
  41. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 66px;"></fieldset>
  42. <div>日访问量 1,234</div>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. <div class="layui-col-xs6 layui-col-md3">
  48. <div class="layui-card">
  49. <div class="layui-card-header">下载数量<span class="layui-badge layui-badge-blue pull-right">月</span></div>
  50. <div class="layui-card-body">
  51. <div class="layui-sales">6,560</div>
  52. <div class="layui-sales-info" >
  53. <div id="zfbs" style="height: 80px;"></div>
  54. <fieldset class="layui-elem-field layui-field-title"></fieldset>
  55. <div>总数 1,234</div>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <div class="layui-col-xs6 layui-col-md3">
  61. <div class="layui-card">
  62. <div class="layui-card-header">流量统计 <span class="layui-badge layui-badge-green pull-right">日</span></div>
  63. <div class="layui-card-body">
  64. <div class="layui-sales">6,560</div>
  65. <div class="layui-sales-info" >
  66. <div id="fwl" style="height: 80px;"></div>
  67. <fieldset class="layui-elem-field layui-field-title" ></fieldset>
  68. <div>日访问量 1,234</div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <div class="layui-col-xs6 layui-col-md3">
  74. <div class="layui-card">
  75. <div class="layui-card-header">转化率 <span class="layui-badge layui-badge-red pull-right">周</span></div>
  76. <div class="layui-card-body">
  77. <div class="layui-sales">83%</div>
  78. <div class="layui-sales-info" >
  79. <div style="height: 80px;">
  80. <div class="layui-progress layui-progress-big">
  81. <div class="layui-progress-bar layui-bg-blue" lay-percent="83%" style="width: 83%;"></div>
  82. </div>
  83. </div>
  84. <fieldset class="layui-elem-field layui-field-title" style="position: relative;"></fieldset>
  85. <div>转化数量 12,234</div>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. <div class="layui-col-xs6 layui-col-md9">
  91. <div class="layui-card">
  92. <div class="layui-card-header">地域分布</div>
  93. <div class="layui-card-body">
  94. <div id="map" style="height: 578px;"></div>
  95. </div>
  96. </div>
  97. </div>
  98. <div class="layui-col-xs6 layui-col-md3">
  99. <div class="layui-card" >
  100. <div class="layui-card-header">在线人数</div>
  101. <div class="layui-card-body">
  102. <div id="zxrs" style="height: 250px" ></div>
  103. </div>
  104. </div>
  105. </div>
  106. <div class="layui-col-xs6 layui-col-md3">
  107. <div class="layui-card" >
  108. <div class="layui-card-header">浏览器分布</div>
  109. <div class="layui-card-body">
  110. <div id="llq" style="height: 250px" ></div>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. {/block}
  117. <!-- /主体 -->
  118. <!-- 脚本 -->
  119. {block name="script"}
  120. <script src="https://cdn.staticfile.org/echarts/5.3.0/echarts.min.js"></script>
  121. <script src="{__GOUGU__}/third_party/echart/china.js"></script>
  122. <script>
  123. function init(layui) {
  124. var layer = layui.layer, table = layui.table;
  125. }
  126. // 访问量
  127. var fwlCharts = echarts.init(document.getElementById('fwl'));
  128. var fwlOptions = {
  129. tooltip: {
  130. trigger: 'axis',
  131. axisPointer: {
  132. type: 'cross',
  133. label: {
  134. backgroundColor: '#6a7985'
  135. }
  136. }
  137. },
  138. grid: {
  139. left: '-1%',
  140. right: '0',
  141. bottom: '0',
  142. top: '5px',
  143. containLabel: false
  144. },
  145. xAxis: [
  146. {
  147. type: 'category',
  148. boundaryGap: false,
  149. data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
  150. show: false
  151. }
  152. ],
  153. yAxis: [
  154. {
  155. type: 'value',
  156. show: false
  157. }
  158. ],
  159. series: [
  160. {
  161. name: '总量',
  162. type: 'line',
  163. stack: '总量',
  164. smooth: true,
  165. lineStyle: {
  166. width: 0
  167. },
  168. showSymbol: false,
  169. areaStyle: {
  170. opacity: 0.8,
  171. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  172. offset: 0,
  173. color: '#1890ff'
  174. }, {
  175. offset: 1,
  176. color: '#1890ff'
  177. }])
  178. },
  179. emphasis: {
  180. focus: 'series'
  181. },
  182. data: [120, 132, 156, 200, 90, 100, 165]
  183. },
  184. ]
  185. };
  186. fwlCharts.setOption(fwlOptions);
  187. // 渲染表信息
  188. var zfbsCharts = echarts.init(document.getElementById('zfbs'));
  189. var zfbsOptions = {
  190. color: ['#1890ff','#666'],
  191. tooltip: {},
  192. grid: {
  193. left: '0',
  194. right: '20',
  195. bottom: '30',
  196. containLabel: true
  197. },
  198. xAxis: {
  199. data: ['1月', '2月', '3月', '4月', '6月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
  200. show:false,
  201. },
  202. yAxis: {
  203. show:false
  204. },
  205. series: [{
  206. type: 'bar',
  207. data: [726, 1013, 690, 892, 982, 570, 536, 546, 988, 1002, 500, 506],
  208. barMaxWidth: 45
  209. }]
  210. }
  211. zfbsCharts.setOption(zfbsOptions);
  212. // 地图数据信息
  213. function randomValue() {
  214. return Math.round(Math.random()*1000);
  215. }
  216. var mapCharts = echarts.init(document.getElementById('map'));
  217. var dataList=[
  218. {name:"南海诸岛",value:0},
  219. {name: '北京', value: randomValue()},
  220. {name: '天津', value: randomValue()},
  221. {name: '上海', value: randomValue()},
  222. {name: '重庆', value: randomValue()},
  223. {name: '河北', value: randomValue()},
  224. {name: '河南', value: randomValue()},
  225. {name: '云南', value: randomValue()},
  226. {name: '辽宁', value: randomValue()},
  227. {name: '黑龙江', value: randomValue()},
  228. {name: '湖南', value: randomValue()},
  229. {name: '安徽', value: randomValue()},
  230. {name: '山东', value: randomValue()},
  231. {name: '新疆', value: randomValue()},
  232. {name: '江苏', value: randomValue()},
  233. {name: '浙江', value: randomValue()},
  234. {name: '江西', value: randomValue()},
  235. {name: '湖北', value: randomValue()},
  236. {name: '广西', value: randomValue()},
  237. {name: '甘肃', value: randomValue()},
  238. {name: '山西', value: randomValue()},
  239. {name: '内蒙古', value: randomValue()},
  240. {name: '陕西', value: randomValue()},
  241. {name: '吉林', value: randomValue()},
  242. {name: '福建', value: randomValue()},
  243. {name: '贵州', value: randomValue()},
  244. {name: '广东', value: randomValue()},
  245. {name: '青海', value: randomValue()},
  246. {name: '西藏', value: randomValue()},
  247. {name: '四川', value: randomValue()},
  248. {name: '宁夏', value: randomValue()},
  249. {name: '海南', value: randomValue()},
  250. {name: '台湾', value: randomValue()},
  251. {name: '香港', value: randomValue()},
  252. {name: '澳门', value: randomValue()}
  253. ]
  254. // 世界地图
  255. var mapOption = {
  256. tooltip: {
  257. formatter:function(params,ticket, callback){
  258. return params.seriesName+'<br />'+params.name+':'+params.value
  259. }
  260. },
  261. visualMap: {
  262. min: 0,
  263. max: 1500,
  264. left: 'left',
  265. top: 'bottom',
  266. text: ['高','低'],//取值范围的文字
  267. inRange: {
  268. color: ['#e0ffff', '#006edd']//取值范围的颜色
  269. },
  270. show: true//图注
  271. },
  272. geo: {
  273. map: 'china',
  274. roam: false, //不开启缩放和平移
  275. zoom:1.23, //视角缩放比例
  276. label: {
  277. normal: {
  278. show: true,
  279. fontSize:'10',
  280. color: 'rgba(0,0,0,0.7)'
  281. }
  282. },
  283. itemStyle: {
  284. normal:{
  285. borderColor: 'rgba(0, 0, 0, 0.2)'
  286. },
  287. emphasis:{
  288. areaColor: '#F3B329',//鼠标选择区域颜色
  289. shadowOffsetX: 0,
  290. shadowOffsetY: 0,
  291. shadowBlur: 20,
  292. borderWidth: 0,
  293. shadowColor: 'rgba(0, 0, 0, 0.5)'
  294. }
  295. }
  296. },
  297. series : [
  298. {
  299. name: '信息量',
  300. type: 'map',
  301. geoIndex: 0,
  302. data:dataList
  303. }
  304. ]
  305. };
  306. mapCharts.setOption(mapOption);
  307. var myCharts = echarts.init(document.getElementById('zxrs'));
  308. var mData = [50, 100, 150, 80, 120, 150, 200, 250, 220, 250, 300, 350, 400, 380, 440, 450, 500, 550, 500];
  309. var option = {
  310. tooltip: {
  311. trigger: "axis"
  312. },
  313. xAxis: [{
  314. type: "category",
  315. boundaryGap: !1,
  316. data: ["06:00", "06:30", "07:00", "07:30", "08:00", "08:30", "09:00", "09:30", "10:00", "11:30", "12:00", "12:30", "13:00", "13:30", "14:00", "14:30", "15:00", "15:30", "16:00"]
  317. }],
  318. yAxis: [{
  319. type: "value"
  320. }],
  321. series: [{
  322. name: "总量",
  323. type: "line",
  324. smooth: !0,
  325. itemStyle: {
  326. normal: {
  327. areaStyle: {
  328. type: "default"
  329. }
  330. }
  331. },
  332. data: mData
  333. }]
  334. };
  335. myCharts.setOption(option);
  336. // 动态改变图表1数据
  337. setInterval(function () {
  338. for (var i = 0; i < mData.length; i++) {
  339. mData[i] += (Math.random() * 50 - 25);
  340. if (mData[i] < 0) {
  341. mData[i] = 0;
  342. }
  343. }
  344. myCharts.setOption({
  345. series: [{
  346. data: mData
  347. }]
  348. });
  349. }, 1000);
  350. // 渲染浏览器分布
  351. var llqCharts = echarts.init(document.getElementById('llq'));
  352. var llqOptions = {
  353. tooltip: {
  354. trigger: 'item'
  355. },
  356. legend: {
  357. bottom: '1%',
  358. left: 'center',
  359. icon: 'circle', // 设置小圆点
  360. itemWidth: 10, // 设置宽度
  361. itemHeight: 10, // 设置高度
  362. },
  363. series: [
  364. {
  365. name: '浏览器分布',
  366. type: 'pie',
  367. radius: ['40%', '70%'],
  368. avoidLabelOverlap: false,
  369. label: {
  370. show: false,
  371. position: 'center'
  372. },
  373. emphasis: {
  374. label: {
  375. show: true,
  376. fontSize: '14px',
  377. }
  378. },
  379. labelLine: {
  380. show: false
  381. },
  382. data: [
  383. {value: 1048, name: 'Chrome'},
  384. {value: 735, name: 'Safair'},
  385. {value: 580, name: 'Firefox'},
  386. {value: 484, name: 'Edge'},
  387. {value: 300, name: 'IE'},
  388. {value: 200, name: 'Other'},
  389. ]
  390. }
  391. ]
  392. };
  393. llqCharts.setOption(llqOptions);
  394. // 窗口大小改变事件
  395. window.onresize = function () {
  396. myCharts.resize();
  397. mapCharts.resize();
  398. fwlCharts.resize();
  399. zfbsCharts.resize();
  400. llqCharts.resize();
  401. };
  402. //页面停留时长统计
  403. let stopTime;
  404. window.onpageshow = ()=>{
  405. stopTime = new Date().getTime();
  406. }
  407. window.onpagehide = ()=>{
  408. stopTime = new Date().getTime() - stopTime;
  409. let record = localStorage.getItem('data');
  410. console.log(record);
  411. let data = record && JSON.parse(record) || [];
  412. localStorage.setItem('data',JSON.stringify([...data,{user:new Date().getTime(),path:window.location.href,stopTime}]));
  413. }
  414. </script>
  415. {/block}
  416. <!-- /脚本 -->