function showZmdsp(data,i,project,projectName,ccUrl){
var ad_pos = project+"_tips_1"
// 展盟dsp精准
var currentIndex = i;
if(data.script[i].content){
var sspConfig = JSON.parse(data.script[i].content);
var zmDsp = {
index:ProjectConfig.GetQueryString('product_category') || '48',
project:ProjectConfig.GetQueryString('project') || project,
tck:ProjectConfig.GetQueryString('tck') || ""
// tck:ProjectConfig.GetQueryString('tck') || "C977D0BBEE6B17C5E795BED36686097526F885BF79C84C6D0CEAC3A3F402CD10"
};
window.uploadConfig = {
act:'load',
ad_id:data.baidu_id,
ad_pos:ad_pos,
ad_type:'dsp_zm',
strategy_id:data.script[i].strategy_id,
idea_id:data.script[i].idea_id,
plan_id:data.script[i].plan_id,
product_category:data.script[i].product_category
};
var url = sspConfig.url+"?v="+new Date().getTime();
render = false;
$.ajax({
url: url,
type: 'get',
data: zmDsp,
dataType: 'json',
success: function (obj) {
if(obj.code == 0){
// 一大三小
if(obj.result.idea_type == 4){
var idea = obj.result.idea || "";
if(idea){
$('.container').css({"width":"370px","height":"400px"});
var dom = '
' +
''+projectName+'-广告'+
'' +
'' +
'' +
'' +
'' +
'' +
'';
$('.container').append(dom);
var next = 1;
for(var i =0;i< 3;i++){
uploadConfig.act = 'show';
uploadConfig.ad_pos = ad_pos+'_'+ (i+1);
uploadZhike(uploadConfig);
}
$('.close1').on('click', function () {
uploadConfig.act = 'click';
uploadConfig.ad_pos = ad_pos+'_'+next;
$('.panel > a').removeClass('active');
switch(next){
case 1:
next = 2;
window.open(idea.landing_page)
$('.close1 img').attr('src',idea['main_img_2']);
break;
case 2:
next = 3;
window.open(idea.landing_page_2)
$('.close1 img').attr('src',idea['main_img_3']);
break;
case 3:
next = 1;
window.open(idea.landing_page_3)
$('.close1 img').attr('src',idea['main_img']);
break;
}
$(".close" + (next+1)).addClass('active');
uploadZhike(uploadConfig);
});
$('.close2').on('click', function () {
next = 2;
uploadConfig.act = 'click';
uploadConfig.ad_pos = ad_pos+'_1';
$('.panel > a').removeClass('active');
$('.close1 img').attr('src',idea.main_img_2);
$(".close3").addClass('active');
uploadZhike(uploadConfig);
});
$('.close3').on('click', function () {
next = 3;
uploadConfig.act = 'click';
uploadConfig.ad_pos = ad_pos+'_2';
$('.panel > a').removeClass('active');
$('.close1 img').attr('src',idea.main_img_3);
$(".close4").addClass('active');
uploadZhike(uploadConfig);
});
$('.close4').on('click', function () {
next = 1;
uploadConfig.act = 'click';
uploadConfig.ad_pos = ad_pos+'_3';
$('.panel > a').removeClass('active');
$('.close1 img').attr('src',idea.main_img);
$(".close2").addClass('active');
uploadZhike(uploadConfig);
});
$('head').append('');
if (typeof window.external != 'undefined' && typeof window.external.CppCall != 'undefined') {
window.external.CppCall("340,390");
}
}
}else{ //单图
var idea = obj.result.idea;
var readStatus = obj.result.readStatus || '';
var pageW = idea.main_img_w,pageH = idea.main_img_h;
$('.container').css({"width":pageW+"px","height":pageH+"px"});
var dom =' '+projectName+'-广告' +
'';
$('.container').append(dom);
uploadConfig.act = 'load';
uploadConfig.dspData = JSON.stringify(idea);
uploadZhike(uploadConfig);
var page_size = pageW+','+pageH;
uploadConfig.act = 'show';
uploadZhike(uploadConfig);
$('head').append('');
if (typeof window.external != 'undefined' && typeof window.external.CppCall != 'undefined') {
window.external.CppCall(page_size);
}
$('.dsp_ad').on('click', function () {
uploadConfig.act = 'click';
uploadConfig.dspData = JSON.stringify(idea);
uploadZhike(uploadConfig);
});
if(readStatus == 1){
// swpiw 1用阅读器打开
$('head').append('');
}else{
$('head').append('');
}
if (typeof window.external != 'undefined' && typeof window.external.CppCall != 'undefined') {
window.external.CppCall(page_size);
}
}
}else{
render = true;
var start = currentIndex + 1;
renderFunc(start,dataRes);
}
},
error:function () {
render = true;
var start = currentIndex + 1;
renderFunc(start,dataRes);
}
});
}
}
function RedirectCc(data,i,project,ccUrl){
var url = ccUrl.split("http://")[1];
var urlhost;
if(location.host == 'news.7654.com'){
urlhost ='prod/'+url.replace(/\//g,".");
}else{
urlhost = 'test/'+url.replace(/\//g,".");
}
var uploadUrl = '&ad_type=dsp_360' + '&ad_pos='+project+'_tips_1'+'&baidu_id='+ data.baidu_id +'&strategy_id='+data.script[i].strategy_id+'&idea_id='+data.script[i].idea_id+'&plan_id='+data.script[i].plan_id+'&product_category='+data.script[i].product_category;
var openUrl = ccUrl+"?"+ location.search.split('?')[1] + uploadUrl;
$.ajax({
url:'http://ads.7654.com/'+urlhost+'.json?v='+new Date().getTime(),
type:'get',
dataType:'json',
success:function(res){
currentOpen = openUrl + '&i='+res.i+'&w='+res.w+'&h='+res.h;
window.external.RedirectUrl(currentOpen);
},
error:function(){
window.external.RedirectUrl(openUrl);
}
})
}
function RedirectCc2(data,i,project,ccUrl){
var url = ccUrl.split("http://")[1];
var urlhost;
if(location.host == 'news.7654.com'){
urlhost ='prod/'+url.replace(/\//g,".");
}else{
urlhost = 'test/'+url.replace(/\//g,".");
}
var uploadUrl = '&ad_type=dsp_360' + '&ad_pos='+project+'_tips_2'+'&baidu_id='+ data.baidu_id +'&strategy_id='+data.script[i].strategy_id+'&idea_id='+data.script[i].idea_id+'&plan_id='+data.script[i].plan_id+'&product_category='+data.script[i].product_category;
var openUrl = ccUrl+"?"+ location.search.split('?')[1] + uploadUrl;
$.ajax({
url:'http://ads.7654.com/'+urlhost+'.json?v='+new Date().getTime(),
type:'get',
dataType:'json',
success:function(res){
currentOpen = openUrl + '&i='+res.i+'&w='+res.w+'&h='+res.h;
window.external.RedirectUrl(currentOpen);
},
error:function(){
window.external.RedirectUrl(openUrl);
}
})
}