ga_index.html 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  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>
  23. <div class="box">
  24. <div id="users" class="contiant" style="height:400px;"></div>
  25. <div class="contiant">
  26. <div class="paihangtitle">
  27. <div>热门网页</div>
  28. </div>
  29. <div style="width: 100%;height: 350px; overflow-y: scroll;">
  30. <table class="page" style="border-collapse:collapse; width: 100%; font-size: 13px; ">
  31. <tr style="background-color: rgb(241,243,249); height: 40px; color:rgb(168,168,185) ;">
  32. <th width="5%"></th>
  33. <th width="30%">网页</th>
  34. <th width="12.5%"></th>
  35. <th width="12.5%">浏览量</th>
  36. <th width="12.5%"></th>
  37. <th width="18%">网页价值</th>
  38. </tr>
  39. <tbody class="tbody">
  40. </tbody>
  41. </table>
  42. </div>
  43. </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. <div class="contiant" >
  83. <div class="paihangtitle">
  84. <div>流量渠道</div>
  85. </div>
  86. <div id="channel" style="height: 400px;">
  87. </div>
  88. </div>
  89. <div class="contiant" >
  90. <div class="paihangtitle">
  91. <div><span class="selected_days">近七天</span>Google Ads 广告系列效果</div>
  92. </div>
  93. <div style="width: 100%;height: 350px; overflow-y: scroll;">
  94. <table class="ads" style="border-collapse:collapse; width: 100%; font-size: 13px; ">
  95. <tr style="background-color: rgb(241,243,249); height: 40px; color:rgb(168,168,185) ;">
  96. <th width="5%"></th>
  97. <th width="20%">广告系列</th>
  98. <th width="12.5%"></th>
  99. <th width="12.5%">点击次数</th>
  100. <th width="12.5%"></th>
  101. <th width="18%">费用</th>
  102. <th width="12.5%"></th>
  103. <th width="12.5%">收入</th>
  104. </tr>
  105. <tbody class="tbody">
  106. </tbody>
  107. </table>
  108. </div>
  109. </div>
  110. <div class="contiant" style="width:60%;">
  111. <div class="paihangtitle">
  112. <div><span class="selected_days">近七天</span>店铺销量数据</div>
  113. </div>
  114. <ul>
  115. <li class="time_btn hour" data-type="hour">分时</li>
  116. <li class="time_btn day active" data-type="day">日</li>
  117. <li class="time_btn week" data-type="week">周</li>
  118. <li class="time_btn month" data-type="month">月</li>
  119. </ul>
  120. <div id="sell" style="height: 800px;">
  121. </div>
  122. </div>
  123. </div>
  124. <style>
  125. th{
  126. font-weight: 100;
  127. }
  128. tbody tr{
  129. height: 50px;
  130. }
  131. .paiming{
  132. width: 20px;
  133. height: 20px;
  134. line-height: 20px;
  135. font-weight: 600;
  136. color: #FFFFFF;
  137. background-color: rgb(182,180,182);
  138. }
  139. .box{
  140. display: flex;
  141. flex-flow: row wrap;
  142. justify-content: space-around;
  143. margin: 25px;
  144. }
  145. table tr:nth-child(even){
  146. background: rgb(249,249,251);
  147. }
  148. .paimingone,.paiming1 {
  149. background-color: rgb(255,197,50);
  150. }
  151. .paimingtwo,.paiming2{
  152. background-color: rgb(244,144,111);
  153. }
  154. .paimingthree,.paiming3{
  155. background-color: rgb(37,208,234);
  156. }
  157. .contiant{
  158. width: 600px;
  159. height: 400px;
  160. box-sizing: border-box;
  161. padding: 20px;
  162. background-color: #fff;
  163. border-radius: 5px;
  164. box-shadow:2px 2px 5px #999999;
  165. display: flex;
  166. flex-direction: column;
  167. margin: 20px;
  168. }
  169. .paihangtitle{
  170. display: flex;
  171. justify-content: space-between;
  172. margin-bottom: 10px;
  173. }
  174. .paihangtitle div{
  175. color: rgb(5,55,72);
  176. font-weight: 600;
  177. }
  178. .paihangtitle a{
  179. text-decoration: none;
  180. color:rgb(168,168,185);
  181. font-weight: 100;
  182. }
  183. .card-list {
  184. display: flex;
  185. flex-wrap: wrap;
  186. justify-content: left;
  187. margin: auto;
  188. }
  189. .card-item {
  190. margin: 20px;
  191. /* box-sizing: border-box; */
  192. padding: 20px;
  193. width: 150px;
  194. border-radius: 5px;
  195. box-shadow: 2px 2px 5px #999999;
  196. text-align: center;
  197. background-color: #fff;
  198. }
  199. .time_btn{
  200. display: block;
  201. float: left;
  202. background-color: #f3f3f3;
  203. padding: 8px 7px;
  204. font: bold 11px 'Roboto',sans-serif;
  205. color: #444;
  206. border: 1px solid #ccc;
  207. background-image: -webkit-linear-gradient(top,#fefefe,#f3f3f3);
  208. background-image: -moz-linear-gradient(top,#fefefe,#f3f3f3);
  209. cursor: pointer;
  210. min-width: 18px;
  211. text-align: center;
  212. }
  213. .time_btn.active{
  214. background-color: #dfdfdf;
  215. background-image: -webkit-linear-gradient(top,#f0f0f0,#dfdfdf);
  216. background-image: -moz-linear-gradient(top,#f0f0f0,#dfdfdf);
  217. border-color: #ccc;
  218. box-shadow: inset 0px 1px 5px rgba(0,0,0,.3);
  219. color: #222;
  220. }
  221. </style>
  222. </div>
  223. <script src="{$theme}js/echarts.min.js?v=201911220005"></script>
  224. <script type="text/javascript">
  225. var sellChart = echarts.init(document.getElementById('sell'));
  226. var sell
  227. var cur_date
  228. var cur_data
  229. var last_sell
  230. var last_data
  231. $(".default span").click(function() {
  232. defaultgo();
  233. });
  234. $(document).ready(function() {
  235. defaultgo();
  236. })
  237. $('.time_btn').click(function(){
  238. $(this).addClass("active").siblings().removeClass("active");
  239. $type=$(this).data('type')
  240. var data=[];
  241. cur_date=$type;
  242. cur_data=sell.data[$type];
  243. date=sell.date[$type];
  244. for(var key in cur_data){
  245. data.push(cur_data[key].itemQuantity)
  246. }
  247. last_data=last_sell[$type]
  248. option = {
  249. xAxis: {
  250. data: date
  251. },
  252. series: [{
  253. name:"销量",
  254. data: data,
  255. type: 'line',
  256. // smooth:true,
  257. },
  258. {
  259. name:"上期对比",
  260. data: last_data,
  261. type: 'line',
  262. itemStyle:{
  263. normal:{
  264. lineStyle:{
  265. width:2,
  266. type:'dotted' //'dotted'虚线 'solid'实线
  267. }
  268. }
  269. },
  270. // smooth:true,
  271. }
  272. ],
  273. dataZoom:[
  274. { // 这个dataZoom组件,默认控制x轴。
  275. type: 'slider', //
  276. show:false,
  277. start: 0, // 左边在 10% 的位置。
  278. end: 100 // 右边在 60% 的位置。
  279. },
  280. { // 这个dataZoom组件,默认控制x轴。
  281. type: 'inside', //
  282. show:false,
  283. start: 0, // 左边在 10% 的位置。
  284. end: 100 // 右边在 60% 的位置。
  285. }
  286. ],
  287. };
  288. if($type=="hour"){
  289. option.dataZoom=[
  290. { // 这个dataZoom组件,默认控制x轴。
  291. type: 'slider', //
  292. show:true,
  293. start: 60, // 左边在 10% 的位置。
  294. end: 100 // 右边在 60% 的位置。
  295. },
  296. { // 这个dataZoom组件,默认控制x轴。
  297. type: 'inside', //
  298. show:true,
  299. start: 60, // 左边在 10% 的位置。
  300. end: 100 // 右边在 60% 的位置。
  301. }
  302. ];
  303. option.series=[
  304. {
  305. name:"销量",
  306. data: data,
  307. type: 'line',
  308. // smooth:true,
  309. },
  310. {
  311. name:"上期对比",
  312. data: [],
  313. }
  314. ];
  315. }
  316. sellChart.setOption(option);
  317. // sellChart.pagere
  318. })
  319. function getSellChart(sell){
  320. cur_date="day";
  321. cur_data=sell.data.day
  322. var data = [];
  323. // day_data.forEach(function(data,item){
  324. // console.log(data);
  325. // console.log(item);
  326. // },[]);
  327. for(var key in cur_data){
  328. data.push(cur_data[key].itemQuantity)
  329. }
  330. last_data=last_sell[cur_date];
  331. option = {
  332. xAxis: {
  333. type: 'category',
  334. data: sell.date.day
  335. },
  336. yAxis: {
  337. type: 'value'
  338. },
  339. legend: {
  340. data: ['销量', '上期对比']
  341. },
  342. tooltip: {
  343. trigger: 'axis',
  344. formatter:function(params){
  345. name=params[0].name;
  346. // console.log(cur_data[name]);
  347. str="";
  348. str+="<span>销量: "+cur_data[name].itemQuantity+"</span><br/>";
  349. str+="<span>交易次数: "+cur_data[name].transactions+"</span><br/>";
  350. str+="<span>总金额: $"+cur_data[name].transactionRevenue+"</span>";
  351. return str;
  352. }
  353. },
  354. series: [
  355. {
  356. name:"销量",
  357. data: data,
  358. type: 'line',
  359. // smooth:true,
  360. },
  361. {
  362. name:"上期对比",
  363. data: last_data,
  364. type: 'line',
  365. itemStyle:{
  366. normal:{
  367. lineStyle:{
  368. width:2,
  369. type:'dotted' //'dotted'虚线 'solid'实线
  370. }
  371. }
  372. },
  373. // smooth:true,
  374. }
  375. ],
  376. dataZoom:[
  377. { // 这个dataZoom组件,默认控制x轴。
  378. type: 'slider', //
  379. show:false,
  380. start: 0, // 左边在 10% 的位置。
  381. end: 100 // 右边在 60% 的位置。
  382. },
  383. { // 这个dataZoom组件,默认控制x轴。
  384. type: 'inside', //
  385. show:false,
  386. start: 0, // 左边在 10% 的位置。
  387. end: 100 // 右边在 60% 的位置。
  388. }
  389. ],
  390. };
  391. // 使用刚指定的配置项和数据显示图表。
  392. sellChart.setOption(option);
  393. }
  394. function getChannelChart(channel){
  395. var channelChart = echarts.init(document.getElementById('channel'));
  396. var y = [];
  397. var x=[];
  398. // day_data.forEach(function(data,item){
  399. // console.log(data);
  400. // console.log(item);
  401. // },[]);
  402. for(var key in channel){
  403. x.push(channel[key].channelGrouping)
  404. y.push({value:channel[key].users,name:channel[key].channelGrouping})
  405. }
  406. option = {
  407. title: {
  408. text: '流量渠道',
  409. left: 'center'
  410. },
  411. tooltip: {
  412. trigger: 'item',
  413. formatter: '{a} <br/>{b} : {c} ({d}%)'
  414. },
  415. legend: {
  416. orient: 'vertical',
  417. left: 'left',
  418. data: x
  419. },
  420. series: [
  421. {
  422. name: '访问来源',
  423. type: 'pie',
  424. radius: '55%',
  425. center: ['50%', '60%'],
  426. data: y,
  427. emphasis: {
  428. itemStyle: {
  429. shadowBlur: 10,
  430. shadowOffsetX: 0,
  431. shadowColor: 'rgba(0, 0, 0, 0.5)'
  432. }
  433. }
  434. }
  435. ]
  436. };
  437. channelChart.setOption(option);
  438. }
  439. function defaultgo() {
  440. days=$("[name='days']").val();
  441. shop=$("[name='shop']").val();
  442. selday_str=$(".select.days option:selected").text();
  443. $('.selected_days').text(selday_str);
  444. $('.sell .tbody').html("");
  445. $('.sku .tbody').html("");
  446. $(".card-list").html("");
  447. $(".ads .tbody").html("");
  448. $(".page .tbody").html("");
  449. $.ajax({
  450. url: "/ga/index/",
  451. data: {"days":days,"shop":shop},
  452. type: "POST",
  453. dataType: "json",
  454. success: function(a) {
  455. if (a && a.success) {
  456. //sell
  457. var geo = a.data.geo
  458. var product = a.data.product
  459. var ads= a.data.ads
  460. var store=a.data.store
  461. var page=a.data.page
  462. var channel=a.data.channel
  463. var store_html=""
  464. sell =a.data.sell
  465. last_sell=a.data.last_sell
  466. geo.map((item,index)=>{
  467. var h='"/ga/regionproduct/'+shop+'/'+days+'/'+Base64.encode(item.region)+'"'
  468. if(index==0){
  469. 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>'
  470. $('.sell .tbody').append(Tdom)
  471. }else if(index==1){
  472. 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>'
  473. $('.sell .tbody').append(Tdom)
  474. }else if(index==2){
  475. 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>'
  476. $('.sell .tbody').append(Tdom)
  477. }else{
  478. 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>'
  479. $('.sell .tbody').append(Tdom)
  480. }
  481. })
  482. product.map((item,index)=>{
  483. var h='"/ga/productinfo/'+shop+'/'+days+'/'+Base64.encode(item.productName)+'"';
  484. var Tdom ='<tr ><th><div class="paiming paiming'+parseInt(index+1)+'">'+parseInt(index+1)+'</div></th><th width="20%"><div><a style="color: #0268c2;" href='+h+' target="_blank">'+item.productName+'</a></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>'
  485. $('.sku .tbody').append(Tdom)
  486. })
  487. ads.map((item,index)=>{
  488. // var h='"/ga/productinfo/'+shop+'/'+days+'/'+Base64.encode(item.productName)+'"'
  489. var Tdom ='<tr ><th><div class="paiming paiming'+parseInt(index+1)+'">'+parseInt(index+1)+'</div></th><th width="20%"><div>'+item.campaign+'</div></th><th width="12.5%"></th><th width="12.5%"><div>'+item.adClicks+'</div></th><th width="12.5%"></th><th width="18%"><div><div>'+item.adCost+'</div></div></div></th><th width="12.5%"></th><th width="18%"><div><div>'+item.transactionRevenue+'</div></div></th></tr>'
  490. $('.ads .tbody').append(Tdom)
  491. })
  492. page.map((item,index)=>{
  493. var Tdom ='<tr ><th><div class="paiming paiming'+parseInt(index+1)+'">'+parseInt(index+1)+'</div></th><th width="20%"><div>'+item.pagePath+'</div></th><th width="12.5%"></th><th width="12.5%"><div>'+item.pageviews+'</div></th><th width="12.5%"></th><th width="18%"><div><div>'+item.pageValue+'</div></div></div></th></tr>'
  494. $('.page .tbody').append(Tdom)
  495. })
  496. for(var index in store){
  497. store_html+='<div class="card-item"><div>'+index+'</div><div>'+store[index]+'</div></div>'
  498. }
  499. $(".card-list").html(store_html)
  500. // 基于准备好的dom,初始化echarts实例
  501. var data=a.data
  502. var myChart = echarts.init(document.getElementById('users'));
  503. // 指定图表的配置项和数据
  504. var option = {
  505. legend: {
  506. data: ['新用户', '老用户']
  507. },
  508. tooltip: {
  509. trigger: 'axis',
  510. formatter:function(params){
  511. total=parseInt(params[0].value)+parseInt(params[1].value);
  512. percent1=((params[0].value/total)*100).toFixed(2)+"%";
  513. percent2=((params[1].value/total)*100).toFixed(2)+"%";
  514. str= '<span>'+params[0].seriesName+':'+params[0].value+' 占比:'+percent1+'</span><br/>';
  515. str+= '<span>'+params[1].seriesName+':'+params[1].value+' 占比:'+percent2+'</span><br/>';
  516. return str;
  517. }
  518. },
  519. xAxis: {
  520. type: 'category',
  521. boundaryGap: false,
  522. data: data.users.date
  523. },
  524. yAxis: {
  525. type: 'value'
  526. },
  527. series: [
  528. {
  529. name:"新用户",
  530. data: data.users.new,
  531. type: 'line',
  532. areaStyle: {}
  533. },
  534. {
  535. name:"老用户",
  536. data: data.users.return,
  537. type: 'line',
  538. areaStyle: {}
  539. }
  540. ]
  541. };
  542. // 使用刚指定的配置项和数据显示图表。
  543. myChart.setOption(option);
  544. getSellChart(sell);
  545. getChannelChart(channel)
  546. }
  547. }
  548. });
  549. };
  550. </script>
  551. <script type="text/javascript" src="{$theme}js/laydate.js"></script>
  552. {Template footer}