| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- $("#TogglePreviewTableBtn").on("click",function(){
- if ($(this).hasClass("getoutline-close")){
- $(this).removeClass("getoutline-close");
- $(this).addClass("getoutline-open");
- $(".getoutline-fade").removeClass("toggleable-hidden");
- }else{
- $(this).removeClass("getoutline-open");
- $(this).addClass("getoutline-close");
- $(".getoutline-fade").addClass("toggleable-hidden");
- }
- });
- $(document).on("change","#changeSiteId",function(){
- var url=$(this).data("url");
- var siteid=$(this).val();
- $.ajax({
- url:url,
- data:'siteid='+siteid,
- dataType: "json",
- type:'post',
- success:function(res){
- if(res.code){
- getOutline();
- ajax_page('tody');
- }else{
- layer.alert(res.msg);
- }
- }
- });
- })
- $(document).on("click",".ajax-btn",function(){
- var memo=$(this).attr("id");
- ajax_page(memo);
- })
- $(document).on("click",".overtime-getOutline",function(){
- getOutline();
- })
- $(document).on("click",".overtime-getTimeTrendRpt",function(){
- var memo=$(this).attr("data-memo");
- getTimeTrendRpt(memo);
- })
- $(document).on("click",".overtime-getCommonTrackRpt",function(){
- var memo=$(this).attr("data-memo");
- getCommonTrackRpt(memo)
- })
- var ajax_page=function (memo){
- $(".btn-group .btn").addClass("btn-default");
- $(".btn-group .btn").removeClass("btn-primary");
- $("#"+memo).addClass("btn-primary");
- $("#"+memo).removeClass("btn-default");
- getTimeTrendRpt(memo);
- getCommonTrackRpt(memo);
- };
- var getOutline=function(){
- var overtime='<tr><td colspan="7" style="text-align:center;">请求超时,<a href="javascript:;" class="overtime-getOutline">点击重试</a></td></tr>';
- $.ajax({
- url:url_getoutline,
- type:'post',
- timeout: '10000',
- beforeSend:function(){
- $('.getoutline-tbody').html('<tr><td colspan="7" style="text-align:center;"><i class="fa fa-spin fa-spinner" aria-hidden="true"></i> 数据获取中...</td></tr>');
- },
- success:function(res){
- $('.getoutline-tbody').html(res.html);
- },
- error:function(XMLHttpRequest, textStatus, errorThrown){
- $('.getoutline-tbody').html(overtime);
- },
- complete: function (XMLHttpRequest, textStatus) {
- if(textStatus == 'timeout'){
- $('.getoutline-tbody').html(overtime);
- }
- },
- });
- };
- var getTimeTrendRpt=function(memo){
- $("#echarts-line-chart").css("width",$("#echarts-line-chart").width());
- var overtime='请求超时,<a href="javascript:;" class="overtime-getTimeTrendRpt" data-memo="'+memo+'">点击重试</a>';
- $.ajax({
- url:url_gettimetrendrpt,
- type:'post',
- data:'memo='+memo,
- dataType: "json",
- timeout: '10000',
- success:function(res){
- if(res.status==1){
- var echarts_getTimeTrendRpt = echarts.init(document.getElementById("echarts-line-chart")),
- option_getTimeTrendRpt = {
- tooltip: {
- trigger: "axis"
- },
- grid: {
- left: '3%',
- right: '5%',
- bottom: '3%',
- containLabel: true
- },
- legend: {
- data: ['浏览量(PV)','访客数(UV)']
- },
- calculable: !0,
- xAxis: [{
- type: "category",
- boundaryGap: !1,
- data: res.data.date,
- axisTick: {
- alignWithLabel: true
- }
- }],
- yAxis: {
- type: "value",
- },
- series: [
- {
- name: "浏览量(PV)",
- type: "line",
- data: res.data.pv,
- areaStyle:{
- normal:{
- color:['#e5f1fd']
- }
- }
- },
- {
- name: "访客数(UV)",
- type: "line",
- data: res.data.uv,
- areaStyle:{
- normal:{
- color:['#e5f1fd']
- }
- }
- }
- ],
- color:['#4fa8f9','#6ec71e']
- };
- echarts_getTimeTrendRpt.setOption(option_getTimeTrendRpt);
- $(window).resize(function(){
- echarts_getTimeTrendRpt.resize({width:$("#echarts-line-chart").closest(".panel-body").width()})
- });
- }else{
- $("#echarts-line-chart span").html('暂无数据');
- }
- },
- error:function(XMLHttpRequest, textStatus, errorThrown){
- $("#echarts-line-chart span").html(overtime);
- },
- complete: function (XMLHttpRequest, textStatus) {
- if(textStatus == 'timeout'){
- $("#echarts-line-chart span").html(overtime);
- }
- },
- });
- };
- var getCommonTrackRpt=function(memo){
- var overtime='<tr><td colspan="7" style="text-align:center;">请求超时,<a href="javascript:;" class="overtime-getCommonTrackRpt" data-memo="'+memo+'">点击重试</a></td></tr>';
- $.ajax({
- url:url_getcommontrackrpt,
- type:'post',
- data:'memo='+memo,
- dataType: "json",
- timeout: '10000',
- beforeSend:function(){
- $('.visit-overview-tbody').html('<tr><td colspan="7" class="no-borders text-center"><span style="line-height: 300px;"><i class="fa fa-spin fa-spinner" aria-hidden="true"></i> 数据获取中...<span></td></tr>');
- },
- success:function(res){
- if(res.status){
- $("#sourceSite").html(res.data.sourceSite);
- $("#word").html(res.data.word);
- $("#landingPage").html(res.data.landingPage);
- $("#visitPage").html(res.data.visitPage);
- $(".new_ratio span").html(res.data.visitType.newVisitor.ratio);
- $(".old_ratio span").html(res.data.visitType.oldVisitor.ratio);
- $(".new_pv_count").html(res.data.visitType.newVisitor.pv_count);
- $(".old_pv_count").html(res.data.visitType.oldVisitor.pv_count);
- $(".new_visitor_count").html(res.data.visitType.newVisitor.visitor_count);
- $(".old_visitor_count").html(res.data.visitType.oldVisitor.visitor_count);
- $(".new_bounce_ratio").html(res.data.visitType.newVisitor.bounce_ratio+"%");
- $(".old_bounce_ratio").html(res.data.visitType.oldVisitor.bounce_ratio+"%");
- $(".new_avg_visit_time").html(res.data.visitType.newVisitor.avg_visit_time);
- $(".old_avg_visit_time").html(res.data.visitType.oldVisitor.avg_visit_time);
- $(".new_avg_visit_pages").html(res.data.visitType.newVisitor.avg_visit_pages);
- $(".old_avg_visit_pages").html(res.data.visitType.oldVisitor.avg_visit_pages);
- }else{
- var msg='<tr><td colspan="3" class="text-center">暂无数据</td></tr>';
- $("#sourceSite").html(msg);
- $("#word").html(msg);
- $("#landingPage").html(msg);
- $("#visitPage").html(msg);
- }
- },
- error:function(XMLHttpRequest, textStatus, errorThrown){
- $('.visit-overview-tbody').html(overtime);
- },
- complete: function (XMLHttpRequest, textStatus) {
- if(textStatus == 'timeout'){
- $('.visit-overview-tbody').html(overtime);
- }
- },
- });
- };
- if(bdtj_show==1){
- getOutline();
- ajax_page('tody');
- }else{
- layer.alert("尚未配置,请前往插件管理-百度网站统计-配置");
- }
- }
- };
- return Controller;
- });
|