index.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. {extend name="base"/}
  2. {block name="resources"}
  3. <style>
  4. .body-content {
  5. background: none !important;
  6. padding: 0 !important;
  7. margin: 0 !important;
  8. }
  9. .common-wrap {
  10. background: #fff;
  11. padding: 15px;
  12. margin: 15px 15px 0 15px;
  13. }
  14. .common-wrap .head {
  15. display: flex;
  16. align-items: center
  17. }
  18. .common-wrap .head .title {
  19. font-size: 16px;
  20. font-weight: bolder
  21. }
  22. .common-wrap .head .sub-title {
  23. margin-left: 10px;
  24. color: #999
  25. }
  26. .common-wrap .body {
  27. margin-top: 15px;
  28. }
  29. .summary-wrap {
  30. display: flex;
  31. flex-wrap: wrap;
  32. }
  33. .summary-wrap .summary-item {
  34. padding: 0 15px;
  35. box-sizing: border-box;
  36. flex: 1;
  37. }
  38. .summary-wrap .summary-item .title, .summary-wrap .summary-item .bottom-title {
  39. color: #909399;
  40. font-size: 14px;
  41. margin-top: 5px;
  42. }
  43. .summary-wrap .summary-item .value {
  44. color: #303133;
  45. font-size: 26px;
  46. margin-top: 10px;
  47. }
  48. .summary-wrap .last {
  49. width: 240px;
  50. flex: none;
  51. padding-left: 80px !important;
  52. border-left: 1px solid #eee;
  53. }
  54. .trend-wrap, .constitute-wrap, .distribution {
  55. display: flex;
  56. }
  57. .trend-wrap .common-wrap, .constitute-wrap .common-wrap, .distribution .wrap {
  58. flex: 1;
  59. }
  60. .trend-wrap .common-wrap:first-child, .constitute-wrap .common-wrap:first-child{
  61. margin-right: 0;
  62. }
  63. .distribution .wrap:first-child {
  64. margin-right: 15px;
  65. display: flex;
  66. justify-content: center;
  67. }
  68. </style>
  69. {/block}
  70. {block name="main"}
  71. <div class="common-wrap">
  72. <div class="head">
  73. <div class="title">实时概况</div>
  74. <div class="sub-title">更新时间:{:date('Y-m-d H:i:s')}</div>
  75. </div>
  76. <div class="body summary-wrap">
  77. <div class="summary-item">
  78. <div class="title">今日新增会员数</div>
  79. <div class="value">{$today.member_count}</div>
  80. <div class="bottom-title">昨日:<span>{$yesterday.member_count}</span></div>
  81. </div>
  82. <div class="summary-item">
  83. <div class="title">今日下单会员数</div>
  84. <div class="value">{$today.order_member_count}</div>
  85. <div class="bottom-title">昨日:<span>{$yesterday.order_member_count}</span></div>
  86. </div>
  87. <div class="summary-item">
  88. <div class="title">今日储值会员数</div>
  89. <div class="value">{$today.member_recharge_member_count}</div>
  90. <div class="bottom-title">昨日:<span>{$yesterday.member_recharge_member_count}</span></div>
  91. </div>
  92. <div class="summary-item">
  93. <div class="title">今日领券会员数</div>
  94. <div class="value">{$today.coupon_member_count}</div>
  95. <div class="bottom-title">昨日:<span>{$yesterday.coupon_member_count}</span></div>
  96. </div>
  97. <div class="summary-item last">
  98. <div class="title">下单会员数</div>
  99. <div class="value" id="pay_member_num">{$data.buyed_count}</div>
  100. <div class="bottom-title">未下单会员数:<span>{$data.total_count - $data.buyed_count}</span></div>
  101. </div>
  102. <div class="echart">
  103. <div id="main" style="width: 230px; height: 90px;"></div>
  104. </div>
  105. </div>
  106. </div>
  107. <div class="trend-wrap">
  108. <div class="common-wrap">
  109. <div class="head">
  110. <div class="title">新增会员数</div>
  111. </div>
  112. <div class="body">
  113. <div id="newAdd" style="width: 100%; height: 300px;"></div>
  114. </div>
  115. </div>
  116. <div class="common-wrap">
  117. <div class="head">
  118. <div class="title">消费会员数</div>
  119. </div>
  120. <div class="body">
  121. <div id="consume" style="width: 100%; height: 300px;"></div>
  122. </div>
  123. </div>
  124. </div>
  125. <div class="constitute-wrap">
  126. <div class="common-wrap">
  127. <div class="head">
  128. <div class="title">会员注册渠道比率</div>
  129. </div>
  130. <div class="body">
  131. <div id="channel" style="width: 100%; height: 200px;"></div>
  132. </div>
  133. </div>
  134. <div class="common-wrap">
  135. <div class="head">
  136. <div class="title">会员等级比率</div>
  137. </div>
  138. <div class="body">
  139. <div id="level" style="width: 100%; height: 200px;"></div>
  140. </div>
  141. </div>
  142. </div>
  143. <div class="common-wrap">
  144. <div class="head">
  145. <div class="title">会员分布</div>
  146. </div>
  147. <div class="body distribution">
  148. <div class="wrap">
  149. <div id="china_echart" style="width: 80%;height: 600px"></div>
  150. </div>
  151. <div class="wrap">
  152. <table id="member_list" lay-filter="member_list" class="layui-table"></table>
  153. </div>
  154. </div>
  155. </div>
  156. {/block}
  157. {block name="script"}
  158. <script src="SHOP_JS/echarts.min.js"></script>
  159. <script src="SHOP_JS/china.js"></script>
  160. <script>
  161. var baseColor = getComputedStyle(document.documentElement).getPropertyValue('--base-color');
  162. layui.use('form', function () {
  163. var table, form = layui.form;
  164. form.render();
  165. table = new Table({
  166. elem: '#member_list',
  167. url: ns.url("shop/member/areaCount"),
  168. where: {
  169. handle: true
  170. },
  171. parseData: function (res) { //res 即为原始返回的数据
  172. return {
  173. "code": res.code, //解析接口状态
  174. "msg": res.message, //解析提示文本
  175. "count": res.data.list.length, //解析数据长度
  176. "data": res.data.list //解析数据列表
  177. };
  178. },
  179. page: false,
  180. cols: [
  181. [
  182. {
  183. field: 'LAY_INDEX',
  184. title: '排名',
  185. unresize: 'false',
  186. width: '20%',
  187. templet: function (data) {
  188. return data.LAY_INDEX;
  189. }
  190. }, {
  191. field: 'name',
  192. title: '地区',
  193. unresize: 'false',
  194. width: '30%'
  195. }, {
  196. field: 'value',
  197. title: '会员数',
  198. unresize: 'false',
  199. width: '25%'
  200. }, {
  201. field: 'ratio',
  202. title: '会员占比',
  203. unresize: 'false',
  204. width: '25%',
  205. templet: function (data) {
  206. return data.ratio + '%';
  207. }
  208. }
  209. ]
  210. ]
  211. });
  212. });
  213. // 基于准备好的dom,初始化echarts实例
  214. var myChart = echarts.init(document.getElementById('main'));
  215. // 指定图表的配置项和数据
  216. option = {
  217. tooltip: {
  218. trigger: 'item',
  219. formatter: '{a} <br/>{b}: {c} ({d}%)'
  220. },
  221. legend: {
  222. orient: 'vertical',
  223. right: 0,
  224. top: 0,
  225. data: ['下单会员数', '未下单会员数']
  226. },
  227. color: ['#2FCE63', '#F5CC4E'],
  228. series: [{
  229. width: 100,
  230. height: 100,
  231. top: -5,
  232. left: 0,
  233. name: '',
  234. type: 'pie',
  235. radius: ['50%', '70%'],
  236. avoidLabelOverlap: false,
  237. label: {
  238. show: false,
  239. position: 'center'
  240. },
  241. emphasis: {
  242. label: {
  243. show: true,
  244. fontSize: '12',
  245. color: baseColor
  246. }
  247. },
  248. labelLine: {
  249. show: false
  250. },
  251. data: [
  252. {
  253. value: {$data.buyed_count},
  254. name: '下单会员数',
  255. tooltip: {
  256. trigger: 'item',
  257. backgroundColor: 'rgba(255, 255, 255, 0.7)',
  258. borderColor: '#999',
  259. borderWidth: 1,
  260. padding: 10,
  261. textStyle: {
  262. fontSize: 12,
  263. color: '#333'
  264. }
  265. }
  266. },
  267. {
  268. value: {$data.total_count - $data.buyed_count},
  269. name: '未下单会员数',
  270. tooltip: {
  271. trigger: 'item',
  272. backgroundColor: 'rgba(255, 255, 255, 0.7)',
  273. borderColor: '#999',
  274. borderWidth: 1,
  275. padding: 10,
  276. textStyle: {
  277. color: '#333',
  278. fontSize: 12
  279. }
  280. }
  281. }
  282. ]
  283. }]
  284. };
  285. // 使用刚指定的配置项和数据显示图表。
  286. myChart.setOption(option);
  287. var china_echart = echarts.init(document.getElementById('china_echart'));
  288. var china_option = {
  289. tooltip: {
  290. formatter: function (params, ticket, callback) {
  291. return params.seriesName + '<br />' + params.name + ':' + params.value
  292. }
  293. },
  294. visualMap: {
  295. min: 0,
  296. max: 1500,
  297. left: 'left',
  298. top: 'bottom',
  299. text: ['高', '低'],
  300. inRange: {
  301. color: ['#FFF', '#ff8143']
  302. },
  303. show: false
  304. },
  305. geo: {
  306. map: 'china',
  307. roam: false,
  308. zoom: 1.23,
  309. label: {
  310. normal: {
  311. show: true,
  312. fontSize: '10',
  313. color: 'rgba(0,0,0,0.7)'
  314. }
  315. },
  316. itemStyle: {
  317. normal: {
  318. borderColor: 'rgba(0, 0, 0, 0.2)'
  319. },
  320. emphasis: {
  321. areaColor: '#e0ffff',
  322. shadowOffsetX: 0,
  323. shadowOffsetY: 0,
  324. shadowBlur: 20,
  325. borderWidth: 0,
  326. shadowColor: 'rgba(0, 0, 0, 0.5)'
  327. }
  328. }
  329. },
  330. series: [{
  331. name: '会员数',
  332. type: 'map',
  333. geoIndex: 0,
  334. data: [{"name": "北京", "value": 0}, {"name": "天津", "value": 0}, {"name": "河北", "value": 0}, {
  335. "name": "山西",
  336. "value": 0
  337. }, {"name": "内蒙古", "value": 0}, {"name": "辽宁", "value": 0}, {"name": "吉林", "value": 0}, {
  338. "name": "黑龙江",
  339. "value": 0
  340. }, {"name": "上海", "value": 0}, {"name": "江苏", "value": 0}, {"name": "浙江", "value": 0}, {
  341. "name": "安徽",
  342. "value": 0
  343. }, {"name": "福建", "value": 0}, {"name": "江西", "value": 0}, {"name": "山东", "value": 0}, {
  344. "name": "河南",
  345. "value": 0
  346. }, {"name": "湖北", "value": 0}, {"name": "湖南", "value": 0}, {"name": "广东", "value": 0}, {
  347. "name": "广西",
  348. "value": 0
  349. }, {"name": "海南", "value": 0}, {"name": "重庆", "value": 0}, {"name": "四川", "value": 0}, {
  350. "name": "贵州",
  351. "value": 0
  352. }, {"name": "云南", "value": 0}, {"name": "西藏", "value": 0}, {"name": "陕西", "value": 0}, {
  353. "name": "甘肃",
  354. "value": 0
  355. }, {"name": "青海", "value": 0}, {"name": "宁夏", "value": 0}, {"name": "新疆", "value": 0}, {
  356. "name": "香港",
  357. "value": 0
  358. }, {"name": "澳门", "value": 0}, {"name": "台湾", "value": 0}]
  359. }]
  360. };
  361. china_echart.setOption(china_option);
  362. function areaCount() {
  363. $.ajax({
  364. url: ns.url("shop/member/areaCount"),
  365. dataType: 'JSON',
  366. type: 'POST',
  367. success: function (res) {
  368. if (res.data.list.length > 0) {
  369. china_option.series[0].data = res.data.list;
  370. }
  371. china_echart.setOption(china_option);
  372. }
  373. })
  374. }
  375. areaCount();
  376. /**
  377. * 获取会员七日趋势数据
  378. */
  379. function getMemberStatData() {
  380. $.ajax({
  381. dataType: 'JSON',
  382. type: 'POST',
  383. url: ns.url("shop/stat/getStatData"),
  384. success: function(res) {
  385. // 基于准备好的dom,初始化echarts实例
  386. var newAddChart = echarts.init(document.getElementById('newAdd'));
  387. var consumeChart = echarts.init(document.getElementById('consume'));
  388. // 指定图表的配置项和数据
  389. var option = {
  390. xAxis: {
  391. type: 'category',
  392. data: []
  393. },
  394. yAxis: {
  395. type: 'value'
  396. },
  397. grid: {
  398. top: '8%',
  399. bottom: '9%',
  400. left: '8%',
  401. right: '4%'
  402. },
  403. tooltip: {
  404. trigger: 'axis',
  405. showContent: true,
  406. backgroundColor: 'rgba(0, 0, 0, 0.5)',
  407. padding: [5, 10],
  408. textStyle: {
  409. color: '#fff',
  410. lineHeight: 30,
  411. },
  412. formatter: function(params, ticket, callback) {
  413. return "日期:" + params[0].axisValue + '<br />' + params[0].seriesName + ":" + params[0].value + "人";
  414. },
  415. },
  416. series: [{
  417. name: [''],
  418. data: [],
  419. type: 'line',
  420. smooth: true,
  421. itemStyle: {
  422. color: baseColor
  423. },
  424. areaStyle: {
  425. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  426. offset: 0,
  427. color: baseColor
  428. }, {
  429. offset: 1,
  430. color: '#fff'
  431. }])
  432. }
  433. }]
  434. };
  435. option.xAxis.data = res.time;
  436. option.series[0].name = '新增会员数';
  437. option.series[0].data = res.member_count;
  438. newAddChart.setOption(option);
  439. option.series[0].name = '消费会员数';
  440. option.series[0].data = res.order_member_count;
  441. consumeChart.setOption(option);
  442. }
  443. });
  444. }
  445. getMemberStatData();
  446. function getMemberLevelRatio() {
  447. $.ajax({
  448. dataType: 'JSON',
  449. type: 'POST',
  450. url: ns.url("shop/memberlevel/levellist"),
  451. data: {
  452. page_size: 0,
  453. },
  454. success: function(res) {
  455. var level = res.data.list;
  456. var echart = echarts.init(document.getElementById('level'));
  457. // 指定图表的配置项和数据
  458. var option = {
  459. tooltip: {
  460. trigger: 'item',
  461. formatter: '{a} <br/>{b}: {c} ({d}%)'
  462. },
  463. legend: {
  464. orient: 'vertical',
  465. left: '55%',
  466. top: '10%',
  467. align: 'auto',
  468. data: level.map(function (item) {
  469. return {
  470. name: item.level_name,
  471. icon: 'circle',
  472. }
  473. })
  474. },
  475. color: level.map(function (item) {
  476. return getRandomColor();
  477. }),
  478. series: [{
  479. width: 180,
  480. height: 180,
  481. top: 10,
  482. left: '10%',
  483. name: '',
  484. type: 'pie',
  485. radius: ['50%', '70%'],
  486. avoidLabelOverlap: false,
  487. label: {
  488. show: false,
  489. position: 'center'
  490. },
  491. emphasis: {
  492. label: {
  493. show: true,
  494. fontSize: '12',
  495. color: baseColor
  496. }
  497. },
  498. labelLine: {
  499. show: false
  500. },
  501. data: level.map(function (item) {
  502. return {
  503. value: item.member_num,
  504. name: item.level_name,
  505. tooltip: {
  506. trigger: 'item',
  507. backgroundColor: 'rgba(255, 255, 255, 0.7)',
  508. borderColor: '#999',
  509. borderWidth: 1,
  510. padding: 10,
  511. textStyle: {
  512. fontSize: 12,
  513. color: '#333'
  514. }
  515. }
  516. }
  517. })
  518. }]
  519. };
  520. // 使用刚指定的配置项和数据显示图表。
  521. echart.setOption(option);
  522. }
  523. })
  524. }
  525. getMemberLevelRatio();
  526. function getMemberChannelRatio() {
  527. $.ajax({
  528. dataType: 'JSON',
  529. type: 'POST',
  530. url: ns.url("shop/member/getRegisterChannelMemberNum"),
  531. success: function(res) {
  532. var level = res.data;
  533. var echart = echarts.init(document.getElementById('channel'));
  534. // 指定图表的配置项和数据
  535. var option = {
  536. tooltip: {
  537. trigger: 'item',
  538. formatter: '{a} <br/>{b}: {c} ({d}%)'
  539. },
  540. legend: {
  541. orient: 'vertical',
  542. left: '55%',
  543. top: '20%',
  544. data: level.map(function (item) {
  545. return {
  546. name: item.name,
  547. icon: 'circle',
  548. }
  549. })
  550. },
  551. color: level.map(function (item) {
  552. return getRandomColor();
  553. }),
  554. series: [{
  555. width: 180,
  556. height: 180,
  557. top: 10,
  558. left: '10%',
  559. name: '',
  560. type: 'pie',
  561. radius: ['50%', '70%'],
  562. avoidLabelOverlap: false,
  563. label: {
  564. show: false,
  565. position: 'center'
  566. },
  567. emphasis: {
  568. label: {
  569. show: true,
  570. fontSize: '12',
  571. color: baseColor
  572. }
  573. },
  574. labelLine: {
  575. show: false
  576. },
  577. data: level.map(function (item) {
  578. return {
  579. value: item.member_num,
  580. name: item.name,
  581. tooltip: {
  582. trigger: 'item',
  583. backgroundColor: 'rgba(255, 255, 255, 0.7)',
  584. borderColor: '#999',
  585. borderWidth: 1,
  586. padding: 10,
  587. textStyle: {
  588. fontSize: 12,
  589. color: '#333'
  590. }
  591. }
  592. }
  593. })
  594. }]
  595. };
  596. // 使用刚指定的配置项和数据显示图表。
  597. echart.setOption(option);
  598. }
  599. })
  600. }
  601. getMemberChannelRatio();
  602. /**
  603. * 随机生成颜色
  604. * @returns {string}
  605. */
  606. function getRandomColor(){
  607. return '#' + (function(color){
  608. return (color += '0123456789abcdef'[Math.floor(Math.random()*16)])
  609. && (color.length == 6) ? color : arguments.callee(color);
  610. })('');
  611. }
  612. </script>
  613. {/block}