// zhike样式判定
function zhikeRender(data,i,product_category_url){
//4 为一大三小的样式模板,上报在模板里
if(data.script[i].idea_type == 4){
loadZhikeOT(data,i);
}else if(data.script[i].idea_type == 19){ //两图横排
var specialList = getSpecialList(data,i,product_category_url);
loadZhikeTwo(data,specialList)
}else if(data.script[i].idea_type == 20){ //三图横排
var specialList = getSpecialList(data,i,product_category_url);
loadZhikeThree(data,specialList)
}else if(data.script[i].idea_type == 21){ //四图横排
var specialList = getSpecialList(data,i,product_category_url);
loadZhikeFourCol(data,specialList);
}else if(data.script[i].idea_type == 22){ //四宫格
var specialList = getSpecialList(data,i,product_category_url);
loadZhikeFourP(data,specialList);
}else if(data.script[i].idea_type == 23){ //轮播
var specialList = getSpecialList(data,i,product_category_url);
loadZhikeLoop(data,specialList);
}else if(data.script[i].idea_type ==29||data.script[i].idea_type ==30){ //轮播
var pinList = getPinList(data,i,product_category_url);
loadZhikePin(data,pinList);
}else{ //单图
var specialList = [];
specialList.push(data.script[i]);
loadZhikeOne(data,specialList);
}
}
// 数据筛选
function getSpecialList(data,i,product_category){
var arr = [];
for(var j = i; j < data.script.length;j ++){
if (data.script[j].product_category == product_category && data.script[j].idea_type == data.script[i].idea_type) {
arr.push(data.script[j]);
}
}
return arr;
}
// 数据筛选PIN
function getPinList(data,i,product_category){
var arrPin=[]
for(var j = i; j < data.script.length;j ++){
if(data.script[j].product_category == product_category){
if(data.script[j].idea_type==29){
arrPin.unshift(data.script[j]);
}else if(data.script[j].idea_type==30){
arrPin.push(data.script[j]);
}
}
}
return arrPin;
}
//单图
function loadZhikeOne(data,specialList){
window.uploadConfig = {
act:'load',
ad_id:data.baidu_id,
ad_pos:project_ad_pos+'_tips_1',
ad_type:'zhike',
strategy_id:specialList[0].strategy_id,
idea_id:specialList[0].idea_id,
plan_id:specialList[0].plan_id,
product_category:specialList[0].product_category
};
//加载
uploadConfig.act = 'load';
uploadZhike(uploadConfig);
$('.container').css({"height":"250px"});
var bg_img= specialList[0].idea.float_layer_img|| "";
var project_browser=ProjectConfig.GetQueryString('browser')||ProjectConfig.getBrowser();
$('.container').append('
'+projectName+'-广告');
var bg_color = specialList[0].idea.bg_color || "";
var po_x = specialList[0].idea.close_button_x || '';
var po_y = specialList[0].idea.close_button_y || '';
$('.close').css({"right":po_x + 'px',"top":po_y + 'px'})
var font_color = specialList[0].idea.font_color || "";
if(bg_color){$(".ad").css({"background":bg_color});}
if(font_color){$(".ad").css({"color":font_color});}
if(bg_img&&(project_browser=="IE10"||project_browser=="IE11")){
$(".container").append('')
var num=0;
$(".container").hover(function(){
num++;
if(num==1){
uploadConfig.act = 'float_show';
uploadZhike(uploadConfig);
}
$(".float_img").removeClass("float_slideOut");
$(".float_img").addClass("float_slideIn");
},function(){
$(".float_img").removeClass("float_slideIn");
$(".float_img").addClass("float_slideOut");
}
)
}
render = false;
if(specialList[0].mini_reader == 1){
// swpiw 1用阅读器打开
$('head').append('');
}else{
$('head').append('');
}
if (typeof window.external != 'undefined' && "SetLayout" in window.external) {
var rows = 1, //行数
columns = 1, //列数
row_space = 0, //行间距
column_space = 0, //列间距
status = 1;
window.external.SetLayout(rows,columns,row_space,column_space,status);
}
if (typeof window.external != 'undefined' && "CppCall" in window.external) {
window.external.CppCall();
}
$('#ak').on('click',function () {
uploadConfig.act = 'click';
uploadZhike(uploadConfig);
});
$('.float_img').on('click',function () {
uploadConfig.act = 'float_click';
uploadZhike(uploadConfig);
});
uploadConfig.act = 'show';
uploadZhike(uploadConfig);
}
//两图
function loadZhikeTwo(data,specialList){
if (specialList.length > 0) {
if(specialList.length == 1) {
loadZhikeOne(data,specialList)
}else{
specialList.splice(2); // 只取前2条
$('.container').css({"width":"560px", "height": "160px"});
var dom = ' ' +
''+projectName+'-广告';
$.each(specialList,function (index,ele) {
dom += '';
window.uploadConfig = {
act:'load',
ad_id:data.baidu_id,
ad_pos:project_ad_pos+'_tips_1',
ad_type:'zhike',
strategy_id:ele.strategy_id,
idea_id:ele.idea_id,
plan_id:ele.plan_id,
product_category:ele.product_category
};
uploadConfig.act = 'show';
uploadConfig.ad_pos = project_ad_pos+'_tips_1_2c_'+ (index+1);
uploadZhike(uploadConfig);
})
$('.container').append(dom);
$.each(specialList,function (index,ele) {
$(".container").on('click','#ak'+ (index+1),function () {
window.uploadConfig = {
act:'load',
ad_id:data.baidu_id,
ad_pos:project_ad_pos+'_tips_1',
ad_type:'zhike',
strategy_id:ele.strategy_id,
idea_id:ele.idea_id,
plan_id:ele.plan_id,
product_category:ele.product_category
};
uploadConfig.act = 'click';
uploadConfig.ad_pos = project_ad_pos+'_tips_1_2c_'+ (index+1);
uploadZhike(uploadConfig);
});
})
$('head').append('');
if (typeof window.external != 'undefined' && "SetLayout" in window.external) {
var rows = 1, //行数
columns = 2, //列数
row_space = 20, //行间距
column_space = 0, //列间距
status = 1;
window.external.SetLayout(rows,columns,row_space,column_space,status);
}
if (typeof window.external != 'undefined' && "CppCall" in window.external) {
window.external.CppCall();
}
}
render = false;
}
}
//三图
function loadZhikeThree(data,specialList){
if (specialList.length > 0) {
if(specialList.length == 1) {
loadZhikeOne(data,specialList)
}else if(specialList.length == 2) {
loadZhikeTwo(data,specialList)
}else{
specialList.splice(3); // 只取前3条
$('.container').css({"width":"800px", "height": "150px"});
var dom = ' ' +
''+projectName+'-广告';
$.each(specialList,function (index,ele) {
dom += '';
window.uploadConfig = {
act:'load',
ad_id:data.baidu_id,
ad_pos:project_ad_pos+'_tips_1',
ad_type:'zhike',
strategy_id:ele.strategy_id,
idea_id:ele.idea_id,
plan_id:ele.plan_id,
product_category:ele.product_category
};
uploadConfig.act = 'show';
uploadConfig.ad_pos = project_ad_pos+'_tips_1_3c_'+ (index+1);
uploadZhike(uploadConfig);
})
$('.container').append(dom);
$.each(specialList,function (index,ele) {
$(".container").on('click','#ak'+ (index+1),function () {
window.uploadConfig = {
act:'load',
ad_id:data.baidu_id,
ad_pos:project_ad_pos+'_tips_1',
ad_type:'zhike',
strategy_id:ele.strategy_id,
idea_id:ele.idea_id,
plan_id:ele.plan_id,
product_category:ele.product_category
};
uploadConfig.act = 'click';
uploadConfig.ad_pos = project_ad_pos+'_tips_1_3c_'+ (index+1);
uploadZhike(uploadConfig);
});
})
$('head').append('');
if (typeof window.external != 'undefined' && "SetLayout" in window.external) {
var rows = 1, //行数
columns = 3, //列数
row_space = 10, //行间距
column_space = 0, //列间距
status = 1;
window.external.SetLayout(rows,columns,row_space,column_space,status);
}
if (typeof window.external != 'undefined' && "CppCall" in window.external) {
window.external.CppCall();
}
}
render = false;
}
}
//四横排
function loadZhikeFourCol(data,specialList){
if (specialList.length > 0) {
if(specialList.length == 1) {
loadZhikeOne(data,specialList)
}else if(specialList.length == 2) {
loadZhikeTwo(data,specialList)
}else if(specialList.length == 3) {
loadZhikeThree(data,specialList)
}else{
specialList.splice(4); // 只取前4条
$('.container').css({"width":"845px", "height": "120px"});
var dom = ' ' +
''+projectName+'-广告';
$.each(specialList,function (index,ele) {
dom += '';
window.uploadConfig = {
act:'load',
ad_id:data.baidu_id,
ad_pos:project_ad_pos+'_tips_1',
ad_type:'zhike',
strategy_id:ele.strategy_id,
idea_id:ele.idea_id,
plan_id:ele.plan_id,
product_category:ele.product_category
};
uploadConfig.act = 'show';
uploadConfig.ad_pos = project_ad_pos+'_tips_1_4c_'+ (index+1);
uploadZhike(uploadConfig);
})
$('.container').append(dom);
$.each(specialList,function (index,ele) {
$(".container").on('click','#ak'+ (index+1),function () {
window.uploadConfig = {
act:'load',
ad_id:data.baidu_id,
ad_pos:project_ad_pos+'_tips_1',
ad_type:'zhike',
strategy_id:ele.strategy_id,
idea_id:ele.idea_id,
plan_id:ele.plan_id,
product_category:ele.product_category
};
uploadConfig.act = 'click';
uploadConfig.ad_pos = project_ad_pos+'_tips_1_4c_'+ (index+1);
uploadZhike(uploadConfig);
});
})
$('head').append('');
if (typeof window.external != 'undefined' && "SetLayout" in window.external) {
var rows = 1, //行数
columns = 4, //列数
row_space = 15, //行间距
column_space = 0, //列间距
status = 1;
window.external.SetLayout(rows,columns,row_space,column_space,status);
}
if (typeof window.external != 'undefined' && "CppCall" in window.external) {
window.external.CppCall();
}
}
render = false;
}
}
//四宫格
function loadZhikeFourP(data,specialList){
if (specialList.length > 0) {
if(specialList.length == 1) {
loadZhikeOne(data,specialList)
}else if(specialList.length == 2) {
loadZhikeTwo(data,specialList)
}else if(specialList.length == 3) {
loadZhikeThree(data,specialList)
}else{
specialList.splice(4); // 只取前4条
$('.container').css({"width":"520px", "height": "350px"});
var dom = ' ' +
''+projectName+'-广告';
$.each(specialList,function (index,ele) {
dom += '';
window.uploadConfig = {
act:'load',
ad_id:data.baidu_id,
ad_pos:project_ad_pos+'_tips_1',
ad_type:'zhike',
strategy_id:ele.strategy_id,
idea_id:ele.idea_id,
plan_id:ele.plan_id,
product_category:ele.product_category
};
uploadConfig.act = 'show';
uploadConfig.ad_pos = project_ad_pos+'_tips_1_4p_'+ (index+1);
uploadZhike(uploadConfig);
})
$('.container').append(dom);
$.each(specialList,function (index,ele) {
$(".container").on('click','#ak'+ (index+1),function () {
window.uploadConfig = {
act:'load',
ad_id:data.baidu_id,
ad_pos:project_ad_pos+'_tips_1',
ad_type:'zhike',
strategy_id:ele.strategy_id,
idea_id:ele.idea_id,
plan_id:ele.plan_id,
product_category:ele.product_category
};
uploadConfig.act = 'click';
uploadConfig.ad_pos = project_ad_pos+'_tips_1_4p_'+ (index+1);
uploadZhike(uploadConfig);
});
})
$('head').append('');
if (typeof window.external != 'undefined' && "SetLayout" in window.external) {
var rows = 2, //行数
columns = 2, //列数
row_space = 12, //行间距
column_space = 13, //列间距
status = 1;
window.external.SetLayout(rows,columns,row_space,column_space,status);
}
if (typeof window.external != 'undefined' && "CppCall" in window.external) {
window.external.CppCall();
}
}
render = false;
}
}
//轮播
function loadZhikeLoop(data,specialList){
if (specialList.length > 0) {
if(specialList.length == 1) {
loadZhikeOne(data,specialList); //单图
}else{
$('.container').css({"width":"370px", "height": "250px"});
var dom = ' ' +
''+projectName+'-广告';
var domstr = "";
$.each(specialList,function (index,ele) {
domstr += '';
})
var swiperDom = '';
dom += swiperDom;
function showReport(index){ //show上报
var ele = specialList[index];
window.uploadConfig = {
act:'load',
ad_id:data.baidu_id,
ad_pos:project_ad_pos+'_tips_1',
ad_type:'zhike',
strategy_id:ele.strategy_id,
idea_id:ele.idea_id,
plan_id:ele.plan_id,
product_category:ele.product_category
};
uploadConfig.act = 'show';
uploadConfig.ad_pos = project_ad_pos+'_tips_1_lo_'+ (index+1);
uploadZhike(uploadConfig);
}
var activeIndex = 0;
$('.container').append(dom);
showReport(0);
var mySwiper = new Swiper('.swiper-container', {
autoplay : 5000,
speed:1000,
onlyExternal : true,
loop : true,
onSlideNext: function(swiper){
if(activeIndex+1 < specialList.length){
activeIndex ++;
showReport(activeIndex);
}
}
});
$.each(specialList,function (index,ele) {
$(".container").on('click','#ak'+ (index+1),function () {
window.uploadConfig = {
act:'load',
ad_id:data.baidu_id,
ad_pos:project_ad_pos+'_tips_1',
ad_type:'zhike',
strategy_id:ele.strategy_id,
idea_id:ele.idea_id,
plan_id:ele.plan_id,
product_category:ele.product_category
};
uploadConfig.act = 'click';
uploadConfig.ad_pos = project_ad_pos+'_tips_1_lo_'+ (index+1);
uploadZhike(uploadConfig);
});
})
$('head').append('');
if (typeof window.external != 'undefined' && "SetLayout" in window.external) {
var rows = 1, //行数
columns = 1, //列数
row_space = 0, //行间距
column_space = 0, //列间距
status = 1;
window.external.SetLayout(rows,columns,row_space,column_space,status);
}
if (typeof window.external != 'undefined' && "CppCall" in window.external) {
window.external.CppCall();
}
}
render = false;
}
}
//一大三小
function loadZhikeOT(data,i){
$('.container').css({"width":"370px","height":"400px"});
$('.container').append(''+projectName+'-广告