//ajax/json cors跨域开关
$.support.cors = true;
if (typeof console == 'undefined') {window.console = {log: function () {}}}
// 360广告宏替换参数
var Macro = {start: "__EVENT_TIME_START__", end: "__EVENT_TIME_END__", x: "__OFFSET_X__", y: "__OFFSET_Y__"};
//公用
(function () {
var common = {
getUserId: function () {
return (+new Date()) + Math.random().toString(10).substring(2, 6);
},
newDate:function(str){
var day = str.split(' ');
var days = day[0].split('-');
var mi = day[day.length - 1].split(':');
var date = new Date();
date.setUTCFullYear(days[0], days[1] - 1, days[2]);
date.setUTCHours(mi[0] - 8, mi[1], mi[2]);
return date;
},
GetQueryString: function (name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
},
getIeVersion:function () {
if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/8./i)=="8.") {
return "IE8";
} else if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/9./i)=="9.") {
return "IE9" ;
}else{
return "!IE"
}
},
getSystem: function () {
var sUserAgent = navigator.userAgent;
var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel");
if (isMac) return "Mac";
var isUnix = (navigator.platform == "X11") && !isWin && !isMac;
if (isUnix) return "Unix";
var isLinux = (String(navigator.platform).indexOf("Linux") > -1);
if (isLinux) return "Linux";
if (isWin) {
var isWin2K = sUserAgent.indexOf("Windows NT 5.0") > -1 || sUserAgent.indexOf("Windows 2000") > -1;
if (isWin2K) return "Win2000";
var isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1 || sUserAgent.indexOf("Windows XP") > -1;
if (isWinXP) return "WinXP";
var isWin2003 = sUserAgent.indexOf("Windows NT 5.2") > -1 || sUserAgent.indexOf("Windows 2003") > -1;
if (isWin2003) return "Win2003";
var isWinVista = sUserAgent.indexOf("Windows NT 6.0") > -1 || sUserAgent.indexOf("Windows Vista") > -1;
if (isWinVista) return "WinVista";
var isWin7 = sUserAgent.indexOf("Windows NT 6.1") > -1 || sUserAgent.indexOf("Windows 7") > -1;
if (isWin7) return "Win7";
var isWin10 = sUserAgent.indexOf("Windows NT 10") > -1 || sUserAgent.indexOf("Windows 10") > -1;
if (isWin10) return "Win10";
}
return "other";
},
getBrowser:function () {
var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
var isIE = userAgent.indexOf("compatible") > -1
&& userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器
var isEdge = userAgent.indexOf("Edge") > -1; //判断是否IE的Edge浏览器
var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
var isSafari = userAgent.indexOf("Safari") > -1
&& userAgent.indexOf("Chrome") == -1; //判断是否Safari浏览器
var isChrome = userAgent.indexOf("Chrome") > -1
&& userAgent.indexOf("Safari") > -1; //判断Chrome浏览器
if (isIE) {
var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
reIE.test(userAgent);
var fIEVersion = parseFloat(RegExp["$1"]);
if (fIEVersion == 7) {
return "IE7";
} else if (fIEVersion == 8) {
return "IE8";
} else if (fIEVersion == 9) {
return "IE9";
} else if (fIEVersion == 10) {
return "IE10";
} else if (fIEVersion == 11) {
return "IE11";
} else {
return "0";
}//IE版本过低
return "IE";
}
if (isOpera) {
return "Opera";
}
if (isEdge) {
return "Edge";
}
if (isFF) {
return "FF";
}
if (isSafari) {
return "Safari";
}
if (isChrome) {
return "Chrome";
}
},
};
window.Common = common;
})();
Configuration();
//根据域名配置
var proConfig;
function Configuration() {
// 默认配置
var proObject = {
name: 'kuaiya',
mini_name: '005',
qid: {rewen:'k002',toutiao:'kuaiya07',shehui:'kuaiya07',yule:'kuaiya07',shipin:'k002',tiyu:'k002',qiche:'k002',junshi:'k002',yangsheng:'03062',youxi:'kuaiya07',guoji:'kuaiya07',shishang:'kuaiya07',lishi:'kuaiya07',keji:'kuaiya07',caijing:'kuaiya07',xiaohua:'kuaiya07'},
left_tab:{youxi:'游戏',yangsheng:'养生',junshi:'军事',qiche:'汽车',tiyu:'体育',shipin:'视频',yule:'娱乐',shehui:'社会',toutiao:'推荐'},
left_tab_more:{guoji:'国际',shishang:'时尚',lishi:'历史',keji:'科技',caijing:'财经',xiaohua:'笑话'},
loadUrl:{online_url1:'//miniapi.7654.com/mini/news/page_type/pn/abckantu/type/',hotUrl:'//news.7654.com/tpop4/miniapi/recommend.json',
recommendUrl:'//miniapi.7654.com/mini/news/recommend',loadbaseUrl:'//miniapi.7654.com/mini/news/recommend'},
qid_index: {rewen:1,toutiao:1,shehui:1,yule:1,shipin:1,tiyu:1,qiche:1,junshi:1,yangsheng:1,youxi:1,guoji:1,shishang:1,lishi:1,keji:1,caijing:1,xiaohua:1},
message_flow_showId_first: true,
hot_showId_first: true,
top_right_showId_first: true,
miniRight1:'kuaiya_miniright_1',
miniRight2:'kuaiya_miniright_2',
miniRight3:'kuaiya_miniright_3',
miniQid:'kuaizip',
};
proConfig = proObject;
};
var user_uid = Common.getUserId();
var timer0510;
$('.left_nav .nav_item').hover(function () {
if ($(this).hasClass('hover')) {
$(this).find('.more_nav').show()
}
var x = 0;
var that = this;
timer0510 = setInterval(function () {
x++;
if (x > 3) {
clearInterval(timer0510)
$('.left_nav .nav_item').removeClass('active');
$(that).addClass('active');
$('.left_nav .nav_item_part').removeClass('active');
var type = $(that).attr('date-type');
$(".mask").hide();
var method = $(that).attr('method');
var first_view = $('.left_nav li:eq(0)').attr('method');
if (!first_view) {
$('.left_nav li:eq(0)').attr('method', 'change_view');
}
Mini[method] ? Mini[method]($(that), event) : '';
}
}, 100)
}, function () {
if ($(this).hasClass('hover')) {
$(this).find('.more_nav').hide()
}
clearInterval(timer0510)
});
$('body').on('mouseout', '.left_nav .nav_item:not(:last)', function () {
window.current_index1 = $('.left_nav .active').index();
});
$('body').on('click', '.more_nav .nav_item_part', function () {
var type = $(this).attr('date-type');
for (var i = 0; i < Mini.type_arr.length; i++) {
if (type == Mini.type_arr[i]) {
var flag = false;
break;
} else {
var flag = true;
}
}
Mini.type_arr.push(type);
});
// 点击更多 事件处理
$('body').on('mouseover', '.left_nav .nav_item_part', function () {
$('.left_nav .nav_item_part').removeClass('active');
$('.left_nav .nav_item:not(:last)').removeClass('active');
$(this).addClass('active');
$('.left_nav .nav_item:last').addClass('active');
});
/**
* All频道 对象 key=value
*/
// 将参数序列化,形如 ‘key1=孙平&key2=bbb’
function GetParams(temp, name) {
var theRequest = new Object();
var strs = temp.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
}
// 获取 参数对象的指定key 的 value值
var result = theRequest[name] || null;
return result;
}
//加载百度广告
function loadPjs(url, id, pid, op) {
var scriptAd = document.createElement("script");
scriptAd.type = "text/javascript";
scriptAd.src = url;
scriptAd.setAttribute('smua', op);
if ($('#' + pid).length > 0) {
$('#' + pid)[0].appendChild(scriptAd);
}
scriptAd.id = id;
}
function getUrlParamVal(name) {
// 获取当前 URL参数集
var r = decodeURI(window.location.search);
var arr1 = r.split("?");
arr1.shift();
var params = arr1.join("&");
var res = GetParams(params, name);
return res;
}
$('body').on('mouseover', '.xxl_ad,iframe', function () {
return false
});
function Mini_page() {
var obj = this;
this.pgnum_bot = 1;
this.pgnum_top = 0;
this.startkey = '';
this.newkey = '';
this.uid = user_uid;
this.vqid = getUrlParamVal('vqid') || '';
this.vv = getUrlParamVal('vv') || '';
this.vuid = getUrlParamVal('vuid') || '';
this.bool = true;
this.getBaiDuAd = true;
this.type = 'toutiao';
this.position = "";
this.logo = '';
this.l;
this.adsid = 1;
this.l1 = 0;
this.l2 = 7;
this.refresh_dev;
this.refresh_tab;
this.refresh_scroll;
this.type_arr = [];
this.bottomOutTime = 1;
this.imptk360 = [];
this.ad360data = [];
this.ad360index = 0;
this.pos_pro = '';
this.pos_city = '';
if (typeof Mini_page.instance === 'object') {
return Mini_page.instance;
}
this.instance = this;
this.pathname = window.location.pathname.slice(1, -1);
}
Mini_page.prototype = {
// 页面初始化数据获取
bindEvent:function(){
var obj = this;
obj.type_arr.push(obj.type);
var urlhost;
if(location.host == 'news.7654.com'){
urlhost ='prod/'+location.host+location.pathname.replace(/\//g,".");
}else{
urlhost = 'test/'+location.host+location.pathname.replace(/\//g,".");
}
$.ajax({
url:'http://ads.7654.com/'+urlhost+'json?t='+new Date().getTime(),
// url:'http://ads.7654.com/test/test.gamma-minipage.news.7654.com.bz02.json',
// url:'http://ads.7654.com/zycerrorjson',
type:'get',
dataType:'json',
success:function(res){
proConfig.message_flow_showId=res.l;//左侧
proConfig.top_right_showId=res.rt;//右上
proConfig.hot_showId=res.rb;//右下
$.ajax({
url:proConfig.loadUrl.recommendUrl,
type: 'get',
dataType: 'json',
success: function (response) {
var data = response.data.slice(0,6);
var orderIndex = 1; //首次加载六条热闻
$.each(data, function (index, val) {
val.indexOrder = orderIndex;
orderIndex++;
obj.render('.scroll_con', val, "append", 'show', true, false, 'pdata');
});
$('.scroll_con').prepend('
为您推荐了6篇文章
');
$('#toast').addClass('hide_now');
setTimeout(function () {$('.scroll_con #toast').remove();}, 2000);
obj.get360Ad(obj.bottomOutTime, function (res) {
var first_item_360bool_1 = true,
first_item_360bool_2 = true;
window.first_item_360bool_3 = true;
window.first_item_360bool_4 = true;
window.first_item_360bool_5 = true;
window.first_item_360bool_6 = true;
$.each(res, function (index, val) {
obj.ad360data.push(val);
obj.imptk360.push(val.imptk);
});
if (res[0]) {
if (res[0].type == 3) {
obj.renderBig360('.scroll_con .list_item:eq(0)', res[0], 1);
}else if (res[0].type == 4) {
obj.renderVideo360('.scroll_con .list_item:eq(0)', res[0], 1);
} else {
obj.render360('.scroll_con .list_item:eq(0)', res[0], 1);
}
url_scroll(res[0].imptk);
upload($('.scroll_con .list_item:eq(0) .img_click_gg'),'show')//右上show上报
}
if (res[1]) {
if (res[1].type == 3) {
obj.renderBig360('.scroll_con .list_item:eq(2)', res[1], 3);
}else if (res[1].type == 4) {
obj.renderVideo360('.scroll_con .list_item:eq(2)', res[1], 3);
} else {
obj.render360('.scroll_con .list_item:eq(2)', res[1], 3);
}
url_scroll(res[1].imptk);
}
if (res[2]) {
if(res[2].type==4){
obj.renderVideo360('.scroll_con .list_item:eq(4)', res[2], 5);
}else{
obj.render360('.scroll_con .list_item:eq(4)', res[2],5);
}
if ($('.scroll_con .list_item:eq(4)').offset()) {
var nowTop = $('.scroll_con .list_item:eq(4)').offset().top;
if (nowTop < 570 && window.first_item_360bool_3) {
url_scroll(res[2].imptk);
window.first_item_360bool_3 = false;
}
}
}
if (res[3]) {
if(res[3].type==4){
obj.renderVideo360('.scroll_con .list_item:eq(6)', res[3], 7);
}else{
obj.render360('.scroll_con .list_item:eq(6)', res[3], 7);
}
}
if (res[4]) {
if(res[4].type==4){
obj.renderVideo360('.scroll_con .list_item:eq(8)', res[4], 9);
}else{
obj.render360('.scroll_con .list_item:eq(8)', res[4], 9);
}
}
if (res[5]) {
if(res[5].type==4){
obj.renderVideo360('.scroll_con .list_item:eq(10)', res[5], 11);
}else{
obj.render360('.scroll_con .list_item:eq(10)', res[5], 11);
}
}
var showRefreshBool = true;
$('.content').on('scroll', function (event) {
var SCROLL_TOP = $(this).scrollTop();
var thirdTop = $('.scroll_con .list_item:eq(4)').offset().top;
var fourththirdTop = $('.scroll_con .list_item:eq(6)').offset().top;
var fifthTop = $('.scroll_con .list_item:eq(8)').offset().top;
var sixthTop = $('.scroll_con .list_item:eq(10)').offset().top;
if (thirdTop - 590 < 0 && window.first_item_360bool_3) {
window.first_item_360bool_3 = false;
if (obj.ad360data[2]) {
url_scroll(obj.ad360data[2].imptk);
}
}
if (fourththirdTop - 590 < 0 && window.first_item_360bool_4) {
$('#refresh').show();
window.first_item_360bool_4 = false;
if (obj.ad360data[3]) {
url_scroll(obj.ad360data[3].imptk);
}
}
if (fifthTop - 590 < 0 && window.first_item_360bool_5) {
window.first_item_360bool_5 = false;
if (obj.ad360data[4]) {
url_scroll(obj.ad360data[4].imptk);
}
}
if (sixthTop - 590 < 0 && window.first_item_360bool_6) {
window.first_item_360bool_6 = false;
if (obj.ad360data[5]) {
url_scroll(obj.ad360data[5].imptk);
}
}
});
}, '', 6);
},
error:function(){
$.ajax({
url:'//news.7654.com/tpop4/miniapi/recommend.json',
type: 'get',
dataType: 'json',
success: function (response) {
var data = response.data.slice(0,6);
var orderIndex = 1; //首次加载六条热闻
$.each(data, function (index, val) {
val.indexOrder = orderIndex;
orderIndex++;
obj.render('.scroll_con', val, "append", 'show', true, false, 'pdata');
});
$('.scroll_con').prepend('为您推荐了6篇文章
');
$('#toast').addClass('hide_now');
setTimeout(function () {$('.scroll_con #toast').remove();}, 2000);
setTimeout(function () {
obj.get360Ad(obj.bottomOutTime, function (res) {
var first_item_360bool_1 = true,
first_item_360bool_2 = true;
window.first_item_360bool_3 = true;
window.first_item_360bool_4 = true;
window.first_item_360bool_5 = true;
window.first_item_360bool_6 = true;
$.each(res, function (index, val) {
obj.ad360data.push(val);
obj.imptk360.push(val.imptk);
});
if (res[0]) {
if (res[0].type == 3) {
obj.renderBig360('.scroll_con .list_item:eq(0)', res[0], 1);
}else if (res[0].type == 4) {
obj.renderVideo360('.scroll_con .list_item:eq(0)', res[0], 1);
} else {
obj.render360('.scroll_con .list_item:eq(0)', res[0], 1);
}
url_scroll(res[0].imptk);
upload($('.scroll_con .list_item:eq(0) .img_click_gg'),'show')//右上show上报
}
if (res[1]) {
if (res[1].type == 3) {
obj.renderBig360('.scroll_con .list_item:eq(2)', res[1], 3);
}else if (res[1].type == 4) {
obj.renderVideo360('.scroll_con .list_item:eq(2)', res[1], 3);
} else {
obj.render360('.scroll_con .list_item:eq(2)', res[1], 3);
}
url_scroll(res[1].imptk);
}
if (res[2]) {
if(res[2].type==4){
obj.renderVideo360('.scroll_con .list_item:eq(4)', res[2], 5);
}else{
obj.render360('.scroll_con .list_item:eq(4)', res[2],5);
}
if ($('.scroll_con .list_item:eq(4)').offset()) {
var nowTop = $('.scroll_con .list_item:eq(4)').offset().top;
if (nowTop < 570 && window.first_item_360bool_3) {
url_scroll(res[2].imptk);
window.first_item_360bool_3 = false;
}
}
}
if (res[3]) {
if(res[3].type==4){
obj.renderVideo360('.scroll_con .list_item:eq(6)', res[3], 7);
}else{
obj.render360('.scroll_con .list_item:eq(6)', res[3], 7);
}
}
if (res[4]) {
if(res[4].type==4){
obj.renderVideo360('.scroll_con .list_item:eq(8)', res[4], 9);
}else{
obj.render360('.scroll_con .list_item:eq(8)', res[4], 9);
}
}
if (res[5]) {
if(res[5].type==4){
obj.renderVideo360('.scroll_con .list_item:eq(10)', res[5], 11);
}else{
obj.render360('.scroll_con .list_item:eq(10)', res[5], 11);
}
}
var showRefreshBool = true;
$('.content').on('scroll', function (event) {
var SCROLL_TOP = $(this).scrollTop();
var thirdTop = $('.scroll_con .list_item:eq(4)').offset().top;
var fourththirdTop = $('.scroll_con .list_item:eq(6)').offset().top;
var fifthTop = $('.scroll_con .list_item:eq(8)').offset().top;
var sixthTop = $('.scroll_con .list_item:eq(10)').offset().top;
if (thirdTop - 590 < 0 && window.first_item_360bool_3) {
window.first_item_360bool_3 = false;
if (obj.ad360data[2]) {
url_scroll(obj.ad360data[2].imptk);
}
}
if (fourththirdTop - 590 < 0 && window.first_item_360bool_4) {
$('#refresh').show();
window.first_item_360bool_4 = false;
if (obj.ad360data[3]) {
url_scroll(obj.ad360data[3].imptk);
}
}
if (fifthTop - 590 < 0 && window.first_item_360bool_5) {
window.first_item_360bool_5 = false;
if (obj.ad360data[4]) {
url_scroll(obj.ad360data[4].imptk);
}
}
if (sixthTop - 590 < 0 && window.first_item_360bool_6) {
window.first_item_360bool_6 = false;
if (obj.ad360data[5]) {
url_scroll(obj.ad360data[5].imptk);
}
}
});
$('.scroll_con .list_item:eq(11)').after('刚刚看到这里 点击刷新
');
}, '', 6);
}, 1000);
},
error:function(){}
});
}
});
obj.renderSsp(function(res){
var top1=proConfig.miniRight1;
var top2=proConfig.miniRight2;
if($.isEmptyObject(res)){
obj.get360Ad(1,function(res){
if(res[0]){
$('.right_pannel .showcase:eq(0)').html('')
url_scroll(res[0].imptk);
upload($('.right_pannel .showcase:eq(0) .img_click_gg' ),'show')//右上show上报
}else{
obj.renderLoad('.right_pannel .showcase:eq(0)',0,'top');
}
if(res[1]){
$('.right_pannel .showcase:eq(1)').html('')
url_scroll(res[1].imptk);
}else{
obj.renderLoad('.right_pannel .showcase:eq(1)',1,'top');
}
},proConfig.top_right_showId, 2);
}else{
var data1=res.data[proConfig.miniRight1];
var data2=res.data[proConfig.miniRight2];
if(data1.script.length!=0&&data1.script[0].idea_type==14){ //右上大图
$(".top_ssp").show();
$(".showcase").hide();
var value=data1.script[0].idea;
$('.top_ssp').html('广告');
window.uploadConfig1 = {
act:'show',
ad_id:data1.baidu_id,
ad_pos:top1,
strategy_id:data1.script[0].strategy_id,
idea_id:data1.script[0].idea_id,
plan_id:data1.script[0].plan_id,
product_category:data1.script[0].product_category
};
//加载
uploadZhike(uploadConfig1);
$("body").on('click','.ssp_click_gg',function(){
uploadConfig1.act='click';
uploadZhike(uploadConfig1);
})
return false;
}else if(data1.script.length!=0&&data2.script.length!=0&&data1.script[0].idea_type==13&&data2.script[0].idea_type==13){ //右上1小图 右上2小图
var value1=data1.script[0].idea;
var value2=data2.script[0].idea;
$('.showcase:eq(0)').html('广告');
$('.showcase:eq(1)').html('广告')
window.uploadConfig1 = {
act:'show',
ad_id:data1.baidu_id,
ad_pos:top1,
strategy_id:data1.script[0].strategy_id,
idea_id:data1.script[0].idea_id,
plan_id:data1.script[0].plan_id,
product_category:data1.script[0].product_category
};
window.uploadConfig2 = {
act:'show',
ad_id:data2.baidu_id,
ad_pos:top2,
strategy_id:data2.script[0].strategy_id,
idea_id:data2.script[0].idea_id,
plan_id:data2.script[0].plan_id,
product_category:data2.script[0].product_category
};
//加载
uploadZhike(uploadConfig1);
uploadZhike(uploadConfig2);
$("body").on('click','.ssp_click_gg1',function(){
uploadConfig1.act='click';
uploadZhike(uploadConfig1);
})
$("body").on('click','.ssp_click_gg2',function(){
uploadConfig2.act='click';
uploadZhike(uploadConfig2);
})
return false;
}else if(data1.script.length!=0&&data1.script[0].idea_type==13&&data2.script.length==0){//右上1小图 右上2无图
var value1=data1.script[0].idea;
$('.showcase:eq(0)').html('广告');
obj.get360Ad(1,function(res){
if(res[0]){
$('.right_pannel .showcase:eq(1)').html('')
url_scroll(res[0].imptk);
upload($('.right_pannel .showcase:eq(1) .img_click_gg' ),'show')//右上show上报
}else{
obj.renderLoad('.right_pannel .showcase:eq(1)',0,'top');
}
},proConfig.top_right_showId, 1);
window.uploadConfig1 = {
act:'show',
ad_id:data1.baidu_id,
ad_pos:top1,
strategy_id:data1.script[0].strategy_id,
idea_id:data1.script[0].idea_id,
plan_id:data1.script[0].plan_id,
product_category:data1.script[0].product_category
};
//加载
uploadZhike(uploadConfig1);
$("body").on('click','.ssp_click_gg',function(){
uploadConfig1.act='click';
uploadZhike(uploadConfig1);
})
return false;
}else if(data1.script.length==0&&data2.script.length!=0&&data2.script[0].idea_type==13){//右上1无图 右上2有值
var value2=data2.script[0].idea;
$('.showcase:eq(1)').html('广告');
obj.get360Ad(1,function(res){
if(res[0]){
$('.right_pannel .showcase:eq(0)').html('')
url_scroll(res[0].imptk);
upload($('.right_pannel .showcase:eq(1) .img_click_gg' ),'show')//右上show上报
}else{
obj.renderLoad('.right_pannel .showcase:eq(0)',0,'top');
}
},proConfig.top_right_showId, 1);
window.uploadConfig2 = {
act:'show',
ad_id:data2.baidu_id,
ad_pos:top2,
strategy_id:data2.script[0].strategy_id,
idea_id:data2.script[0].idea_id,
plan_id:data2.script[0].plan_id,
product_category:data2.script[0].product_category
};
//加载
uploadZhike(uploadConfig2);
$("body").on('click','.ssp_click_gg',function(){
uploadConfig2.act='click';
uploadZhike(uploadConfig2);
})
return false;
}else if(data1.script.length==0&&data2.script.length==0){
obj.get360Ad(1,function(res){
if(res[0]){
$('.right_pannel .showcase:eq(0)').html('')
url_scroll(res[0].imptk);
upload($('.right_pannel .showcase:eq(0) .img_click_gg' ),'show')//右上show上报
}else{
obj.renderLoad('.right_pannel .showcase:eq(0)',0,'top');
}
if(res[1]){
$('.right_pannel .showcase:eq(1)').html('')
url_scroll(res[1].imptk);
}else{
obj.renderLoad('.right_pannel .showcase:eq(1)',1,'top');
}
},proConfig.top_right_showId, 2);
}else{
}
}
},2)
obj.renderSsp(function(res){
var top3=proConfig.miniRight3;
if($.isEmptyObject(res)||res.data[top3].script.length==0){ //ssp有数据并且为空
$('.today_news .hot_ssp').hide();
$(".hot_news").append('24小时热闻
');
var qid=proConfig.qid.rewen;
obj.renderNovel(function(data){
obj.get360Ad(1,function(res){
if(res.length==1){
$('.today_news .adCase:eq(0)').html(''+
'' + res[0].title + '
广告');
$('.today_news .adCase:eq(1)').html('' + data[0].title + '
');
$('.today_news .slide2').remove();
url_scroll(res[0].imptk);
upload($('.today_news .adCase:eq(0) a'),'show')//右下show上报
var mySwiper = new Swiper('.swiper-container',{
autoplay : 3000,
loop:true,
autoplayDisableOnInteraction : false,
})
}else if(res.length==2){
$('.today_news .adCase:eq(0)').html(''+
'' + res[0].title + '
广告');
$('.today_news .adCase:eq(1)').html('' + data[0].title + '
');
$('.today_news .adCase:eq(2)').html(''+
'' + res[1].title + '
广告');
url_scroll(res[0].imptk);
url_scroll(res[1].imptk);
upload($('.today_news .adCase:eq(0) a'),'show')//右下show上报
var mySwiper = new Swiper('.swiper-container',{
autoplay : 3000,
loop:true,
autoplayDisableOnInteraction : false,
})
}else{
$('.today_news .adCase:eq(0)').html('' + data[0].title + '
');
$('.today_news .slide1').remove();
$('.today_news .slide2').remove();
$(".arrow").remove();
var mySwiper = new Swiper('.swiper-container',{
})
}
$('.leftBtn').click(function(){
mySwiper.swipePrev();
})
$('.rightBtn').click(function(){
mySwiper.swipeNext();
})
},proConfig.hot_showId, 2)
})
}else{
var datas=res.data[proConfig.miniRight3];
var value=datas.script[0].idea;
console.log(datas)
$('.today_news .hot_news').hide();
$('.today_news .swiper-container').html('广告');
window.uploadConfig = {
act:'show',
ad_id:datas.baidu_id,
strategy_id:datas.script[0].strategy_id,
idea_id:datas.script[0].idea_id,
plan_id:datas.script[0].plan_id,
product_category:datas.script[0].product_category
};
//加载
uploadZhike(uploadConfig);
$("body").on('click','.ssp_click_gg4',function(){
uploadConfig.act='click';
uploadZhike(uploadConfig);
})
}
},1)
$(".swiper-container").hover(function(){
$(".arrow").show();
},function(){
$(".arrow").hide();
})
}
})
var _clktk, _curl, start_time, end_time;
//宏替换-1
function mouseDownMacro(el, x, y) {
start_time = Math.round(new Date());
_clktk = el.data('oldclktk');
_curl = el.data("oldcurl");
if (_clktk.indexOf(Macro["start"]) > -1) {
_clktk = _clktk.replace(Macro["start"], start_time);
}
if (_clktk.indexOf(Macro["x"]) > -1) {
_clktk = _clktk.replace(Macro["x"], x);
}
if (_clktk.indexOf(Macro["y"]) > -1) {
_clktk = _clktk.replace(Macro["y"], y);
}
if (_curl.indexOf(Macro["start"]) > -1) {
_curl = _curl.replace(Macro["start"], start_time);
}
if (_curl.indexOf(Macro["x"]) > -1) {
_curl = _curl.replace(Macro["x"], x);
}
if (_curl.indexOf(Macro["y"]) > -1) {
_curl = _curl.replace(Macro["y"], y);
}
el.attr('data-clktk', _clktk);
el.attr('href', _curl);
}
//宏替换-2
function mouseUpMacro(el) {
end_time = Math.round(new Date());
_curl = el.attr("href");
if (_clktk.indexOf(Macro["end"]) > -1) {
_clktk = _clktk.replace(Macro["end"], end_time);
}
if (_curl.indexOf(Macro["end"]) > -1) {
_curl = _curl.replace(Macro["end"], end_time);
}
el.attr('data-clktk', _clktk);
el.attr('href', _curl);
}
/*360曝光*/
var url_scroll = function (arr) {
$.each(arr, function (index, val) {
$('body').append('');
});
};
/*360点击曝光*/
$('body').on('mousedown', '.img_click_gg', function (e) {
var x = Math.floor(e.pageX - $(this).offset().left),
y = Math.floor(e.pageY - $(this).offset().top);
x = x<0 ? 0:x;
y = y<0 ? 0:y;
mouseDownMacro($(this), x, y);
}).on('click', '.img_click_gg', function () {
mouseUpMacro($(this));
var str = $(this).attr('data-clktk');
if (str) {
var arr = str.split(',');
$.each(arr, function (index, val) {
$('body').append('');
});
}
upload($(this)[0],'click');
});
$("body").on('click','.news_click_gg',function(){
upload($(this)[0],'click');
})
$('body').on('click', '.click_event', function (event) {
var method = $(this).attr('method');
obj[method] ? obj[method]($(this), event) : '';
});
$('.content').on('scroll', function (event) {
var SCROLL_TOP = $(this).scrollTop();
var CLIENT_HEIGHT =570;
var TOTAL_HEIGHT = $('.scroll_con').height() - $('.scroll_con .list_item:last').height();
if (SCROLL_TOP + CLIENT_HEIGHT >= TOTAL_HEIGHT && obj.bool && TOTAL_HEIGHT != 0) {
obj.imptk360 = [];
obj.bool = false;
obj.pgnum_bot++;
obj.bottomOutTime++;
var params = {
type: obj.type,
startkey: obj.startkey,
newkey: obj.newkey,
pgnum: obj.pgnum_bot,
uid: user_uid,
qid: '01747',
pos_pro: encodeURIComponent(obj.pos_pro),
pos_city: encodeURIComponent(obj.pos_city),
position: encodeURIComponent(obj.position),
domain: 'news.7654.com'
};
obj.refresh_scroll = true;
obj.fetch_data(params);
}
});
},
// 页面初始化数据获取
fetch_data: function (params, btn) {
var loading_dom = '';
$('.content').prepend(loading_dom);
var obj = this;
var online_url1 = proConfig.loadUrl.online_url1;
var online_url2 = proConfig.loadUrl.online_url2;
if (obj.refresh_dev) {
var pgnum = obj.pgnum_top++
online_url = online_url2 + params.type + '/page/' + pgnum
}
if (obj.refresh_scroll || obj.refresh_tab) {
online_url = online_url1 + params.type + '/page/' + params.pgnum
}
$.ajax({
url: online_url,
type: 'get',
dataType: 'json',
error: function () {
obj.fetch_data(null);
},
success: function (res) {
if (res.code == 0) {
proConfig.message_flow_showId_first =true;
//tab切换
if (obj.refresh_tab) {
obj.refresh_tab = false
obj.l1 = 6;
obj.l2 = 7;
var oType = btn.attr('date-type');
var orderIndex = 10;
$.each(res.data, function (index, val) {
val.indexOrder = orderIndex;
orderIndex--;
obj.render('.scroll_con.' + oType, val, "prepend", "no_show", false, true);
});
$('.scroll_con').prepend('为您推荐了6篇文章
');
$('#toast').addClass('hide_now');
setTimeout(function () {
$('.scroll_con #toast').remove();
}, 2000);
setTimeout(function () {
obj.get360Ad(obj.bottomOutTime, function (res) {
var first_item_360bool_1 = true,
first_item_360bool_2 = true;
$.each(res, function (index, val) {
obj.ad360data.push(val);
obj.imptk360.push(val.imptk);
});
if (res[0]) {
if (res[0].type == 3) {
obj.renderBig360('.scroll_con.' + oType + ' .list_item:eq(0)', res[0] , 1);
}else if (res[0].type == 4) {
obj.renderVideo360('.scroll_con.' + oType + ' .list_item:eq(0)', res[0] , 1);
} else {
obj.render360('.scroll_con.' + oType + ' .list_item:eq(0)', res[0], 1);
}
url_scroll(res[0].imptk);
}
if (res[1]) {
if (res[1].type ==3) {
obj.renderBig360('.scroll_con.' + oType + ' .list_item:eq(2)', res[1], 3);
} else if (res[1].type == 4) {
obj.renderVideo360('.scroll_con.' + oType + ' .list_item:eq(2)', res[1] , 3);
}else {
obj.render360('.scroll_con.' + oType + ' .list_item:eq(2)', res[1], 3);
}
url_scroll(res[1].imptk);
}
if (res[2]) {
if(res[2].type==4){
obj.renderVideo360('.scroll_con.' + oType + ' .list_item:eq(4)', res[2] , 5);
}else{
obj.render360('.scroll_con.' + oType + ' .list_item:eq(4)', res[2] , 5);
}
if ($('.scroll_con.' + oType + ' .list_item:eq(4)').offset()) {
var nowTop = $('.scroll_con.' + oType + ' .list_item:eq(4)').offset().top;
}
if (nowTop < 570 && window.first_item_360bool_3) {
url_scroll(res[2].imptk);
window.first_item_360bool_3 = false;
}
}
if (res[3]) {
if(res[3].type==4){
obj.renderVideo360('.scroll_con.' + oType + ' .list_item:eq(6)', res[3] , 7);
}else{
obj.render360('.scroll_con.' + oType + ' .list_item:eq(6)', res[3], 7);
}
}
if (res[4]) {
if(res[4].type==4){
obj.renderVideo360('.scroll_con.' + oType + ' .list_item:eq(8)', res[4] , 9);
}else{
obj.render360('.scroll_con.' + oType + ' .list_item:eq(8)', res[4], 9);
}
}
if (res[5]) {
if(res[5].type==4){
obj.renderVideo360('.scroll_con.' + oType + ' .list_item:eq(10)', res[5] , 11);
}else{
obj.render360('.scroll_con.' + oType + ' .list_item:eq(10)', res[5], 11);
}
}
var showRefreshBool = true;
}, '', 6);
}, 1000)
$('.content').css({'scrollTop': '0'});
}
// 下拉刷新
if (obj.refresh_scroll) {
obj.refresh_scroll = false
var list_len = $('.scroll_con .list_item').length;
$.each(res.data, function (index, val) {
val.indexOrder = proConfig.qid_index[obj.type] + 10;
proConfig.qid_index[obj.type]++;
obj.render('.scroll_con', val, "append", "no_show", true, false, 'pdata');
});
obj.get360Ad(obj.bottomOutTime, function (res) {
var item_360bool_1 = true,
item_360bool_2 = true,
item_360bool_3 = true;
$.each(res, function (index, val) {
obj.imptk360.push(val.imptk);
});
if (res[0]) {
if(res[0].type==4){
obj.renderVideo360('.scroll_con .list_item:eq(' + (list_len + 2) + ')', res[0], list_len + 2);
}else{
obj.render360('.scroll_con .list_item:eq(' + (list_len + 2) + ')', res[0], list_len + 2);
}
}
if (res[1]) {
if(res[1].type==4){
obj.renderVideo360('.scroll_con .list_item:eq(' + (list_len + 6) + ')', res[1],list_len + 6);
}else{
obj.render360('.scroll_con .list_item:eq(' + (list_len + 6) + ')', res[1],list_len + 6);
}
}
if (res[2]) {
if(res[2].type==4){
obj.renderVideo360('.scroll_con .list_item:eq(' + (list_len + 10) + ')', res[2],list_len + 10);
}else{
obj.render360('.scroll_con .list_item:eq(' + (list_len + 10) + ')', res[2],list_len + 10);
}
}
var list_360item_h_1 = $('.scroll_con').outerHeight() - $('.scroll_con .list_item:nth-last-child(1)').outerHeight() - $('.scroll_con .list_item:nth-last-child(2)').outerHeight() - $('.scroll_con .list_item:nth-last-child(3)').outerHeight() - $('.scroll_con .list_item:nth-last-child(4)').outerHeight() - $('.scroll_con .list_item:nth-last-child(5)').outerHeight() - $('.scroll_con .list_item:nth-last-child(6)').outerHeight() - $('.scroll_con .list_item:nth-last-child(7)').outerHeight() - $('.scroll_con .list_item:nth-last-child(8)').outerHeight() - $('.scroll_con .list_item:nth-last-child(9)').outerHeight() - $('.scroll_con .list_item:nth-last-child(10)').outerHeight() - $('.scroll_con .list_item:nth-last-child(11)').outerHeight();
var list_360item_h_2 = $('.scroll_con').outerHeight() - $('.scroll_con .list_item:nth-last-child(1)').outerHeight() - $('.scroll_con .list_item:nth-last-child(2)').outerHeight() - $('.scroll_con .list_item:nth-last-child(3)').outerHeight() - $('.scroll_con .list_item:nth-last-child(4)').outerHeight() - $('.scroll_con .list_item:nth-last-child(5)').outerHeight() - $('.scroll_con .list_item:nth-last-child(6)').outerHeight() - $('.scroll_con .list_item:nth-last-child(7)').outerHeight()
var list_360item_h_3 = $('.scroll_con').outerHeight() - $('.scroll_con .list_item:nth-last-child(1)').outerHeight() - $('.scroll_con .list_item:nth-last-child(2)').outerHeight() - $('.scroll_con .list_item:nth-last-child(3)').outerHeight()
$('.content').on('scroll', function (event) {
var SCROLL_TOP = $(this).scrollTop();
if (570 + SCROLL_TOP > list_360item_h_1 && item_360bool_1) {
item_360bool_1 = false;
if (obj.imptk360[0]) {
url_scroll(obj.imptk360[0]);
}
}
if (570 + SCROLL_TOP > list_360item_h_2 && item_360bool_2) {
item_360bool_2 = false;
if (obj.imptk360[1]) {
url_scroll(obj.imptk360[1]);
}
}
if (570 + SCROLL_TOP > list_360item_h_3 && item_360bool_3) {
item_360bool_3 = false;
if (obj.imptk360[1]) {
url_scroll(obj.imptk360[2]);
}
}
});
obj.bool = true;
})
}
} else {
alert('Sorry, ' + res.info);
}
$('.loading_ajax').remove();
}
});
},
// 数据流360广告获取
get360Ad: function (reqtime, callback, showId, num) {
var recommend_url = '//show.g.mediav.com/s',
recommend_type = 1,
recommend_of = 4,
reqtimes = reqtime || 1,
recommend_newf = 1,
recommend_showid = showId || proConfig.message_flow_showId,
tck = Common.GetQueryString("tck"),
recommend_adnum = num || 3,
recommendk_uid = recommend_uid(),
recommend_refurl=encodeURIComponent(document.referrer),
recommend_param;
tck = tck ? '&tck='+ tck:'';
if (document.location.protocol == "https:") {
recommend_param = 'https://show-g.mediav.com/s' + '?type=' + recommend_type + '&of=' + recommend_of + '&newf=' + recommend_newf + '&scheme=https&showid=' + recommend_showid + '&uid=' + recommendk_uid + '&impct=' + recommend_adnum + '&reqtimes=' + reqtimes + tck+'&refurl='+recommend_refurl;
} else {
recommend_param = recommend_url + '?type=' + recommend_type + '&of=' + recommend_of + '&newf=' + recommend_newf + '&showid=' + recommend_showid + '&uid=' + recommendk_uid + '&impct=' + recommend_adnum + '&reqtimes=' + reqtimes + tck+'&refurl='+recommend_refurl;
}
$.ajax({
type: 'get',
url: recommend_param,
dataType: 'jsonp',
jsonp: 'jsonp',
success: function (data) {
//[]
if(!data.ads){
upload("","loadfail2")
if(proConfig.message_flow_showId_first && proConfig.message_flow_showId == recommend_showid){
proConfig.message_flow_showId_first = false;
$.ajax({
type: 'get',
url: recommend_param,
dataType: 'jsonp',
jsonp: 'jsonp',
success: function (data) {
var d = data.ads || [];
if(d.length==0){
upload("","loadfail3")
}
callback && callback(d);
var pso ={
timestamp: new Date().getTime(),
project: location.pathname,
action:"show",
p1:'messageFlow',
p2: recommend_showid,
p3: !data.ads ? "error": "success",
p4:"null"
};
upload2(pso);
},
error: function () {
var data=[];
upload('','loadfail4')
callback(data);
}
})
}else if(proConfig.top_right_showId_first && proConfig.top_right_showId == recommend_showid ){
proConfig.top_right_showId_first = false;
$.ajax({
type: 'get',
url: recommend_param,
dataType: 'jsonp',
jsonp: 'jsonp',
success: function (data) {
var d = data.ads || [];
if(d.length==0){
upload("","loadfail3")
}
callback && callback(d);
var pso ={
timestamp: new Date().getTime(),
project: location.pathname,
action:"show",
p1:'topRight',
p2: recommend_showid,
p3: !data.ads ? "error": "success",
p4:"null"
};
upload2(pso);
},
error: function () {
var data=[];
upload('','loadfail4')
callback(data);
}
})
}else if(proConfig.hot_showId_first&& proConfig.hot_showId == recommend_showid){
proConfig.hot_showId_first = false;
$.ajax({
type: 'get',
url: recommend_param,
dataType: 'jsonp',
jsonp: 'jsonp',
success: function (data) {
var d = data.ads || [];
if(d.length==0){
upload("","loadfail3")
}
callback && callback(d);
var pso ={
timestamp: new Date().getTime(),
project: location.pathname,
action:"show",
p1:'hotNews',
p2: recommend_showid,
p3: !data.ads ? "error": "success",
p4:"null"
};
upload2(pso);
},
error: function () {
var data=[];
upload('','loadfail4')
callback(data);
}
})
}
}else{
var d = data.ads || [];
callback && callback(d);
}
},
error: function () {
var data=[];
upload('','loadfail1')
callback(data);
}
})
},
// 数据渲染
render: function (target_dom, content, render_way, show_type, flag1, flag2, updata) {
var obj = this;
if (flag1) {
obj.l1++;
if (obj.l1 > 100) {
obj.l1 = 101;
}
obj.l = obj.l1;
}
if (flag2) {
obj.l2--;
obj.l = obj.l2;
}
var myQId = proConfig.qid[obj.type];
var dom = '',
author_info = '',
type_dom = '',
important_href = '?qid=' + myQId ,
point_dom = '';
if ( content.url.indexOf('www.lieqinews.com') > -1) {
important_href = '';
}
if (obj.type == "toutiao" || obj.type == "redian") {
point_dom = '·';
}
obj.logo = obj.type;
if (obj.type == 'redian') {
obj.logo = 'toutiao2'
}
if (content.dfh_nickname) {
author_info = point_dom + '' + content.dfh_nickname + '';
} else {
author_info = '';
}
type_dom = '' + content.source + '';
if (obj.vuid) {
important_href += "&vuid=" + obj.vuid;
}
if (obj.vv) {
important_href += "&vv=" + obj.vv;
}
if (obj.vqid) {
important_href += "&vqid=" + obj.vqid;
}
//生成所有important_href
var commonObj = $.extend(proConfig.left_tab,proConfig.left_tab_more);
important_href += "&_"+content.indexOrder+"_"+commonObj[obj.type]+"1";
var url = content.url.split('?qid')[0];
var pda = updata === 'updata'?'updata':'pdata';
if (content.img_size == 3 || content.img_size == 4) {
var more_imgs = '';
var should_reduce_h = '';
if (content.img.length == 4) {
$.each(content.img, function (index, val) {
if(val.indexOf('://') > -1){
val = '//' + val.split('://')[1];
}
more_imgs += '';
});
} else {
$.each(content.img, function (index, val) {
if(val.indexOf('://') > -1){
val = '//' + val.split('://')[1];
}
more_imgs += '';
});
more_imgs += '查看详情>>'
}
dom = '';
} else {
if(content.img[0] && content.img[0].indexOf('://') > -1){
content.img[0] = '//' + content.img[0].split('://')[1];
}
dom = '';
};
if (render_way == 'prepend') {
$(target_dom).prepend(dom);
} else {
$(target_dom).append(dom);
}
// pdata.init();
},
//右下小说
renderNovel:function(callback,num){
$.ajax({
url:proConfig.loadUrl.hotUrl,
// url:'http://ads.7654.com/loaderrorjson',
type:'GET',
dataType:'json',
success:function(res){
callback&&callback(res.data);
},
error:function(){
var data=[];
callback&&callback(data);
}
})
},
renderLoad:function(target_dom,startnum,area){
$.ajax({//右侧打底显示
url:proConfig.loadUrl.loadbaseUrl,
type:'GET',
dataType:'json',
success:function(res){
var qid=proConfig.qid.toutiao;
var adData=res.data.slice(startnum,startnum+1)[0];
if(area=='top'){
var dom='';
}else{
var dom=''+
'' + adData.title + '
'
}
$(target_dom).append(dom);
}
})
},
renderSsp:function(callback,rightNum){
var url;
var rightTop;
if(rightNum==2){
rightTop=''+proConfig.miniRight1+','+proConfig.miniRight2;
}else{
rightTop=proConfig.miniRight3;
}
if(location.host == 'news.7654.com'){
url = 'http://ssp.7654.com/ssp/ads?qid='+proConfig.miniQid+'&ad='+rightTop;
}else{
url = 'http://test-ssp.7654.com/ssp/ads?qid='+proConfig.miniQid+'&ad='+rightTop;
}
$.ajax({
url:url,
// url:'http://ads.7654.com/loaderrorjson',
type:'GET',
dataType:'json',
success:function(res){
console.log(res,'res')
var obj={};
if($.isEmptyObject(res.data)){
res=obj;
}
callback&&callback(res);
},
error:function(){
var data={};
callback(data)
}
})
},
//360大图样式
renderBig360: function (target_dom, adData, tagPosition) {
this.ad360index++;
var dom = '';
$(target_dom).before(dom);
},
renderVideo360: function (target_dom, adData, tagPosition) {
this.ad360index++;
var domvideo='';
if((Common.getIeVersion()!='IE8')&&(Common.getIeVersion()!='IE9')){
domvideo='