main.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. {extend name="public/container"}
  2. {block name="head_top"}
  3. <!-- 全局js -->
  4. <script src="{__PLUG_PATH}echarts/echarts.common.min.js"></script>
  5. <script src="{__PLUG_PATH}echarts/theme/macarons.js"></script>
  6. <script src="{__PLUG_PATH}echarts/theme/westeros.js"></script>
  7. {/block}
  8. {block name="content"}
  9. <div id="app">
  10. <div class="row" >
  11. <div class="col-lg-12">
  12. <div class="ibox float-e-margins">
  13. <div class="ibox-title">
  14. <h5>用户</h5>
  15. </div>
  16. <div class="ibox-content">
  17. <div class="row">
  18. <div class="col-lg-12">
  19. <div class="flot-chart">
  20. <div class="flot-chart-content" ref="user_echart" id="flot-dashboard-chart2"></div>
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. {/block}
  30. {block name="script"}
  31. <style scoped>
  32. .box{width:0px;}
  33. </style>
  34. <script>
  35. require(['vue','axios','layer'],function(Vue,axios,layer){
  36. new Vue({
  37. el:"#app",
  38. data:{
  39. option:{},
  40. myChart:{},
  41. active:'thirtyday',
  42. cyclename:'最近30天',
  43. precyclename:'上个30天',
  44. cyclecount:0,
  45. cycleprice:0,
  46. cyclecount_percent:0,
  47. cycleprice_percent:0,
  48. cyclecount_is_plus:0,
  49. cycleprice_is_plus:0,
  50. pre_cyclecount:0,
  51. pre_cycleprice:0
  52. },
  53. methods:{
  54. info:function () {
  55. var that=this;
  56. axios.get("{:Url('userchart')}").then((res)=>{
  57. that.myChart.user_echart.setOption(that.userchartsetoption(res.data.data));
  58. });
  59. },
  60. getlist:function (e) {
  61. var that=this;
  62. var cycle = e!=null ? e :'thirtyday';
  63. axios.get("{:Url('orderchart')}?cycle="+cycle).then((res)=>{
  64. that.myChart.order_echart.clear();
  65. that.myChart.order_echart.setOption(that.orderchartsetoption(res.data.data));
  66. that.active = cycle;
  67. switch (cycle){
  68. case 'thirtyday':
  69. that.cyclename = '最近30天';
  70. that.precyclename = '上个30天';
  71. break;
  72. case 'week':
  73. that.precyclename = '上周';
  74. that.cyclename = '本周';
  75. break;
  76. case 'month':
  77. that.precyclename = '上月';
  78. that.cyclename = '本月';
  79. break;
  80. case 'year':
  81. that.cyclename = '去年';
  82. that.precyclename = '今年';
  83. break;
  84. default:
  85. break;
  86. }
  87. var data=res.data.data;
  88. if(data) {
  89. that.cyclecount = data.cycle.count.data;
  90. that.cyclecount_percent = data.cycle.count.percent;
  91. that.cyclecount_is_plus = data.cycle.count.is_plus;
  92. that.cycleprice = data.cycle.price.data;
  93. that.cycleprice_percent = data.cycle.price.percent;
  94. that.cycleprice_is_plus = data.cycle.price.is_plus;
  95. that.pre_cyclecount = data.pre_cycle.count.data;
  96. that.pre_cycleprice = data.pre_cycle.price.data;
  97. }
  98. });
  99. },
  100. orderchartsetoption:function(data){
  101. data = data == undefined ? {} : data;
  102. this.option = {
  103. tooltip: {
  104. trigger: 'axis',
  105. axisPointer: {
  106. type: 'cross',
  107. crossStyle: {
  108. color: '#999'
  109. }
  110. }
  111. },
  112. toolbox: {
  113. feature: {
  114. dataView: {show: true, readOnly: false},
  115. magicType: {show: true, type: ['line', 'bar']},
  116. restore: {show: false},
  117. saveAsImage: {show: true}
  118. }
  119. },
  120. legend: {
  121. data: data.legend || []
  122. },
  123. grid: {
  124. x: 70,
  125. x2: 50,
  126. y: 60,
  127. y2: 50
  128. },
  129. xAxis: [
  130. {
  131. type: 'category',
  132. data: data.xAxis,
  133. axisPointer: {
  134. type: 'shadow'
  135. },
  136. axisLabel:{
  137. interval: 0,
  138. rotate:40
  139. }
  140. }
  141. ],
  142. yAxis:[{type : 'value'}],
  143. // yAxis: [
  144. // {
  145. // type: 'value',
  146. // name: '',
  147. // min: 0,
  148. // max: data.yAxis.maxprice,
  149. //// interval: 0,
  150. // axisLabel: {
  151. // formatter: '{value} 元'
  152. // }
  153. // },
  154. // {
  155. // type: 'value',
  156. // name: '',
  157. // min: 0,
  158. // max: data.yAxis.maxnum,
  159. // interval: 5,
  160. // axisLabel: {
  161. // formatter: '{value} 个'
  162. // }
  163. // }
  164. // ],
  165. series: data.series
  166. };
  167. return this.option;
  168. },
  169. userchartsetoption:function(data){
  170. this.option = {
  171. tooltip: {
  172. trigger: 'axis',
  173. axisPointer: {
  174. type: 'cross',
  175. crossStyle: {
  176. color: '#999'
  177. }
  178. }
  179. },
  180. toolbox: {
  181. feature: {
  182. dataView: {show: false, readOnly: false},
  183. magicType: {show: true, type: ['line', 'bar']},
  184. restore: {show: false},
  185. saveAsImage: {show: false}
  186. }
  187. },
  188. legend: {
  189. data:data.legend
  190. },
  191. grid: {
  192. x: 70,
  193. x2: 50,
  194. y: 60,
  195. y2: 50
  196. },
  197. xAxis: [
  198. {
  199. type: 'category',
  200. data: data.xAxis,
  201. axisPointer: {
  202. type: 'shadow'
  203. }
  204. }
  205. ],
  206. yAxis: [
  207. {
  208. type: 'value',
  209. name: '人数',
  210. min: 0,
  211. max: data.yAxis.maxnum,
  212. interval: 5,
  213. axisLabel: {
  214. formatter: '{value} 人'
  215. }
  216. }
  217. ],
  218. // series: data.series
  219. series : [ {
  220. name : '人数',
  221. type : 'bar',
  222. barWidth : '50%',
  223. itemStyle: {
  224. normal: {
  225. label: {
  226. show: true, //开启显示
  227. position: 'top', //在上方显示
  228. textStyle: { //数值样式
  229. color: '#666',
  230. fontSize: 12
  231. }
  232. }
  233. }
  234. },
  235. data : data.series
  236. } ]
  237. };
  238. return this.option;
  239. },
  240. setChart:function(name,myChartname){
  241. this.myChart[myChartname] = echarts.init(name,'macarons');//初始化echart
  242. }
  243. },
  244. mounted:function () {
  245. const self = this;
  246. // this.setChart(self.$refs.order_echart,'order_echart');//订单图表
  247. this.setChart(self.$refs.user_echart,'user_echart');//用户图表
  248. this.info();
  249. this.getlist();
  250. $('.opFrames').on('click',function () {
  251. parent.addframes($(this).data('href'),'',$(this).data('name'));
  252. });
  253. }
  254. });
  255. });
  256. </script>
  257. {/block}