index.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. {extend name="base"/}
  2. {block name="resources"}
  3. <style>
  4. .ns-table-tuwen-box .ns-font-box {
  5. overflow: inherit;
  6. }
  7. .ns-card-head-right {
  8. display: flex;
  9. align-items: center;
  10. }
  11. .ns-card-head-right .layui-form-item {
  12. margin-bottom: 0;
  13. }
  14. .current-time, .ns-flow-time-today {
  15. margin-left: 10px;
  16. line-height: 34px;
  17. }
  18. /* 基本信息 */
  19. .ns-basic {
  20. display: flex;
  21. }
  22. .ns-basic .ns-table-tuwen-box {
  23. width: 25%;
  24. border-right: 1px solid #EEEEEE;
  25. padding: 10px 20px;
  26. }
  27. .ns-basic-count {
  28. font-size: 20px;
  29. font-weight: 600;
  30. }
  31. </style>
  32. {/block}
  33. {block name="main"}
  34. <div class="layui-card ns-card-common ns-card-brief">
  35. <div class="layui-card-header">
  36. <span class="ns-card-title">实时概况</span>
  37. <div class="ns-card-head-right layui-form">
  38. <div class="layui-form-item">
  39. <div class="layui-input-block ns-len-mid">
  40. <select name="date" lay-filter="date">
  41. <option value="0">今日实时</option>
  42. <option value="1">近7天</option>
  43. <option value="2">近30天</option>
  44. </select>
  45. </div>
  46. </div>
  47. <div class="ns-flow-time">
  48. <div class="ns-flow-time-today"></div>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="layui-card-body ns-basic">
  53. <div class="ns-table-tuwen-box">
  54. <div class="ns-img-box">
  55. <img src="ADMIN_IMG/stat/order_money.png">
  56. </div>
  57. <div class="ns-font-box">
  58. <div class="ns-text-color-dark-gray ns-prompt-block">
  59. 订单金额&nbsp;&nbsp;
  60. <div class="ns-prompt">
  61. <i class="iconfont iconwenhao1"></i>
  62. <div class="ns-prompt-box">
  63. <div class="ns-prompt-con">
  64. 商城已付款的订单总金额
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. <p class="ns-basic-count" id="orderTotal">0</p>
  70. </div>
  71. </div>
  72. <div class="ns-table-tuwen-box">
  73. <div class="ns-img-box">
  74. <img src="ADMIN_IMG/stat/order_num.png">
  75. </div>
  76. <div class="ns-font-box">
  77. <p class="ns-text-color-dark-gray">订单数</p>
  78. <p class="ns-basic-count" id="orderPayCount">0</p>
  79. </div>
  80. </div>
  81. <div class="ns-table-tuwen-box">
  82. </div>
  83. </div>
  84. </div>
  85. {/block}
  86. {block name="script"}
  87. <script src="SHOP_JS/echarts.min.js"></script>
  88. <script>
  89. $(function() {
  90. getStat(0);
  91. getStatChart(1);
  92. });
  93. layui.use(['form'], function() {
  94. var form = layui.form;
  95. /**
  96. * 监听下拉框
  97. */
  98. form.on('select(date)', function(data) {
  99. getStat(data.value);
  100. });
  101. /**
  102. * 图表监听下拉框
  103. */
  104. form.on('select(date_chart)', function(data) {
  105. getStatChart(data.value);
  106. });
  107. });
  108. //获取店铺统计
  109. function getStat(date_type){
  110. $.ajax({
  111. dataType: 'JSON',
  112. type: 'POST',
  113. url: ns.url("admin/stat/index"),
  114. data: {
  115. date_type: date_type
  116. },
  117. success: function(res){
  118. console.log(res);
  119. if (res.code == 0) {
  120. $("#orderTotal").html(res.data.sum);
  121. $("#orderPayCount").html(res.data.count);
  122. $(".ns-flow-time-today").html(res.data.time_range);
  123. }else{
  124. layer.msg(res.message);
  125. }
  126. }
  127. });
  128. }
  129. //获取店铺统计图表
  130. function getStatChart(date_type){
  131. $.ajax({
  132. dataType: 'JSON',
  133. type: 'POST',
  134. url: ns.url("admin/stat/getstatlist"),
  135. data: {
  136. date_type: date_type
  137. },
  138. success: function(res){
  139. console.log(res);
  140. option.xAxis.data = res.time;
  141. option.series[0].data = res.visit_count;
  142. option.series[1].data = res.collect_goods;
  143. option.series[2].data = res.goods_pay_count;
  144. option.series[3].data = res.collect_shop;
  145. option.series[4].data = res.order_total;
  146. option.series[5].data = res.order_pay_count;
  147. option.series[6].data = res.member_count;
  148. $(".current-time").html(res.time_range);
  149. myChart.setOption(option);
  150. }
  151. });
  152. }
  153. // 基于准备好的dom,初始化echarts实例
  154. var myChart = echarts.init(document.getElementById('main'));
  155. // 指定图表的配置项和数据
  156. option = {
  157. tooltip: {
  158. trigger: 'axis'
  159. },
  160. legend: {
  161. data: ['商品浏览数', '商品收藏数', '订单商品数', '店铺收藏数', '订单金额', '订单数', '会员人数']
  162. },
  163. xAxis: {
  164. type: 'category',
  165. boundaryGap: false,
  166. data: []
  167. },
  168. yAxis: {
  169. type: 'value',
  170. axisLabel: {
  171. formatter: '{value} 个'
  172. }
  173. },
  174. series: [{
  175. name: '商品浏览数',
  176. type: 'line',
  177. data: [],
  178. },
  179. {
  180. name: '商品收藏数',
  181. type: 'line',
  182. data: [],
  183. },
  184. {
  185. name: '订单商品数',
  186. type: 'line',
  187. data: [],
  188. },
  189. {
  190. name: '店铺收藏数',
  191. type: 'line',
  192. data: [],
  193. },
  194. {
  195. name: '订单金额',
  196. type: 'line',
  197. data: [],
  198. },
  199. {
  200. name: '订单数',
  201. type: 'line',
  202. data: [],
  203. },
  204. {
  205. name: '会员人数',
  206. type: 'line',
  207. data: [],
  208. }
  209. ]
  210. };
  211. // 使用刚指定的配置项和数据显示图表。
  212. myChart.setOption(option);
  213. </script>
  214. {/block}