$.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.7654.com') { url = 'http://ssp.7654.com/ssp/ads?qid='; } else { url = 'http://test-ssp.7654.com/ssp/ads?qid='; } if (linkS == "smartlook" || linkS == "ys002") { 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 "jk": 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; case "ys002": renderNewsUrl = "//news.7654.com/api/tpop_news_recommend/tpop4/tpop01/" + row+"/6" 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 += '

' + item.title.substring(0, 25) + '

' + item.title + '

新闻
' }); $(".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); } var _el = $(".content .media").eq(imptkNum) if (_el && _el.length > 0 && _el[0].getBoundingClientRect().top < scrollH) { imptkArr[0] && url_scroll(imptkArr[0]); imptkArr = imptkArr.slice(1); imptkNum++; Targreport(_el,"show") } 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.7654.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.7654.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++; Targreport($(".content .media").eq(i),"show") } 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('

' + item.title.substring(0, titleNum) + '

广告
'); } //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('

' + item.title.substring(0, titleNum) + '

广告
'); } if (item.type == 2 || item.type == 5) { //多图 $(".small").eq(numS).before('
' + item.title.substring(0, 22) + '

' + ' ' + ' ' + ' ' + '

广告

'); } if (item.type == 1) { //单图 $(".small").eq(numS).before('

' + item.title.substring(0, 25) + '

广告
'); } } // bd function renderBaidu(num, count) { var numS = count for (var i = 0; i < num; i++) { $(".small").eq(numS).before(creatScript(conf.baidu_smua, 'tpop_company_bottom_' + (count * 3 + 1))).removeClass("bd") $(".media").eq(0).removeClass("media"); count++; numS++ } } // shStyle function songhengStyle(data, num) { if (data && data.length > 0) { var numS = num $.each(data, function (i, item) { if (item.adtype == "101") { //信息流大图 $(".small").eq(numS).before('

' + item.topic.substring(0, 22) + '

广告
'); } if (item.adtype == "102") {//信息流单图 $(".small").eq(numS).before('

' + item.topic.substring(0, 25) + '

广告
'); } if (item.adtype == "103" || item.adtype == "107") {//信息流多图 $(".small").eq(numS).before('

' + item.topic.substring(0, 22) + '

' + '

' + '

' + '

' + '
广告
'); } if (item.isshowbackurl) { sh_scroll(item.showbackurls) } if (item.isinviewbackurl && $(".shClick").eq(i)[0].getBoundingClientRect().top < 535 && shFirst) { sh_scroll(item.inviewbackurls) shNum++ } else { shFirst = false; } count++; numS++; }); if (songhengLength + (sspNum < 2 ? 0 : sspNum) < 6) { if (conf.mediaType == "360" && songhengLength + sspNum <= 2 && flag360Scroll) { flag360Scroll = false; conf.getShow ? getShowId(conf.impct - _mediaLength, numS) : render360(conf.showId, conf.impct - _mediaLength, numS); } else if (conf.mediaType == "360" && (songhengLength + sspNum <= 2 || !flag360Scroll)) { flag360Scroll = false; conf.getShow ? getShowId(conf.impct - _mediaLength, numS) : render360(conf.showId, conf.impct - _mediaLength, numS); } if (conf.mediaType == "baidu") { renderBaidu(conf.impct - songhengLength, numS) } } } else { if (conf.mediaType == "360" && songhengLength + sspNum <= 2 && flag360Scroll) { flag360Scroll = false; conf.getShow ? getShowId(conf.impct - _mediaLength, numS) : render360(conf.showId, conf.impct - _mediaLength, numS); } else if (conf.mediaType == "360" && (songhengLength + sspNum <= 2 || !flag360Scroll)) { flag360Scroll = false; conf.getShow ? getShowId(conf.impct - _mediaLength, numS) : render360(conf.showId, conf.impct - _mediaLength, numS); } if (conf.mediaType == "baidu") { renderBaidu(conf.impct - songhengLength, numS) } } } function UrlParam(options, callback) { var tpopUrl = " http://show.g.mediav.com", tpopType = options.type, tpopOf = options.of, tpopOfImpct = options.impct, tpopNewf = options.newf, tpopShowid = options.showid, tpopUid = options.uid, tpopReqtimes = options.reqtimes, tck = getQuery("tck") if (document.location.protocol == "http:") { tpopUrl = 'http://show.g.mediav.com/s?type=' + tpopType + '&of=' + tpopOf + '&newf=' + tpopNewf + '&showid=' + tpopShowid + '&uid=' + tpopUid + '&reqtimes=' + tpopReqtimes + '&impct=' + tpopOfImpct; } else { tpopUrl = 'https://show-g.mediav.com/s?type=' + tpopType + '&of=' + tpopOf + '&newf=' + tpopNewf + '&scheme=https' + '&showid=' + tpopShowid + '&uid=' + tpopUid + '&reqtimes=' + tpopReqtimes + '&impct=' + tpopOfImpct; }; tck ? tpopUrl += '&tck=' + tck : "" if (conf.ref) { tpopUrl += "&refurl=" + encodeURIComponent(document.referrer) } $.ajax({ url: tpopUrl, type: 'get', dataType: 'jsonp', timeout: 5000, jsonp: 'jsonp', success: function (data) { callback && callback(data.ads); }, error: function (data) { // renderBaidu() } }); }; //百度广告点击上报 window.addEventListener ? window.addEventListener('blur', detectFocus, true) : window.attachEvent('onfocusout', detectFocus); function detectFocus() { var $activeElement = $(document.activeElement); var activeName = $activeElement.get(0).tagName; if (activeName.toUpperCase() === 'IFRAME') { var _parent = getParent($activeElement);//返回iframe的上一级 $.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($(_parent[0]).attr("position")) }).done(function (data) { }); function getParent(obj) { var _parent = obj.parents(); for (var i = 0; i < _parent.length; i++) { return _parent.eq(i); } } } setTimeout("window.focus()", 50); } var showFlag = true; function renderSsp(n) { $.ajax({ url: url + _pro + '&time=' + new Date().getTime() + "&ad=" + conf.ad_pos, type: 'get', dataType: 'json', success: function (data) { var numS = n var _data = data.data[conf.ad_pos]; if (typeof _data != "undefined" && _data.script.length > 0) { $.each(_data.script, function (i, item) { if (sspNum >= 2) { return } if (item.type == 2) { //直客 就是order if (item.order_type == 1) { // 厂商 sspNum = sspNum + 1; var sspUrl = item.idea.landing_page; sspUrl.indexOf("?") > -1 ? sspUrl = sspUrl + "&adtype=zhike" : sspUrl = sspUrl + "?adtype=zhike" $(".small").eq(numS).before('

' + item.idea.title.substring(0, 22) + '

广告
') if (sspNum == 1) { metaFlag = false $('head').append(''); if ('CppCall' in window.external) { window.external.CppCall(conf.pageSize); } } } window.uploadConfig = { ad_pos: conf.ad_pos, ad_id: _data["baidu_id"], ad_type: "zhike", strategy_id: item.strategy_id, idea_id: item.idea_id, plan_id: item.plan_id, act: "show", product_category: item.product_category, }; uploadZhike(uploadConfig); } }) if (sspNum >= 2) { count++; } } if (conf.shShow) { renderSongheng(count); } else { flag360Scroll = false if (conf.mediaType == "360") { conf.getShow ? getShowId(conf.impct - (sspNum / 2 == 1 ? 2 : 0), count) : render360(conf.showId, conf.impct - (sspNum / 2 == 1 ? 2 : 0), count); } else { renderBaidu(conf.impct - (sspNum / 2 == 1 ? 2 : 0), count) } } }, error: function () { if (conf.shShow) { renderSongheng(count); } else { flag360Scroll = false if (conf.mediaType == "360") { conf.getShow ? getShowId(conf.impct - (sspNum / 2 == 1 ? 2 : 0), count) : render360(conf.showId, conf.impct - (sspNum / 2 == 1 ? 2 : 0), count); } else { renderBaidu(conf.impct - (sspNum / 2 == 1 ? 2 : 0), count) } } } }) } function Targreport(el,act){ if(conf.targreport){ var _child = el.find("a"); var _imageadress = _child.data("imageadress"); var _imagetitle = _child.data("imagetitle") if(_child.length>1){ _imageadress = []; _child.each((function(i,item){ if(i>0){ _imageadress.push($(item).data("imageadress")) } })) } var _obj = { imageadress:_imageadress, imagetitle:_imagetitle, act:act } // console.log(_obj) if ('SpecialAdsLog' in window.external) { window.external.SpecialAdsLog(JSON.stringify(_obj)); } } } // })();