function loadDspAd(e) {
if(renderStatus == 0){
uploadConfig.act = 'songheng_'+e.data.length;
uploadZhike(uploadConfig);
if (e.data && e.data.length > 0) {
var sh_data = e.data[0];
if( sh_data.adtype && sh_data.miniimg.length > 0){ //广告类型adtype及图片资源miniimg是否存在
if(sh_data.adtype == 103){ //四图
if(sh_data.miniimg.length == 4){
renderFour(sh_data);
}else{
renderDsp(sh_data); //返回接口存在广告类型adtype及图片资源miniimg但类型为非4图取第一张图片资源
}
}else if(sh_data.adtype == 104){ //大图 450*375px
renderDsp(sh_data,"450px");
}else{ //未接入类型顺位
render = true;
var start = currentIndex + 1;
renderFunc(start,dataRes);
}
}else{ //数据异常顺位
// checkShdsp();
render = true;
var start = currentIndex + 1;
renderFunc(start,dataRes);
}
} else { // 数据为空顺位
// checkShdsp();
render = true;
var start = currentIndex + 1;
renderFunc(start,dataRes);
}
}
};
function renderDsp(data,page_w){
$('.container').empty();
uploadConfig.act = 'load';
uploadZhike(uploadConfig);
$('.container').append('
'+uploadConfig.project_cn+'-广告由嵩恒广告提供');
$('.image-wrapper > img')[0].src = data.miniimg[0].src;
$('.image-wrapper')[0].href = data.url;
document.getElementById("ak0").onerror = function () {
// checkShdsp();
ProjectConfig.loadBase();
};
document.getElementById("ak0").onload = function () {
if(page_w){
$(".container").css({"width":page_w});
}
var page_size_w = document.getElementById('ak0').offsetWidth;
var page_size_h = document.getElementById('ak0').offsetHeight;
var page_size = page_size_w+"," + page_size_h;
$(".container").css({"width":page_size_w,"height":page_size_h});
if(dataRes.script[currentIndex].mini_reader == 1){
// swpiw 1用阅读器打开
$('head').append('');
}else{
$('head').append('');
}
if (typeof window.external != 'undefined' && typeof window.external.CppCall != 'undefined') {
window.external.CppCall(page_size);
}
// 渲染
ProjectConfig.uploadUrl(data.showbackurls[0]);
uploadConfig.act = 'show';
uploadZhike(uploadConfig);
// window.external.ClearRequestCount();
};
//进入可视区s域上报
if (data.isinviewbackurl) {
ProjectConfig.uploadUrl(data.inviewbackurls[0]);
}
//关闭上报
$('.close').on('click', function () {
ProjectConfig.uploadUrl(data.closebackurls[0])
});
//点击上报
$('.image-wrapper').on('click', function () {
ProjectConfig.uploadUrl(data.clickbackurls[0]);
uploadConfig.act = 'click';
uploadZhike(uploadConfig);
})
};
function renderFour(sh_data){
$('.container').empty();
uploadConfig.act = 'load';
uploadZhike(uploadConfig);
var topicArr = [];
if(sh_data.topic){
topicArr = sh_data.topic.split("&&");
}
var topicItem0 = topicArr[0] || "",topicItem1 = topicArr[1] || "",topicItem2 = topicArr[2] || "",topicItem3 = topicArr[3] || "";
$('.container').append(''
+' '
+''+uploadConfig.project_cn+'-广告由嵩恒广告提供'
+''
+''+topicItem0+'
'
+''+topicItem1+'
'
+''+topicItem2+'
'
+''+topicItem3+'
'
+'');
$('.image-wrapper')[0].href = sh_data.url;
var imgError = 0;
document.getElementById("ak").onerror = function () {
imgError ++;
if(imgError == 1){
// checkShdsp();
ProjectConfig.loadBase();
}
};
document.getElementById("ak1").onerror = function () {
imgError ++;
if(imgError == 1){
// checkShdsp();
ProjectConfig.loadBase();
}
};
document.getElementById("ak2").onerror = function () {
imgError ++;
if(imgError == 1){
// checkShdsp();
ProjectConfig.loadBase();
}
};
document.getElementById("ak3").onerror = function () {
imgError ++;
if(imgError == 1){
// checkShdsp();
ProjectConfig.loadBase();
}
};
var imgFlag = 0;
function popBox(){
var page_size = "655,481";
$(".container").css({"width":"655px","height":"481px"});
if(dataRes.script[currentIndex].mini_reader == 1){
// swpiw 1用阅读器打开
$('head').append('');
}else{
$('head').append('');
}
if (typeof window.external != 'undefined' && typeof window.external.CppCall != 'undefined') {
window.external.CppCall(page_size);
}
// 渲染
ProjectConfig.uploadUrl(sh_data.showbackurls[0]);
uploadConfig.act = 'show';
uploadZhike(uploadConfig);
// window.external.ClearRequestCount();
}
document.getElementById("ak").onload = function () {
imgFlag ++
if(imgFlag == 4 && imgError == 0){
popBox()
}
};
document.getElementById("ak1").onload = function () {
imgFlag ++
if(imgFlag == 4 && imgError == 0){
popBox()
}
};
document.getElementById("ak2").onload = function () {
imgFlag ++
if(imgFlag == 4 && imgError == 0){
popBox()
}
};
document.getElementById("ak3").onload = function () {
imgFlag ++
if(imgFlag == 4 && imgError == 0){
popBox()
}
};
//进入可视区s域上报
if (sh_data.isinviewbackurl) {
ProjectConfig.uploadUrl(sh_data.inviewbackurls[0]);
}
//关闭上报
$('.close').on('click', function () {
ProjectConfig.uploadUrl(sh_data.closebackurls[0])
});
//点击上报
$('.image-wrapper').on('click', function () {
ProjectConfig.uploadUrl(sh_data.clickbackurls[0]);
uploadConfig.act = 'click';
uploadZhike(uploadConfig);
})
}