ga_chart.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. {Template header}
  2. <script src="{$theme}js/base64.min.js"></script>
  3. <body>
  4. <div class="warp">
  5. <div class="title default " style="margin-bottom:20px;">天数
  6. <select name="days" class="select days" value>
  7. <option value="0">今天</option>
  8. <option value="1">昨天</option>
  9. <option value="7" selected>近7天</option>
  10. <option value="15" >近15天</option>
  11. <option value="30">近30天</option>
  12. <option value="60">近60天</option>
  13. </select>
  14. 店铺名称:<select name="shop" class="select">
  15. <option value="">请选择</option>
  16. {loop usershop() as $val}
  17. <option value="{$val['id']}" {if $val['id']==$shop['id']}selected{/if}>{$val['shopname']}</option>
  18. {/loop}
  19. </select>
  20. <span>确 定</span></div>
  21. <div class='card-list'>
  22. <div class="card-item">
  23. <div>销量</div>
  24. <div>1123</div>
  25. <div>较上一周</div>
  26. </div>
  27. <div class="card-item">
  28. <div>销量</div>
  29. <div>1123</div>
  30. <div>较上一周</div>
  31. </div>
  32. <div class="card-item">
  33. <div>销量</div>
  34. <div>1123</div>
  35. <div>较上一周</div>
  36. </div>
  37. <div class="card-item">
  38. <div>销量</div>
  39. <div>1123</div>
  40. <div>较上一周</div>
  41. </div>
  42. </div>
  43. <div id="users" style="width:50%;height:40%;float:left;"></div>
  44. <div class="contiant">
  45. <div class="paihangtitle">
  46. <div><span class="selected_days">近7天</span>产品销量排行</div>
  47. </div>
  48. <div style="width: 100%;height: 350px; overflow-y: scroll;">
  49. <table class="sku" style="border-collapse:collapse; width: 100%; font-size: 13px; ">
  50. <tr style="background-color: rgb(241,243,249); height: 40px; color:rgb(168,168,185) ;">
  51. <th width="5%"></th>
  52. <th width="30%">商品sku</th>
  53. <th width="12.5%"></th>
  54. <th width="12.5%">销售额</th>
  55. <th width="12.5%"></th>
  56. <th width="18%">销售量</th>
  57. </tr>
  58. <tbody class="tbody">
  59. </tbody>
  60. </table>
  61. </div>
  62. </div>
  63. <div class="contiant" >
  64. <div class="paihangtitle">
  65. <div><span class="selected_days">近七天</span>地区销量排行</div>
  66. </div>
  67. <div style="width: 100%;height: 350px; overflow-y: scroll;">
  68. <table class="sell" style="border-collapse:collapse; width: 100%; font-size: 13px; ">
  69. <tr style="background-color: rgb(241,243,249); height: 40px; color:rgb(168,168,185) ;">
  70. <th width="5%"></th>
  71. <th width="20%">地区</th>
  72. <th width="12.5%"></th>
  73. <th width="12.5%">订单量</th>
  74. <th width="12.5%"></th>
  75. <th width="18%">占比</th>
  76. </tr>
  77. <tbody class="tbody">
  78. </tbody>
  79. </table>
  80. </div>
  81. </div>
  82. <style>
  83. th{
  84. font-weight: 100;
  85. }
  86. tbody tr{
  87. height: 50px;
  88. }
  89. .paiming{
  90. width: 20px;
  91. height: 20px;
  92. line-height: 20px;
  93. font-weight: 600;
  94. color: #FFFFFF;
  95. background-color: rgb(182,180,182);
  96. }
  97. table tr:nth-child(even){
  98. background: rgb(249,249,251);
  99. }
  100. .paimingone {
  101. background-color: rgb(255,197,50);
  102. }
  103. .paimingtwo{
  104. background-color: rgb(244,144,111);
  105. }
  106. .paimingthree{
  107. background-color: rgb(37,208,234);
  108. }
  109. .contiant{
  110. width: 600px;
  111. height: 400px;
  112. box-sizing: border-box;
  113. padding: 20px;
  114. background-color: #fff;
  115. border-radius: 5px;
  116. box-shadow:2px 2px 5px #999999;
  117. display: flex;
  118. flex-direction: column;
  119. }
  120. .paihangtitle{
  121. display: flex;
  122. justify-content: space-between;
  123. margin-bottom: 10px;
  124. }
  125. .paihangtitle div{
  126. color: rgb(5,55,72);
  127. font-weight: 600;
  128. }
  129. .paihangtitle a{
  130. text-decoration: none;
  131. color:rgb(168,168,185);
  132. font-weight: 100;
  133. }
  134. .card-list {
  135. display: flex;
  136. flex-wrap: wrap;
  137. justify-content: left;
  138. margin: auto;
  139. }
  140. .card-item {
  141. margin: 20px;
  142. box-sizing: border-box;
  143. padding: 20px;
  144. width: 150px;
  145. border-radius: 5px;
  146. box-shadow: 2px 2px 5px #999999;
  147. text-align: center;
  148. }
  149. </style>
  150. </div>
  151. <script src="{$theme}js/echarts.min.js?v=201911220005"></script>
  152. <script type="text/javascript">
  153. $(".default span").click(function() {
  154. defaultgo();
  155. });
  156. $(document).ready(function() {
  157. defaultgo();
  158. })
  159. function defaultgo() {
  160. days=$("[name='days']").val();
  161. shop=$("[name='shop']").val();
  162. selday_str=$(".select.days option:selected").text();
  163. $('.selected_days').text(selday_str);
  164. $('.sell .tbody').html("");
  165. $('.sku .tbody').html("");
  166. $.ajax({
  167. url: "/ga/trafficsource/",
  168. data: {"days":days,"shop":shop},
  169. type: "POST",
  170. dataType: "json",
  171. success: function(a) {
  172. if (a && a.success) {
  173. //sell
  174. var tablelist = a.data.sell
  175. var product = a.data.product
  176. tablelist.map((item,index)=>{
  177. var h='"/ga/regionproduct/'+shop+'/'+days+'/'+Base64.encode(item.region)+'"'
  178. if(index==0){
  179. var Tdom ='<tr ><th><div class="paiming paimingone">'+parseInt(index+1)+'</div></th><th width="20%"><h9 class="window" data-h='+h+' data-t="订单详情">'+item.region+'</h9></th><th width="12.5%"></th><th width="12.5%"><div>'+item.transactions+'</div></th><th width="12.5%"></th><th width="18%"><div><div>'+item.percent+'</div><div style="width: 90%;margin-top: 5px; height: 4px; background-color: rgb(238,238,238); border-radius: 5px;"><div style="width: '+item.percent+'; height: 100%; background-color: rgb(40,208,234);border-top-left-radius: 10px;border-bottom-left-radius: 10px;"></div></div></div></th></tr>'
  180. $('.sell .tbody').append(Tdom)
  181. }else if(index==1){
  182. var Tdom ='<tr ><th><div class="paiming paimingtwo">'+parseInt(index+1)+'</div></th><th width="20%"><h9 class="window" data-h='+h+' data-t="订单详情">'+item.region+'</h9></th><th width="12.5%"></th><th width="12.5%"><div>'+item.transactions+'</div></th><th width="12.5%"></th><th width="18%"><div><div>'+item.percent+'</div><div style="width: 90%;margin-top: 5px; height: 4px; background-color: rgb(238,238,238); border-radius: 5px;"><div style="width: '+item.percent+'; height: 100%; background-color: rgb(40,208,234);border-top-left-radius: 10px;border-bottom-left-radius: 10px;"></div></div></div></th></tr>'
  183. $('.sell .tbody').append(Tdom)
  184. }else if(index==2){
  185. var Tdom ='<tr ><th><div class="paiming paimingthree">'+parseInt(index+1)+'</div></th><th width="20%"><h9 class="window" data-h='+h+' data-t="订单详情">'+item.region+'</h9></th><th width="12.5%"></th><th width="12.5%"><div>'+item.transactions+'</div></th><th width="12.5%"></th><th width="18%"><div><div>'+item.percent+'</div><div style="width: 90%;margin-top: 5px; height: 4px; background-color: rgb(238,238,238); border-radius: 5px;"><div style="width: '+item.percent+'; height: 100%; background-color: rgb(40,208,234);border-top-left-radius: 10px;border-bottom-left-radius: 10px;"></div></div></div></th></tr>'
  186. $('.sell .tbody').append(Tdom)
  187. }else{
  188. var Tdom ='<tr ><th><div class="paiming">'+parseInt(index+1)+'</div></th><th width="20%"><h9 class="window" data-h='+h+' data-t="订单详情">'+item.region+'</h9></th><th width="12.5%"></th><th width="12.5%"><div>'+item.transactions+'</div></th><th width="12.5%"></th><th width="18%"><div><div>'+item.percent+'</div><div style="width: 90%;margin-top: 5px; height: 4px; background-color: rgb(238,238,238); border-radius: 5px;"><div style="width:'+item.percent+'; height: 100%; background-color: rgb(40,208,234);border-top-left-radius: 10px;border-bottom-left-radius: 10px;"></div></div></div></th></tr>'
  189. $('.sell .tbody').append(Tdom)
  190. }
  191. })
  192. product.map((item,index)=>{
  193. var h='"/ga/productinfo/'+shop+'/'+days+'/'+Base64.encode(item.productName)+'"'
  194. if(index==0){
  195. var Tdom ='<tr ><th><div class="paiming paimingone">'+parseInt(index+1)+'</div></th><th width="20%"><div><h9 class="window" data-h='+h+' data-t="订单详情">'+item.productName+'</h9></div></th><th width="12.5%"></th><th width="12.5%"><div>'+item.itemRevenue+'</div></th><th width="12.5%"></th><th width="18%"><div><div>'+item.itemQuantity+'</div></div></div></th></tr>'
  196. $('.sku .tbody').append(Tdom)
  197. }else if(index==1){
  198. var Tdom ='<tr ><th><div class="paiming paimingtwo">'+parseInt(index+1)+'</div></th><th width="20%"><div><h9 class="window" data-h='+h+' data-t="订单详情">'+item.productName+'</h9></div></th><th width="12.5%"></th><th width="12.5%"><div>'+item.itemRevenue+'</div></th><th width="12.5%"></th><th width="18%"><div><div>'+item.itemQuantity+'</div></div></div></th></tr>'
  199. $('.sku .tbody').append(Tdom)
  200. }else if(index==2){
  201. var Tdom ='<tr ><th><div class="paiming paimingthree">'+parseInt(index+1)+'</div></th><th width="20%"><div><h9 class="window" data-h='+h+' data-t="订单详情">'+item.productName+'</h9></div></th><th width="12.5%"></th><th width="12.5%"><div>'+item.itemRevenue+'</div></th><th width="12.5%"></th><th width="18%"><div><div>'+item.itemQuantity+'</div></div></div></th></tr>'
  202. $('.sku .tbody').append(Tdom)
  203. }else{
  204. var Tdom ='<tr ><th><div class="paiming">'+parseInt(index+1)+'</div></th><th width="20%"><div><h9 class="window" data-h='+h+' data-t="订单详情">'+item.productName+'</h9></div></th><th width="12.5%"></th><th width="12.5%"><div>'+item.itemRevenue+'</div></th><th width="12.5%"></th><th width="18%"><div><div>'+item.itemQuantity+'</div></div></div></th></tr>'
  205. $('.sku .tbody').append(Tdom)
  206. }
  207. })
  208. // 基于准备好的dom,初始化echarts实例
  209. var data=a.data
  210. var myChart = echarts.init(document.getElementById('users'));
  211. // 指定图表的配置项和数据
  212. var option = {
  213. legend: {
  214. data: ['新用户', '老用户']
  215. },
  216. tooltip: {
  217. trigger: 'axis',
  218. formatter:function(params){
  219. total=parseInt(params[0].value)+parseInt(params[1].value);
  220. percent1=((params[0].value/total)*100).toFixed(2)+"%";
  221. percent2=((params[1].value/total)*100).toFixed(2)+"%";
  222. str= '<span>'+params[0].seriesName+':'+params[0].value+' 占比:'+percent1+'</span><br/>';
  223. str+= '<span>'+params[1].seriesName+':'+params[1].value+' 占比:'+percent2+'</span><br/>';
  224. return str;
  225. }
  226. },
  227. xAxis: {
  228. type: 'category',
  229. boundaryGap: false,
  230. data: data.users.date
  231. },
  232. yAxis: {
  233. type: 'value'
  234. },
  235. series: [
  236. {
  237. name:"新用户",
  238. data: data.users.new,
  239. type: 'line',
  240. areaStyle: {}
  241. },
  242. {
  243. name:"老用户",
  244. data: data.users.return,
  245. type: 'line',
  246. areaStyle: {}
  247. }
  248. ]
  249. };
  250. // 使用刚指定的配置项和数据显示图表。
  251. myChart.setOption(option);
  252. var dom = document.getElementById("container");
  253. var myChart = echarts.init(dom);
  254. var app = {};
  255. option = null;
  256. option = {
  257. tooltip: {
  258. trigger: 'axis'
  259. },
  260. legend: {
  261. data:['预计可得金额','实际可得金额']
  262. },
  263. toolbox: {
  264. show: true,
  265. feature: {
  266. dataZoom: {
  267. yAxisIndex: 'none'
  268. },
  269. dataView: {readOnly: false},
  270. magicType: {type: ['line', 'bar']},
  271. restore: {},
  272. saveAsImage: {}
  273. }
  274. },
  275. xAxis: {
  276. type: 'category',
  277. boundaryGap: false,
  278. data: a.time
  279. },
  280. yAxis: {
  281. type: 'value',
  282. axisLabel: {
  283. formatter: '{value} 元 '
  284. }
  285. },
  286. series: [
  287. {
  288. name:'预计可得金额',
  289. type:'line',
  290. data: a.ymoney,
  291. markPoint: {
  292. data: [
  293. {type: 'max', name: '最大值'},
  294. {type: 'min', name: '最小值'}
  295. ]
  296. },
  297. markLine: {
  298. data: [
  299. {type: 'average', name: '平均值'}
  300. ]
  301. }
  302. },
  303. {
  304. name:'实际可得金额',
  305. type:'line',
  306. data: a.money,
  307. markLine: {
  308. data: [
  309. {type: 'average', name: '平均值'},
  310. [{
  311. symbol: 'none',
  312. x: '90%',
  313. yAxis: 'max'
  314. }, {
  315. symbol: 'circle',
  316. label: {
  317. normal: {
  318. position: 'start',
  319. formatter: '最大值'
  320. }
  321. },
  322. type: 'max',
  323. name: '最高点'
  324. }]
  325. ]
  326. }
  327. }
  328. ]
  329. };
  330. ;
  331. if (option && typeof option === "object") {
  332. myChart.setOption(option, true);
  333. }
  334. }
  335. }
  336. });
  337. };
  338. </script>
  339. <script type="text/javascript" src="{$theme}js/laydate.js"></script>
  340. {Template footer}