layui.use(['layer', 'element','laydate'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;


    // 广告月度观看趋势
    var myCharts = echarts.init(document.getElementById('ad-month'), myEchartsTheme);
    function adWatchMonth(){
        var option = {

            tooltip: {
                // trigger: 'axis',
                // axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                //     type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                // }
            },
            grid: {
                left: '-10',
                top: '0%',
                right: '0',
                containLabel: true
            },
            xAxis: {
                type: "category",
                data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
                itemStyle: {
                    narmal: {
                        color: "red"
                    }
                },
                axisLabel: {
                    textStyle: {
                        color: '#d6e0dc',//坐标值的具体的颜色
                    },

                },
                axisLine: {
                    lineStyle: {
                        color: 'rgba(125,132,255,0.15)' //坐标轴的颜色
                    }
                },

            },
            yAxis: {
                show: false,
                type: "value",
                "axisTick": {       //y轴刻度线
                    "show": false
                },
                "splitLine": {     //网格线
                    "show": false
                }
            },
            series: [
                {
                    data: [],
                    type: "bar",
                    itemStyle: {
                        normal: {
                            barBorderRadius: [3, 3, 3, 3],
                            //每根柱子颜色设置
                            color: new echarts.graphic.LinearGradient(
                                0, 1, 0, 0,
                                [
                                    {offset: 0, color: '#1778c3'},
                                    {offset: 1, color: '#2bb3d5'}

                                ]
                            ),
                            label : {show: true,}
                        }
                    },
                    barCategoryGap: '50%',
                }
            ]
        };
        myCharts.setOption(option);
        var regionProvince=$("#province-id").val();
        //获取广告月度观看
        $.ajax({
            url     :   '/statistics/data/cockpit/statisticsAdWatchCountChartByDateType',
            type:'POST',
            data:'dateType=0&regionProvince='+regionProvince,
            success :   function(result){
                var data=result.data;
                if(result.code=="200"&&data){
                    var dataArray=new Array();
                     var date=new Date();
                    var currentMonth=date.getMonth()+1;
                    //12个月份
                    for(var i=1;i<13;i++){
                        for( var z in data){
                            var month=data[z].month;
                            var adWatchCount=data[z].adWatchCount;
                            if(month==i){
                                if(i==currentMonth){
                                    dataArray[i-1]={
                                        value:adWatchCount,
                                        itemStyle: {

                                            color: new echarts.graphic.LinearGradient(
                                                0, 1, 0, 0,
                                                [
                                                    {offset: 0, color: '#1778c3'},
                                                    {offset: 1, color: '#d0826e'}

                                                ]
                                            ),
                                        }
                                    };
                                }else{
                                    dataArray[i-1]=adWatchCount;
                                }

                            }else{
                                dataArray[i-1]=0;
                            }
                        }
                    }
                    //初始化图形数据
                    myCharts.setOption({
                        series: [
                            {
                                data: dataArray
                            }
                        ]
                    });
                }
            }
        });

    }


   //广告类别观看分布
    var myCharts1 = echarts.init(document.getElementById('ad-classify'), myEchartsTheme);
    function adWatchAdType(){
        var colorList = ['#7c93eb', '#c4a2b9', '#ebd2cc'];
        var option1 = {
            tooltip: {},
            grid: {
                left: '0',
                top: '0',
                right:'0',
                bottom: '20',
                containLabel: true
            },
            series: [{
                type: 'wordCloud',
                gridSize: 12,

                sizeRange: [15, 45],
                rotationRange: [0, 0],
                shape: 'circle',
                textStyle: {
                    normal: {
                        color: function (v) {

                            if (v.value > 2000) {
                                //alert(v.value)
                                return colorList[0];
                            } else if (v.value > 1000) {
                                return colorList[1];
                            } else {
                                return '#278fb7';
                            }
                        },
                    },
                    emphasis: {
                        shadowBlur: 10,
                        shadowColor: '#333'
                    }
                },

                data: []
            }]
        };
        myCharts1.setOption(option1);
        var regionProvince=$("#province-id").val();
        //获取广告类别观看量
        $.ajax({
            url     :   '/statistics/data/cockpit/statisticsAdWatchRankForAdType',
            type:'POST',
            data:'regionProvince='+regionProvince,
            success :   function(result){
                var dataArray=new Array();
                var data=result.data;
                if(result.code=="200"&&data){
                    for(var i in data){
                        if(i==0){
                            dataArray[i]={'name':data[i].adTypeName,
                                value: data[i].adWatchCount,textStyle: {
                                    normal: {
                                        color: '#be6ce6'
                                    },
                                    emphasis: {
                                        color: '#4995d0'
                                    }
                                }}
                        }else{
                            dataArray[i]={'name':data[i].adTypeName,value: data[i].adWatchCount}
                        }

                    }
                    myCharts1.setOption({
                        series: [{
                            data:dataArray
                        }]
                    });
                }
            }
        });
    }


    //广告观看量TOP10城市
    var myCharts2 = echarts.init(document.getElementById('watch-ranking'));
    function adWatchCityRankTopTen(){
        var category =[];
        var barData =[]
        var option2 = {
            tooltip: {
                // trigger: 'axis',
                // axisPointer: {
                //     type: 'shadow'
                // }
            },
            grid: {
                left: '3%',
                right: '4%',
                top: '0%',
                containLabel: true
            },


            xAxis: {
                type: 'value',
                'show':false,
                axisLine: {
                    show: false,
                    lineStyle: {
                        color: '#d6e0dc'
                    }
                },

                axisTick: {
                    show: false
                },
                splitLine: {
                    show: false,

                },

            },
            yAxis: {
                type: 'category',
                data: category,
                splitLine: {show: false},
                axisLine: {
                    show: false, //隐藏y轴
                    lineStyle: {
                        color: 'rgba(125,132,255,0.15)' //坐标轴的颜色
                    }
                },
                axisTick: {
                    show: false
                },
                axisLabel: {
                    textStyle: {
                        color: '#d6e0dc',//坐标值的具体的颜色
                    },

                },
                offset: 10,
                nameTextStyle: {
                    fontSize: 15
                }
            },
            series: [
                {
                    name: '次数',
                    type: 'bar',
                    data: barData,
                    barWidth: 14,
                    barGap: 10,
                    smooth: true,
                    label: {
                        normal: {
                            show: true,
                            position: 'right', //数值的位置
                            offset: [-20, 0],
                            textStyle: {
                                color: '#d6e0dc',
                                fontSize: 12
                            }
                        }
                    },

                    itemStyle: {

                        normal: {
                            barBorderRadius: [3, 3, 3, 3],
                            color: new echarts.graphic.LinearGradient(
                                0, 0, 1, 0,
                                [
                                    {offset: 0, color: '#1778c3'},
                                    {offset: 1, color: '#2bb3d5'}

                                ]
                            )
                        }
                    }
                }
            ]
        };
        myCharts2.setOption(option2);
        var regionProvince=$("#province-id").val();
        //获取城市观看量
        $.ajax({
            url     :   '/statistics/data/cockpit/statisticsAdWatchRankForArea',
            type:'POST',
            data:'areaType=1&regionProvince='+regionProvince,
            success :   function(result){
                var data=result.data;
                if(result.code=="200"&&data){
                    var category2=new Array(data.length);
                    var barData2=new Array(data.length);
                    var z=0;
                    for(var i=(data.length-1);i>=0;i--){
                        var watchData=data[i];
                        var area=watchData.area;
                        category2[z]=area;
                        var adWatchCount=watchData.adWatchCount;
                        barData2[z]=adWatchCount;
                        if(z==(data.length-1)){
                            barData2[z]={value:adWatchCount,
                                itemStyle: {
                                color: new echarts.graphic.LinearGradient(
                                    0, 0, 1, 0,
                                    [
                                        {offset: 0, color: '#1778c3'},
                                        {offset: 1, color: '#d0826e'}
                                    ]
                                ),
                            }}
                        }else{
                            barData2[z]=adWatchCount;
                        }
                        z++;
                    }
                    myCharts2.setOption({
                        yAxis: {
                            data: category2
                        },
                        series: [
                            {
                                name: '次数',
                                type: 'bar',
                                data: barData2
                            }]
                    });
                }
            }
        });
    }

    // 广告每日观看趋势
    var myCharts3 = echarts.init(document.getElementById('data-view'), myEchartsTheme);
    function adWatchDay() {
        //获取当月天数
        var dayArray=new Array();
        var dataArray=new Array();
        var currentDate=new Date();
        var dayCount=layui.laydate.getEndDate(currentDate.getMonth()+1, currentDate.getFullYear());
        for(var i=1;i<=dayCount;i++){
            dayArray[i-1]=i;
            dataArray[i-1]=0;
        }
        var option3 = {
            title: {
                text: '广告每日观看趋势',
                // subtext: '销售面积区间',
                x: 'center',
                y:'0',
                textStyle: {
                    color: 'rgb(44, 169, 225)',
                    fontSize: 14
                }
            },
            grid: {
                left: '10',
                top: '30',
                right:'0',
                bottom: '30',
                containLabel: true
            },
            tooltip: {
                trigger: "axis",
                formatter: "{b}<br>观看次数趋势：{c}",

            },
            calculable: true,
            xAxis: [{
                type: "category",
                axisLine: {
                    lineStyle: {
                        color: 'rgba(125,132,255,0.15)' //坐标轴的颜色
                    }
                },

                axisLabel: {
                    textStyle: {
                        color: '#d6e0dc',//坐标值得具体的颜色
                    },

                },
                axisPointer: {
                    snap: true,
                    lineStyle: {
                        color: '#666',
                        opacity: 0.5,
                        width: 1
                    },

                },
                data: dayArray,
            }],
            yAxis: [{
                type: "value",
                name:"观看次数",

                nameTextStyle:{
                    color:"#d6e0dc",

                },
                splitArea:{show:false},
                axisLine: {
                    show: true, //隐藏y轴
                    lineStyle: {
                        color: 'rgba(125,132,255,0.15)' //坐标轴的颜色
                    }
                },

                axisLabel: {
                    textStyle: {
                        color: '#d6e0dc',//坐标值得具体的颜色
                    },

                },
                splitLine: {
                    show: false,

                }
            }],
            series: [{
                type: "line",
                data: dataArray,
                itemStyle: { normal: { color: "#015b6a",label : {show: true,textStyle:{color:'#d6e0dc'}} }, },
                areaStyle: {
                    normal: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: 'rgba(0, 216, 135, 0.2)'
                        }, {
                            offset: 0.8,
                            color: 'rgba(0, 216, 135, 0.1)'
                        }], false),
                        shadowColor: 'rgba(0, 0, 0, 0.1)',
                    }
                },
            }]

        }
        myCharts3.setOption(option3);
        var regionProvince=$("#province-id").val();
        //获取广告今日观看量
        $.ajax({
            url     :   '/statistics/data/cockpit/statisticsAdWatchCountChartByDateType',
            type:'POST',
            data:'dateType=1&regionProvince='+regionProvince,
            success :   function(result){
                var data=result.data;
                if(result.code=="200"&&data){
                    //某月每天
                    for(var i in dataArray){
                        var dayChart=Number(i)+1;
                        for( var z in data){
                            var day=data[z].day;
                            var adWatchCount=data[z].adWatchCount;
                            if(day==dayChart){
                                    dataArray[i]=adWatchCount;
                            }
                        }
                    }
                    if(dataArray.length>0){
                        //初始化图形数据
                        myCharts3.setOption({
                            series: [
                                {
                                    data: dataArray
                                }
                            ]
                        });
                    }
                }
            }
        });

    }

    //地图
    var myCharts4 = echarts.init(document.getElementById('earth_echar'));
    function adPushMap(){
        var geoCoordMap = {
            "新疆":[84.9023,41.748],
            "西藏":[88.7695,31.6846],
            "内蒙古":[117.5977,44.3408],
            "青海":[96.2402,35.4199],
            "四川":[102.9199,30.1904],
            "黑龙江":[128.1445,48.5156],
            "甘肃":[95.7129,40.166],
            "云南":[101.8652,25.1807],
            "广西":[108.2813,23.6426],
            "湖南":[111.5332,27.3779],
            "陕西":[109.5996,35.6396],
            "广东":[113.4668,22.8076],
            "吉林":[126.4746,43.5938],
            "河北":[115.4004,37.9688],
            "湖北":[112.2363,31.1572],
            "贵州":[106.6113,26.9385],
            "山东":[118.7402,36.4307],
            "江西":[116.0156,27.29],
            "河南":[113.4668,33.8818],
            "辽宁":[122.3438,41.0889],
            "山西":[112.4121,37.6611],
            "安徽":[117.2461,32.0361],
            "福建":[118.3008,25.9277],
            "浙江":[120.498,29.0918],
            "江苏":[120.0586,32.915],
            "重庆":[107.7539,30.1904],
            "宁夏":[105.9961,37.3096],
            "海南":[109.9512,19.2041],
            "台湾":[121.0254,23.5986],
            "北京":[116.4551,40.2539],
            "天津":[117.4219,39.4189],
            "上海":[121.4648,31.2891],
            "香港":[114.2578,22.3242],
            "澳门":[113.5547,22.1484]
        }
        var data = [];
        var max = 1000000,
            min = 900; // todo
        var maxSize4Pin = 80,
            minSize4Pin = 40;

        var convertData = function(data) {
            var res = [];
            for (var i = 0; i < data.length; i++) {
                var geoCoord = geoCoordMap[data[i].name];
                if (geoCoord&&data[i].value>0) {
                    res.push({
                        name: data[i].name,
                        value: geoCoord.concat(data[i].value)
                    });
                }
            }
            return res;
        };

        var option4 = {
            title: {
                text: '广告分布区域',
                // subtext: '销售面积区间',
                x: 'center',
                y:'10',
                textStyle: {
                    color: 'rgb(44, 169, 225)',
                    fontSize: 14
                }
            },
            grid: {
                left: '0',
                right: '0',
                top:'0',
                bottom:'0',
                containLabel: true
            },
            legend: {
                orient: 'vertical',
                left: 'left',

            },
            tooltip: {
                trigger: 'item',
                formatter: function(params) {
                   if (typeof(params.value)[2] == "undefined") {
                       if(params.value){
                           return params.name + ' : ' + params.value;
                       }else{
                           return '';
                       }

                    } else {
                        return params.name + ' : ' + params.value[2];
                    }
                }
            },
            legend: {
                orient: 'vertical',
                y: 'bottom',
                x: 'right',
                data: ['sell_area'],
                textStyle: {
                    color: '#fff'
                }
            },
            visualMap: {
                show: false,
                min: 0,
                max: 500,
                left: 'left',
                top: 'bottom',
                text: ['高', '低'], // 文本，默认为数值文本
                calculable: true,
                seriesIndex: [1],
                inRange: {
                    // color: ['#3B5077', '#031525'] // 蓝黑
                    // color: ['#ffc0cb', '#800080'] // 红紫
                    // color: ['#3C3B3F', '#605C3C'] // 黑绿
                    color: '#197ec4' // 黑紫黑
                    // color: ['#23074d', '#cc5333'] // 紫红
                    // color: ['#00467F', '#A5CC82'] // 蓝绿
                    // color: ['#1488CC', '#2B32B2'] // 浅蓝
                    // color: ['#00467F', '#A5CC82'] // 蓝绿
                    // color: ['#00467F', '#A5CC82'] // 蓝绿
                    // color: ['#00467F', '#A5CC82'] // 蓝绿
                    // color: ['#00467F', '#A5CC82'] // 蓝绿
                }
            },
            geo: {
                show: true,
                map: 'china',
                label: {
                    normal: {
                        show: false
                    },
                    emphasis: {
                        show: false,
                    }
                },
                roam: true,
                itemStyle: {
                    normal: {
                        areaColor: '#a9cef0',
                        borderColor: '#3B5077',
                        borderWidth: 1,
                        borderColor: '#051940',
                    },
                    emphasis: {
                        areaColor: '#197ec4',
                    }
                }
            },
            series: [{
                name: 'credit_pm2.5',
                type: 'scatter',
                coordinateSystem: 'geo',
                data: convertData(data),
                symbolSize: function(val) {
                    return val[2] / 10000;
                },
                label: {
                    normal: {
                        formatter: '{b}',
                        position: 'right',
                        show: true
                    },
                    emphasis: {
                        show: true
                    },

                },
                itemStyle: {
                    normal: {
                        color: '#fff'
                    }
                }
            },
                {
                    type: 'map',
                    map: 'zhongguo',
                    geoIndex: 0,
                    aspectScale: 1, //长宽比
                    showLegendSymbol: false, // 存在legend时显示
                    label: {
                        normal: {
                            show: false
                        },
                        emphasis: {
                            show: false,
                            textStyle: {
                                color: '#fff'
                            }
                        }
                    },
                    roam: true,
                    itemStyle: {
                        normal: {
                            areaColor: '#031525',
                            borderColor: '#3B5077',
                        },
                        emphasis: {
                            areaColor: '#2B91B7'
                        }
                    },
                    animation: false,
                    data: data
                },
                {
                    name: '点',
                    type: 'scatter',
                    coordinateSystem: 'geo',
                    symbol: 'pin',
                    symbolSize: function(val) {
                        return 40;
                    },
                    label: {
                        normal: {
                            formatter: '{@[2]}',
                            show: true,
                            textStyle: {
                                color: '#fff',
                                fontSize: 9,
                            }
                        }
                    },
                    itemStyle: {
                        normal: {
                            color: '#F62157', //标志颜色
                        }
                    },
                    zlevel: 6,
                    data: convertData(data),
                },
                {
                    name: 'Top 5',
                    type: 'effectScatter',
                    coordinateSystem: 'geo',
                    data: convertData(data.sort(function(a, b) {
                        return b.value - a.value;
                    }).slice(0, 1)),
                    symbolSize: function(val) {
                        return 15;
                    },
                    showEffectOn: 'render',
                    rippleEffect: {
                        brushType: 'stroke'
                    },
                    hoverAnimation: true,
                    label: {
                        normal: {
                            formatter: '{b}',
                            position: 'right',
                            show: false,

                        }
                    },
                    itemStyle: {
                        normal: {
                            color: '#F62157',
                            shadowBlur: 10,
                            shadowColor: '#F62157'
                        }
                    },
                    zlevel: 1
                },

            ]
        };
        var regionProvinceTemp="";
        myCharts4.setOption(option4);
       //获取省份投放量
        $.ajax({
            url     :   '/statistics/data/cockpit/statisticsAdPushAndExposureByArea',
            type:'POST',
            success :   function(result){
                var dataResult=result.data;
                if(result.code=="200"&&dataResult){
                    for(var i in dataResult){
                        var watchData=dataResult[i];
                        var area=watchData.area;
                        var adExposureCount=watchData.adExposureCount;
                        data[i]={'name':area,'value':adExposureCount,'regionProvince':watchData.regionProvince};
                    }
                    myCharts4.setOption({
                        series: [{
                            name: 'credit_pm2.5',
                            type: 'scatter',
                            coordinateSystem: 'geo',
                            data: convertData(data),
                            symbolSize: function(val) {
                                return val[2] / 10000;
                            },
                            label: {
                                normal: {
                                    formatter: '{b}',
                                    position: 'right',
                                    show: true
                                },
                                emphasis: {
                                    show: true
                                },

                            },
                            itemStyle: {
                                normal: {
                                    color: '#fff'
                                }
                            }
                        },
                            {
                                type: 'map',
                                map: 'zhongguo',
                                geoIndex: 0,
                                aspectScale: 1, //长宽比
                                showLegendSymbol: false, // 存在legend时显示
                                label: {
                                    normal: {
                                        show: false
                                    },
                                    emphasis: {
                                        show: false,
                                        textStyle: {
                                            color: '#fff'
                                        }
                                    }
                                },
                                roam: true,
                                itemStyle: {
                                    normal: {
                                        areaColor: '#031525',
                                        borderColor: '#3B5077',
                                    },
                                    emphasis: {
                                        areaColor: '#2B91B7'
                                    }
                                },
                                animation: false,
                                data: data
                            },
                            {
                                name: '点',
                                type: 'scatter',
                                coordinateSystem: 'geo',
                                symbol: 'pin',
                                symbolSize: function(val) {
                                    return 40;
                                },
                                label: {
                                    normal: {
                                        formatter: '{@[2]}',
                                        show: true,
                                        textStyle: {
                                            color: '#fff',
                                            fontSize: 9,
                                        }
                                    }
                                },
                                itemStyle: {
                                    normal: {
                                        color: '#F62157', //标志颜色
                                    }
                                },
                                zlevel: 6,
                                data: convertData(data),
                            },
                            {
                                name: 'Top 5',
                                type: 'effectScatter',
                                coordinateSystem: 'geo',
                                data: convertData(data.sort(function(a, b) {
                                    return b.value - a.value;
                                }).slice(0, 1)),
                                symbolSize: function(val) {
                                    return 15;
                                },
                                showEffectOn: 'render',
                                rippleEffect: {
                                    brushType: 'stroke'
                                },
                                hoverAnimation: true,
                                label: {
                                    normal: {
                                        formatter: '{b}',
                                        position: 'right',
                                        show: false,

                                    }
                                },
                                itemStyle: {
                                    normal: {
                                        color: '#F62157',
                                        shadowBlur: 10,
                                        shadowColor: '#F62157'
                                    }
                                },
                                zlevel: 1
                            },

                        ]
                    });

                }
            }
        });
        //地图点击事件
        myCharts4.on("click",function (params) {
            if(params.name){
                if(regionProvinceTemp!=params.name){
                    //获取省份
                    for(var i in data){
                        var provinceName= data[i].name;
                        if(params.name==provinceName){
                            regionProvinceTemp=provinceName;
                            $("#province-id").val( data[i].regionProvince);
                        }
                    }
                    statisticsInit();
                }
            }else{
                if(regionProvinceTemp){
                    regionProvinceTemp="";
                    $("#province-id").val("");
                    statisticsInit();
                }
            }
        });
    }

    // 窗口大小改变事件
    window.addEventListener("resize", function () {
        myCharts.resize();
        myCharts1.resize();
        myCharts2.resize();
        myCharts3.resize();
        myCharts4.resize();

    });

    var myMarhq = '';
    //广告观看明细
   function adWatchRank() {
       var regionProvince=$("#province-id").val();
       $.ajax({
           url     :   '/statistics/data/cockpit/statisticsAdWatchRank',
           type:'POST',
           data:'regionProvince='+regionProvince,
           success :   function(result){
               $('.tbl-body tbody').empty();
               $('.tbl-header tbody').empty();
               var data=result.data;
               if(result.code=="200"&&data){
                   for(var i in data){
                       var item=data[i];
                       i=Number(i)+1;
                      var str = '<tr>'+
                           '<td>'+i+'</td>'+
                           '<td>'+item.adName+'</td>'+
                           '<td>'+item.adTypeName+'</td>'+
                           '<td>'+item.watchCount+'</td>'+

                           '</tr>'

                       $('.tbl-body tbody').append(str);
                       $('.tbl-header tbody').append(str);
                   }
               }
               if(data.length > 10){
                   $('.tbl-body tbody').html($('.tbl-body tbody').html()+$('.tbl-body tbody').html());
                   $('.tbl-body').css('top', '0');
                   var tblTop = 0;
                   var speedhq = 50; // 数值越大越慢
                   var outerHeight = $('.tbl-body tbody').find("tr").outerHeight();
                   function Marqueehq(){
                       if(tblTop <= -outerHeight*data.length){
                           tblTop = 0;
                       } else {
                           tblTop -= 1;
                       }
                       $('.tbl-body').css('top', tblTop+'px');
                   }
                   //清除之前任务
                   clearInterval(myMarhq);
                   myMarhq = setInterval(Marqueehq,speedhq);
                   // 鼠标移上去取消事件
                   $(".tbl-header tbody").hover(function (){
                       clearInterval(myMarhq);
                   },function (){
                       clearInterval(myMarhq);
                       myMarhq = setInterval(Marqueehq,speedhq);
                   })
               }else{
                   clearInterval(myMarhq);
                    //取消绑定hover事件
                   $(".tbl-header tbody").off('mouseenter').unbind('mouseleave');
                   $('.tbl-body').css('top', '0px');
               }
           }
       });

    }

    //广告类别 广告投放 广告观看 本周观看 上周观看数量
    function statisticsCount(){
        var regionProvince=$("#province-id").val();
        $.ajax({
            url     :   '/statistics/data/cockpit/adDataCockpitCount',
            type:'POST',
            data:'regionProvince='+regionProvince,
            success :   function(result){
                if(result.code=="200"&&result.data){
                    $("#ad-type-count").text(result.data.adTypeCount);
                    $("#ad-exposure-count").text(result.data.adExposureCount);
                    $("#ad-watch-count").text(result.data.adWatchCount);
                    $("#ad-watch-count-day-week").text(result.data.adWatchCountDayOfWeek);
                    $("#ad-watch-count-day-last-week").text(result.data.adWatchCountDayOfLastWeek);
                }
            }
        });
    }

    //数据初始化
    function  statisticsInit() {
        //广告类别 广告投放 广告观看 本周观看 上周观看数量
        statisticsCount();
        //广告观看量TOP10城市
        adWatchCityRankTopTen();
        // 广告观看明细
        adWatchRank();
        //广告月度观看趋势
        adWatchMonth();
        //广告每日观看趋势
        adWatchDay();
        //广告类别观看分布
        adWatchAdType();
    };

    //全屏模式
    $(".screen-btn").click(function(){
        var parentDocument=window.parent.document;
            $(parentDocument).find("iframe").attr("allowFullScreen",true);
        //全屏
        var docElm = document.documentElement;
        if($(this).find('i').hasClass('reduce')){
            $(this).find('i').removeClass('reduce').attr('title','全屏');

            if (window.ActiveXObject)
            {
                iefull();
            }else{
                exitScreen();
            }

        }else{
            $(this).find('i').addClass('reduce').attr('title','退出全屏');
            if (window.ActiveXObject)
            {
                iefull();
            }else{
                fullScreen();
            }
        }
    });

    //初始化
    (function(){
        //数据初始化
        statisticsInit();
        //广告发布区域
        adPushMap();
    })();
});
function fullScreen(){
    var el = document.documentElement;
    var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullscreen;
    if(typeof rfs != "undefined" && rfs) {
        rfs.call(el);
    };
    return;
}
//退出全屏
function exitScreen(){
    if (document.exitFullscreen) {
        document.exitFullscreen();
    }
    else if (document.mozCancelFullScreen) {
        document.mozCancelFullScreen();
    }
    else if (document.webkitCancelFullScreen) {
        document.webkitCancelFullScreen();
    }
    else if (document.msExitFullscreen) {
        document.msExitFullscreen();
    }
    if(typeof cfs != "undefined" && cfs) {
        cfs.call(el);
    }
}
//ie低版本的全屏，退出全屏都这个方法
function iefull(){
    var el = document.documentElement;
    var rfs = el.msRequestFullScreen;
    if(typeof window.ActiveXObject != "undefined") {
        //这的方法 模拟f11键，使浏览器全屏
        var wscript = new ActiveXObject("WScript.Shell");
        if(wscript != null) {
            wscript.SendKeys("{F11}");
        }
    }
}