$.support.cors = true; // (function () { // 点击替换 var sec360 = false, page = 0, imptkArr = [], count = 0, row = "", flesh = false, imptkNum = 0, blaceNum = 1, _numC = 0,shNum=0,firstEn=true,shFirst=true,titleNum = 22,scrollH=535,_data=[],_status=0,row=0,_imgSrc = "",media_tab=true,renderNewsUrl="//news.7654.com/api/tpop_news_recommend/tpop2/" + conf.qid + "/" + row+"/6",numS=0; var linkS = location.pathname.split("/")[3] //ssp var url = '',_pro = getQuery('project'),sspNum=0,sspFlag=true, flag360Scroll=true, //midia滚动 _mediaLength=0, sspOrsongheng=true, metaFlag = true; songhengLength=0; //songheng回来的长度 if(location.host == 'news.qihaxiaoshuo.com'){ url = 'http://ssp.7654.com/ssp/ads?qid='; }else{ url = 'http://test-ssp.7654.com/ssp/ads?qid='; } if(linkS == "smartlook"){ sspOrsongheng = false } switch(linkS) { case "bz": titleNum = 20; scrollH=535; //---------------------------- break; case "htkk": titleNum = 20 scrollH=535; break; case "pdf": titleNum = 20 scrollH=524; break; default: titleNum = 22 } var url_scroll = function (arr) { $.each(arr, function (index, val) { $('body').append(''); }); }; var sh_scroll = function(arr){ if(!(arr instanceof Array)){ arr = arr.split(",") } $.each(arr, function (index, val) { var img = new Image(); img.src = val; }); } window.uploadConfig = { act: '', ad_id: getQuery('baidu_id'), ad_pos: conf.ad_pos, strategy_id: getQuery('strategy_id'), idea_id: getQuery('idea_id'), plan_id: getQuery('plan_id'), product_category: getQuery('product_category'), }; if(conf.ad_pos && getQuery("sspRender")){ uploadConfig.ad_type= 'dsp', uploadConfig.act = 'show'; uploadZhike(uploadConfig); } renderNews(); //newsRender function renderNews() { switch(linkS) { case "bz": renderNewsUrl="//news.toutiaobashi.com/api/tpop/list_new/"+conf.qid+"/1/16/6/"+row; break; case "htkk": renderNewsUrl="//news.7654.com/api/tpop_news_recommend/tpop2/"+conf.qid+"/"+row+"/"+6 break; case "pdf": renderNewsUrl="//news.toutiaobashi.com/api/tpop/list_new/"+conf.qid+"/1/93/6/"+row break; case "jsbtest": renderNewsUrl="//news.7654.com/api/tpop_news_recommend/tpop4/"+conf.qid+"/"+row+"/6"; break; case "llq": renderNewsUrl="//news.toutiaobashi.com/api/tpop/list_new/"+conf.qid+"/1/93/6/"+row; break; case "pv": renderNewsUrl="//news.7654.com/api/tpop_news_recommend/tpop3/"+conf.qid+"/"+row+"/6"; break; case "sp": renderNewsUrl="//news.7654.com/api/tpop_news_recommend/tpop5/"+conf.qid+"/"+row+"/6" break; case "ys01": renderNewsUrl="//news.7654.com/api/tpop_news_recommend/tpop1/"+conf.qid+"/"+row+"/6" break; case "smartlook": renderNewsUrl="//news.7654.com/api/tpop_news_recommend/tpop1/wx02/"+row break; default: renderNewsUrl; } $.ajax({ url: renderNewsUrl, dataType: "json", success: function (data) { flesh = true; page = page + 1; if(count != (page-1)*6 ){ count = (page-1)*6 } var _html=""; if(linkS == "bz" ||linkS == "pdf" || linkS == "llq" ){ _data = data.data.list; row = data.data.last_row; _status = data.status }else{ _status = data.code _data = data.data; row = data.last_row; } if (_status == 1) { $.each(_data, function (i, item) { if(linkS == "bz" ||linkS == "pdf" || linkS == "llq" ){ _imgSrc = item.content_img_list[0] }else{ _imgSrc = item.img } _numC = _numC + 1; _html += '
' }); $(".nano-content").append(_html); if(conf.shShow){ if(sspOrsongheng){ sspOrsongheng = false renderSsp(count) }else{ sspNum = 0 renderSongheng(count) } }else{ if(sspOrsongheng){ sspOrsongheng = false renderSsp(count) } else if(conf.mediaType =="360" && !sspOrsongheng){ conf.getShow? getShowId(conf.impct,count):render360(conf.showId,conf.impct,count); }else if(!sspOrsongheng){ renderBaidu(conf.impct,count) } } $(".nano").nanoScroller(); $(".nano").on("update", function (event, values) { if(conf.mediaType == "360" && flag360Scroll){ var _count =songhengLength+(sspNum/2==1?1:0) if(songhengLength == 0 && sspNum==1){ _count=1 } flag360Scroll = false; _mediaLength = songhengLength*2+(sspNum>=1?2:0) conf.getShow && _mediaLength<12? getShowId(conf.impct-_mediaLength,_count):_mediaLength<12&&render360(conf.showId,conf.impct-_mediaLength,_count); } if ($(".content .media").eq(imptkNum) && $(".content .media").eq(imptkNum).length > 0 && $(".content .media").eq(imptkNum)[0].getBoundingClientRect().top < scrollH) { imptkArr[0] && url_scroll(imptkArr[0]); imptkArr = imptkArr.slice(1); imptkNum++; } if($(".content .shClick").eq(shNum) && $(".content .shClick").eq(shNum).length > 0 && $(".content .shClick").eq(shNum)[0].getBoundingClientRect().top < scrollH){ if($(".content .shClick").eq(shNum).find("a").data("isinviewbackurl") =="1"){ sh_scroll($(".content .shClick").eq(shNum).find("a").data("inviewbackurls")) } shNum++ } if ($(".small").eq(blaceNum * 5 - 3)[0] && $(".small").eq(blaceNum * 5 - 3)[0].getBoundingClientRect().top < 380 && flesh) { blaceNum++; flesh = false; renderNews(); } }); } } }); } //将星 function getShowId(num,count) { var _replace = location.pathname.replace(/\//g,".") var _url ='//ads.7654.com/test/'+location.host+ _replace+'json?time='+new Date().getTime() if(location.host.indexOf('news.qihaxiaoshuo.com')>-1){ _url = '//ads.7654.com/prod/'+location.host+_replace+'json?time='+new Date().getTime() } $.ajax({ url:_url, dataType: "json", success: function (data) { if(data.i){ render360(data.i,num,count) }else{ // render360(conf.showId,num) } }, error:function(){ // render360(conf.showId,num) } }) } //shRender function renderSongheng(count){ if(metaFlag){ metaFlag = false $('head').append(''); if('CppCall' in window.external){ window.external.CppCall(conf.pageSize); } } var shUrl = location.host == "news.qihaxiaoshuo.com"?'//pcsoftwords.dftoutiao.com':"//106.75.98.65", type ="toutiao", newsitetype = "zhanmeng", qid = "03871", uid = (+new Date()) + Math.random().toString(10).substring(2, 6), os =getSystem(), pageposition = "sy", newstype="yule", newsuid=(+new Date()) + Math.random().toString(10).substring(2, 6), thisurl=location.href, pgnum=page, adnum=6-(sspNum<2?0:2)/2, tpopUrl = shUrl+'/dfpcitv/pcitv?type=' + type + '&newsitetype=' + newsitetype + '&qid=' + qid + '&uid=' + uid + '&os=' + os + '&pageposition=' + pageposition + '&newstype=' + newstype+ '&newsuid=' + newsuid + '&thisurl=' + thisurl + '&pgnum=' + pgnum + '&adnum=' + adnum; $.ajax({ url:tpopUrl, dataType: 'jsonp', jsonp: 'jsonpcallback', timeout: 5000, success: function (data) { // data.data = data.data.slice(0,2) songhengLength = data.data.length?data.data.length:0 _mediaLength = songhengLength*2+(sspNum<2?0:2) if(data.data.length>0){ media_tab && $(".meida_tab").text("嵩恒和"); media_tab = false; $.getJSON("//ad.kuaizip.com/advertise/userclick", { time: new Date().getTime(), localUrl: $.base64.encode("kZip.com" + location.pathname), project: $.base64.encode("tpop" + "_" + conf.proType), position: $.base64.encode("songheng_show"), act: $.base64.encode("songheng_"+data.data.length) }) songhengStyle(data.data,count) }else{ $.getJSON("//ad.kuaizip.com/advertise/userclick", { time: new Date().getTime(), localUrl: $.base64.encode("kZip.com" + location.pathname), project: $.base64.encode("tpop" + "_" + conf.proType), position: $.base64.encode("songheng_show"), act: $.base64.encode("songheng_error") }) if(conf.mediaType == "360" && songhengLength+sspNum<=2 && flag360Scroll){ flag360Scroll = false; conf.getShow? getShowId(conf.impct-_mediaLength,count):render360(conf.showId,conf.impct-_mediaLength,count); }else if(conf.mediaType == "360" && (songhengLength+sspNum<=2 || !flag360Scroll) ){ flag360Scroll = false; conf.getShow? getShowId(conf.impct-_mediaLength,count):render360(conf.showId,conf.impct-_mediaLength,count); } if(conf.mediaType == "baidu"){ renderBaidu(conf.impct-songhengLength,count) } } }, error:function(){ songhengLength=0 _mediaLength = sspNum>=1?2:0 if(!flag360Scroll && count>=6 || songhengLength==0 && flag360Scroll){ songhengLength==0 && flag360Scroll && sspNum >=1? count=1:"" if(conf.mediaType == "360" && songhengLength+sspNum<=2 && flag360Scroll){ flag360Scroll = false; conf.getShow? getShowId(conf.impct-_mediaLength,count):render360(conf.showId,conf.impct-_mediaLength,count); }else if(conf.mediaType == "360" && (songhengLength+sspNum<=2 || !flag360Scroll) ){ flag360Scroll = false; conf.getShow? getShowId(conf.impct-_mediaLength,count):render360(conf.showId,conf.impct-_mediaLength,count); } } $.getJSON("//ad.kuaizip.com/advertise/userclick", { time: new Date().getTime(), localUrl: $.base64.encode("kZip.com" + location.pathname), project: $.base64.encode("tpop" + "_" + conf.proType), position: $.base64.encode("songheng_show"), act: $.base64.encode("songheng_error") }) } }) } //meidaRender function render360(showId,num,_count) { if(metaFlag){ metaFlag = false $('head').append(''); if('CppCall' in window.external){ window.external.CppCall(conf.pageSize); } } UrlParam({ of: 4, newf: 1, type: 1, showid: showId, uid: (+new Date()) + Math.random().toString(10).substring(2, 6), reqtimes: page, impct: num }, function (data) { firstShow(showId) var _n = _count if (conf.twiceSubData) { if (sec360 && !data) { secDataUp(showId, "error") } if (sec360 && data) { secDataUp(showId, "success") } } if (!data) { if (sec360) { return; } sec360 = true; render360(showId,num,_n); return; } var _logNum = data.length for (var i = 0; i < _logNum; i++) { if (data[i] && data[i].type != 4) { if (conf.morRender) { moreRender(data[i],_n) } else { sigleRnder(data[i],_n) } if( !sspOrsongheng && sspNum>0){ sspNum = 0 } if( $(".content .media").eq(i) && $(".content .media").eq(i)[0].getBoundingClientRect().top < 535 && firstEn){ url_scroll(data[i].imptk) imptkNum++; }else if(data[i].type !=4){ firstEn = false; imptkArr.push(data[i].imptk) } } else { $(".small").eq(_n * 2).before(creatScript(conf.baidu_smua, 'tpop_company_bottom_' + (count * 3 + 1))).removeClass("bd"); $(".media").eq(0).removeClass("media"); } if(i%2!=0){ _n++ count++; } } }); } //media单样式 function sigleRnder(item,count) { if(conf.impct == 12 ){ numS = count }else if(conf.impct == 5){ numS= count * 2 } $(".small").eq(numS).before(''); } //media多样式 function moreRender(item,count) { var numS; if(conf.impct == 12 ){ numS = count }else if(conf.impct == 5){ numS= count * 2 } if (item.type == 3) { //大图 $(".small").eq(numS).before(''); } if (item.type == 2 || item.type == 5) { //多图 $(".small").eq(numS).before('