

function request_param(paras) {
    var url = location.href;
    var paraString = url.substring(url.indexOf("?") + 1, url.length).split("#");
    paraString = paraString[0].split("&");
    var paraObj = {};
    var i, j;
    for (i = 0; j = paraString[i]; i++) {
        paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
    }
    var returnValue = paraObj[paras.toLowerCase()];
    if (typeof (returnValue) == "undefined") {
        return "";
    } else {
        return returnValue;
    }
}

//全局变量
var adsUrl = "https://gdg.gzdjy.org";
//广告站点ID
var seatid = 86;
   //视频图片广告ID
var videoadsid = 604;
//图片广告位ID
var imageadsid = 693;

//图片广告
function GetAdsImages() {
    var name = '#lilist';
 
    jQuery.support.cors = true;
    $.ajax({
        type: "POST",
        url: adsUrl + "/AdsService.asmx/GetAdListByIdToJson",
        data: "{'id': '" + imageadsid +
            "', 'siteId': '" + seatid + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        beforeSend: function () {
            //            $(name).empty();
            //            $("#divimg").empty();
        },
        success: function (g) {
            var f = $.parseJSON(g.d);

            if (f.errcode == 0) {



                var licontent = "";
                var imgcontent = "";
                for (var j = 0; j < f.ads.length; j++) {


                    var fileurl = f.ads[j].photourl;
                    var index = fileurl.lastIndexOf("/");

                    //                    alert(index);

                  //  var file = 'files/' + fileurl.substring(index + 1);

                    // alert(file);

                    if (j == 0) {
                        licontent += ' <li data-target="#carousel-example-generic" data-slide-to="' + j + '" class="active"></li>';
                        imgcontent += '<div class="item active">';
                    }
                    else {
                        licontent += ' <li data-target="#carousel-example-generic" data-slide-to="' + j + '"></li>';
                        imgcontent += '<div class="item">';
                    }


                    imgcontent += ' <a><img src="' + fileurl + '" width="1080" height="494"></a></div>';

                }

                //    alert(imgcontent);


                if (f.ads.length > 0) {

                    document.getElementById('lilist').innerHTML = licontent;
                    document.getElementById('divimg').innerHTML = imgcontent;


//                    //推送框架下载对应文件
//                    var state = window.external.downloadadsfiles(g.d, "adsimage");

//                    //                alert(state);
//                    if (state == "False") {
//                        document.getElementById('lilist').innerHTML = licontent;
//                        document.getElementById('divimg').innerHTML = imgcontent;
//                    }
//                    else {
//                        //等待下载完成刷新
//                    }
                }


            }

        },
        error: function (c) {
            alert(c);

        },

        complete: function () { }
    })
}


//视频广告
function GetAdsVideos() {
   
    jQuery.support.cors = true;
    $.ajax({
        type: "POST",
        url: adsUrl + "/AdsService.asmx/GetAdListByIdToJson",
        data: "{'id': '" + videoadsid +
            "', 'siteId': '" + seatid + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        beforeSend: function () {

        },
        success: function (g) {
            var f = $.parseJSON(g.d);

            if (f.errcode == 0) {


                var vedioArry = []; //设置播放视频列表数组

                for (var j = 0; j < f.ads.length; j++) {


                    var fileurl = f.ads[j].photourl;
                    var index = fileurl.lastIndexOf("/");

                    //                    alert(index);

                    var file = fileurl.substring(index + 1);

                    vedioArry.push(file);

                }



                //推送框架下载对应文件
                var state = window.external.downloadadsfiles(g.d, "adsvideo");

                //启动播放
//                var myVideo = document.getElementById("myVedio"); //通过js获取到vedio标签实例


////                alert(state);
//                if (state == "False") {

////                    alert(vedioArry.length);

//                    var arryNumber = 0; //设置默认播放位置，方便后面循环
//                    myVideo.addEventListener("ended", function () {//为vedio添加ended监听，当视频播放完毕后执行对应函数
//                        if (arryNumber == (vedioArry.length - 1)) { //判断是否到了最后一个视频
//                            myVideo.src = "files/" + vedioArry[0]; //播放第一个视频
//                            myVideo.play();
//                            arryNumber = 0; //将下标重设为 0
//                        } else {
//                            arryNumber += 1; //每播放一次则将下标加一
//                            myVideo.src = "files/" + vedioArry[arryNumber];
//                            myVideo.play();
//                        }
//                    });

//                } else {
//                    //等待下载完成刷新，循环当前播放
//                    myVideo.addEventListener("ended", function () {//为vedio添加ended监听，当视频播放完毕后执行对应函数
//                        myVideo.play();
//                    });


//                }


            }

        },
        error: function (c) {
            alert(c);

        },

        complete: function () { }
    })
}


//获取当前用户全局变量
var propertyAds = window.external.getadsproperty();

var propertyAdsArray = propertyAds.split(",");

//服务域名
adsUrl = propertyAdsArray[0];
//广告站点ID
seatid = propertyAdsArray[1]; ;
//视频图片广告ID
 var videoadsid = propertyAdsArray[2]; 
//图片广告位ID
 imageadsid = propertyAdsArray[3]; 

GetAdsImages();

GetAdsVideos();