world.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // var myChart = echarts.init(document.getElementById("echarts-map-world"));
  5. var ajax_page=function(memo){
  6. var overtime='<tr><td colspan="7" style="text-align:center;">请求超时,<a href="javascript:;" class="ajax-page" data-memo="'+memo+'">点击重试</a></td></tr>';
  7. $.ajax({
  8. url:url,
  9. type:'post',
  10. data:'memo='+memo,
  11. dataType: "json",
  12. timeout: '10000',
  13. beforeSend:function(){
  14. $(".btn-group .btn-primary").addClass("btn-default");
  15. $(".btn-group .btn-primary").removeClass("btn-primary");
  16. $("#"+memo).addClass("btn-primary");
  17. $("#"+memo).removeClass("btn-default");
  18. $('.visit-world-tbody').html('<tr><td colspan="7" style="text-align: center;"><span><i class="fa fa-spin fa-spinner" aria-hidden="true"></i>&nbsp;&nbsp;数据获取中...<span></td></tr>');
  19. },
  20. success:function(res){
  21. if(res.status){
  22. var map=res.map;
  23. // var option = {
  24. // tooltip : {
  25. // trigger: 'item',
  26. // },
  27. // nameMap:nameMap,
  28. // visualMap: {
  29. // min:'0',
  30. // max:map[0]['value'],
  31. // left: 'left',
  32. // top: 'bottom',
  33. // orient: 'horizontal',
  34. // inverse:true,
  35. // align:'left',
  36. // inRange: {
  37. // color: ['rgba(230,230,230,0.6)', '#3385e3'],
  38. // symbolSize: [30, 100]
  39. // },
  40. // outRange: {
  41. // color: ['#e6e6e6', '#3385e3'],
  42. // symbolSize: [30, 100]
  43. // },
  44. // borderColor:'#ffffff',
  45. // text:['高','低'],
  46. // },
  47. // series : [
  48. // {
  49. // name: '浏览量(PV)',
  50. // type: 'map',
  51. // map: 'world',
  52. // roam: true,
  53. // label: {
  54. // normal: {
  55. // show: false
  56. // },
  57. // emphasis: {
  58. // show: true
  59. // }
  60. // },
  61. // itemStyle:{
  62. // normal:{
  63. // borderColor:'#ffffff',
  64. // areaColor:'#e6e6e6'
  65. // }
  66. // },
  67. // data:map
  68. // },
  69. // ]
  70. // };
  71. // myChart.setOption(option);
  72. $('.pv_count').html(res['sum'][0]);
  73. $('.visitor_count').html(res['sum'][1]);
  74. $('.ip_count').html(res['sum'][2]);
  75. $('.bounce_ratio').html(res['sum'][3]+'%');
  76. $('.avg_visit_time').html(res['sum'][4]);
  77. $('.visit-world-tbody').html(res.html);
  78. }else{
  79. $('.visit-world-tbody').html('<tr><td colspan="7" style="text-align:center;">'+res.msg+'</td></tr>');
  80. }
  81. },
  82. error:function(XMLHttpRequest, textStatus, errorThrown){
  83. $('.visit-world-tbody').html(overtime);
  84. },
  85. complete: function (XMLHttpRequest, textStatus) {
  86. if(textStatus == 'timeout'){
  87. $('.visit-world-tbody').html(overtime);
  88. }
  89. },
  90. });
  91. };
  92. $(document).on("change","#changeSiteId",function(){
  93. var url=$(this).data("url");
  94. var siteid=$(this).val();
  95. $.ajax({
  96. url:url,
  97. data:'siteid='+siteid,
  98. dataType: "json",
  99. type:'post',
  100. success:function(res){
  101. if(res.code){
  102. location.reload();
  103. }else{
  104. layer.alert(res.msg);
  105. }
  106. }
  107. });
  108. })
  109. if(bdtj_show==1){
  110. ajax_page('tody');
  111. }else{
  112. layer.alert("尚未配置,请前往插件管理-百度网站统计-配置");
  113. }
  114. $(document).on("click",".ajax-page",function(){
  115. var memo=$(this).attr("data-memo");
  116. ajax_page(memo);
  117. })
  118. }
  119. };
  120. return Controller;
  121. });