//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); }, 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; }, }; window.Common = common; })(); Configuration(); //根据域名配置 var proConfig; function Configuration() { // 默认配置 var proObject = { name: 'kuaiya', mini_name: '005', qid: {rewen:'mininew',toutiao:'mininew',shehui:'mininew',yule:'mininew',shipin:'mininew',tiyu:'mininew',qiche:'mininew',junshi:'mininew',yangsheng:'mininew',youxi:'mininew',guoji:'mininew',shishang:'mininew',lishi:'mininew',keji:'mininew',caijing:'mininew',xiaohua:'mininew'}, left_tab:{youxi:'游戏',yangsheng:'养生',junshi:'军事',qiche:'汽车',tiyu:'体育',shipin:'视频',yule:'娱乐',shehui:'社会', toutiao:'推荐',guoji:'国际',caijing:'财经',xiaohua:'笑话',qinggan:'情感',gaoxiao:'搞笑',lieqi:'猎奇',lvyou:'旅游',renwen:'人文'}, left_tab_more:{keji:'科技',shishang:'时尚',lishi:'历史'}, loadUrl:{online_url1:'//news.toutiaobashi.com/api/tpop/list_new/mininew/1/',online_url2:'//news.toutiaobashi.com/api/tpop/list_new/mininew/1/', hotNews:'//news.toutiaobashi.com/api/hot/limit/2',recommendUrl:'//news.toutiaobashi.com/api/tpop/list_new/mininew/1/34/10', flowUrl:'//news.toutiaobashi.com/api/daohang_news_data/mininewjx/34/11', hotUrl:'//news.toutiaobashi.com/api/wps_news_list/14/mininewhot', }, name:{'推荐':93,'社会':14,'娱乐':16,'视频':24,'搞笑':13,'猎奇':21,'图片':22,'游戏':29,'体育':17,'汽车':28,'财经':18,'健康':15, '星座':27,'军事':20,'情感':26,'国际':12,'时尚':25,'科技':19,'育儿':30,'人文':23,'旅游':31,'美文':32}, 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,lieqi:1,lvyou:1,renwen:1}, typeKey: {rewen:33,toutiao:34,shehui:14,yule:16,shipin:24,tiyu:17,qiche:28,junshi:20,yangsheng:39, youxi:29,guoji:12,shishang:25,lishi:46,keji:19,caijing:18,xiaohua:13,qinggan:26,gaoxiao:13,lieqi:21,lvyou:31,renwen:23,meiwen:32}, typeKeyRow: {rewen:'',toutiao:'',shehui:'',yule:'',shipin:'',tiyu:'',qiche:'',junshi:'',yangsheng:'', youxi:'',guoji:'',shishang:'',lishi:'',keji:'',caijing:'',xiaohua:'',qinggan:'',gaoxiao:'',lieqi:'',lvyou:'',renwen:''}, // message_flow_showId:"", // bottom_right_showId:"", // top_right_showId:"", normal_baidu_smua: 'd=p&s=b&u=u3636592&w=500&h=96', //数据流百度广告 right_top_baidu_smua_1: 'd=p&s=b&u=u3678551&w=190&h=110', //右上1百度广告 hot_baidu_smua_1: 'd=p&s=b&u=u3681161&w=189&h=132', //热闻百度广告1 hot_baidu_smua_2:'d=p&s=b&u=u3681161&w=189&h=132', //热闻百度广告2 ad360ClickNum: 0, // 360广告点击次数-黑名单-10次以上 }; proConfig = proObject; }; var user_uid = Common.getUserId(); var timer0510; var clickFlag=true; //tab-hover $('body').on('click','.left_nav .nav_item',function () { var clickFlag=false; var first_nav=$('.first_nav > li.active').attr('date-type'); var scroll_con=$('.scroll_con').attr('class') if($(this).hasClass('active')){ return false; } if(timer0510){ clearInterval(timer0510); timer0510=null; } var x=0; var that = this; timer0510 = setInterval(function () { x++; if(x>2){ clearInterval(timer0510); $('.left_nav .nav_item').removeClass('active'); $(that).addClass('active'); $('.left_nav .nav_item_part').removeClass('active'); var type = $(that).attr('date-type'); if (type == 'redian') { type == 'toutiao2' } 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); var method = $(that).attr('method'); var first_view = $('.left_nav li:eq(0)').attr('method'); if (type != 'toutiao' && !first_view) { $('.left_nav li:eq(0)').attr('method', 'change_view'); } Mini[method] ? Mini[method]($(that), window.event) : ''; } }, 300) }); //更多的点击事件 $(".more_tab").click(function () { $(".first_nav").toggle("nav_hide"); $(".second_nav").toggle("nav_show"); }); var tab = $(".more_tab span"); tab.click(function () { if ($(this).hasClass("rectangle1")) { $(this).removeClass("rectangle1").addClass("rectangle2") } else { $(this).addClass("rectangle1").removeClass("rectangle2") } }) //置顶 $("#container .content").scroll(function () { if ($("#container .content").scrollTop() > 100) { $(".roof_placement").fadeIn(200); } else { $(".roof_placement").fadeOut(200); } if ($("#container .content").scrollTop() > 1065) { if($(".right_pannel .case").eq(0).html()){ $("#container .show_case").css({'position': 'fixed', 'top': '50px'}); }else{ $("#container .show_case").css({'position': 'fixed', 'top': '40px'}); } $(".hot_news").css({'position': 'fixed', 'top': '10px'}); $(".showcase").css({'position': 'fixed', 'top': '290px'}); $(".news_bottom").css({'display':"block",'position': 'fixed', 'top': '430px'}); } else { $("#container .show_case").css({'position': 'static'}); $(".hot_news").css({'position': 'static'}); $(".showcase").css({'position': 'static'}); $(".news_bottom").css({'display':"none",'position': 'static'}); } }) $(".roof_placement").click(function () { $("#container .content").animate({scrollTop: 0}, 1000); return false; }) //咨询和精选切换 $(".let_bar").on("click", "a", function () { $(this).addClass("active").siblings().removeClass("active"); if ($('.let_bar .consule').hasClass('active')) { $('.cascade_flow').addClass('content_hide'); $('.content').removeClass('content_hide'); $('.left_nav').removeClass('content_hide'); $('.content').scrollTop(0); $("#container .show_case").css({'position': 'static'}); } else { $('.cascade_flow').removeClass('content_hide'); $('.content').addClass('content_hide'); $('.left_nav').addClass('content_hide'); $.ajax({ url: '//news.toutiaobashi.com/api/daohang_news_data/mininewjx/34/11', type: 'get', dataType: 'json', success: function (res) { var dataArr = res.data; Mini.flowArr.push(dataArr); $.each(dataArr, function (index, item) { $(".cascade_flow").append('

' + item.title + '

' + item.cat_name + '' + item.source + '
'); }); var divs = $(".cascade_flow div"); var pageWidth = 887; var boxWidth = 268; var gap = 10; var cols = 3//列数; var arr = []; //设置第一行的盒子 for (var i = 0; i < cols; i++) { //第一行盒子的top是0 divs[i].style.top = 0; //设置盒子的left值 divs[i].style.left = i * (boxWidth + gap) + "px"; //将盒子的高度添加到数组中,方便后续的排列 arr.push(divs[i].offsetHeight); } //其他的盒子 for (i = cols; i < divs.length; i++) { //1. 获取到数组最小列的下标 var index = 0;//假设数组第0项就是最小值 var min = arr[0]; //遍历数组 for (var j = 0; j < arr.length; j++) { if (min > arr[j]) { min = arr[j]; index = j; } } //2. 设置left divs[i].style.left = index * (boxWidth + gap) + "px"; //3. 设置top divs[i].style.top = min + gap + "px"; //4. 修改高度 arr[index]:最小列的高度 加上刚刚新增的盒子的高度 arr[index] += divs[i].offsetHeight + gap; } } }) } }) $('body').on('mouseout', '.left_nav .nav_item', 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); }); // 将参数序列化,形如 ‘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.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 = ''; this.rightTwiceAd = true this.flowArr = []; this.cityId=''; if (typeof Mini_page.instance === 'object') { return Mini_page.instance; } this.instance = this; this.pathname = window.location.pathname.slice(1, -1); this.refreshClick=true; } 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 = location.hostname==="localhost"?"test/test.gamma-minipage.news.7654.com.0105.":('test/'+location.host+location.pathname.replace(/\//g,".")); } $.ajax({ url:'http://ads.7654.com/'+urlhost+'json?t='+new Date().getTime(), dataType:'json', success: function (res) { proConfig.message_flow_showId = res.l; proConfig.bottom_right_showId=res.rb; proConfig.top_right_showId=res.rt; $.ajax({ url: proConfig.loadUrl.recommendUrl, type: 'get', dataType: 'json', success: function (response) { Mini.refreshClick=false; var data = response.data.list; var orderIndex = 1; $.each(data, function (index, val) { val.indexOrder = orderIndex; orderIndex++; obj.render('.scroll_con', val, "append", 'show', true, false, 'pdata'); }); function url_scroll (arr) { $.each(arr, function (index, val) { $('body').append(''); }); }; 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; window.first_item_360bool_7 = true; window.first_item_360bool_8 = true; window.first_item_360bool_9 = true; window.first_item_360bool_10 = 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]); }else{ obj.render360('.scroll_con .list_item:eq(0)', res[0]); } url_scroll(res[0].imptk); upload($('.scroll_con .list_item:eq(0) .img_click_gg'),'show') } if (res[1]) { obj.render360('.scroll_con .list_item:eq(2)', res[1]); url_scroll(res[1].imptk); } if (res[2]) { obj.render360('.scroll_con .list_item:eq(4)', res[2]); // url_scroll(res[2].imptk); } if (res[3]) { obj.render360('.scroll_con .list_item:eq(6)', res[3]); } if (res[4]) { obj.render360('.scroll_con .list_item:eq(8)', res[4]); } if (res[5]) { obj.render360('.scroll_con .list_item:eq(10)', res[5]); } if (res[6]) { obj.render360('.scroll_con .list_item:eq(12)', res[6]); } if (res[7]) { obj.render360('.scroll_con .list_item:eq(14)', res[7]); } if (res[8]) { obj.render360('.scroll_con .list_item:eq(16)', res[8]); } if (res[9]) { obj.render360('.scroll_con .list_item:eq(18)', res[9]); } var showRefreshBool = true; Mini.refreshClick=true; $('.content').on('scroll', function (event) { if ($(".media").eq(6)[0] && $(".media").eq(6)[0].getBoundingClientRect().top <= 862) { $(".media").removeClass("media") var SCROLL_TOP = $(this).scrollTop(); var CLIENT_HEIGHT = 600; 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: obj.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); } var SCROLL_TOP = $(this).scrollTop(); var thirdTop = $('.scroll_con .list_item')[4] ? $('.scroll_con .list_item')[4].getBoundingClientRect().top : 862; var fourththirdTop = $('.scroll_con .list_item')[6] ? $('.scroll_con .list_item')[6].getBoundingClientRect().top : 862; var fifthTop = $('.scroll_con .list_item')[8] ? $('.scroll_con .list_item')[8].getBoundingClientRect().top : 862; var sixthTop = $('.scroll_con .list_item')[10] ? $('.scroll_con .list_item')[10].getBoundingClientRect().top : 862; var sevenTop = $('.scroll_con .list_item')[12] ? $('.scroll_con .list_item')[12].getBoundingClientRect().top : 862; var eightTop = $('.scroll_con .list_item')[14] ? $('.scroll_con .list_item')[14].getBoundingClientRect().top : 862; var nineTop = $('.scroll_con .list_item')[16] ? $('.scroll_con .list_item')[16].getBoundingClientRect().top : 862; var tenTop = $('.scroll_con .list_item')[18] ? $('.scroll_con .list_item')[18].getBoundingClientRect().top : 862; if (thirdTop - 862 < 0 && window.first_item_360bool_3) { window.first_item_360bool_3 = false; if (obj.ad360data[2]) { url_scroll(obj.ad360data[2].imptk); } } if (fourththirdTop - 862 < 0 && window.first_item_360bool_4) { window.first_item_360bool_4 = false; if (obj.ad360data[3]) { url_scroll(obj.ad360data[3].imptk); } } if (fifthTop - 862 < 0 && window.first_item_360bool_5) { window.first_item_360bool_5 = false; if (obj.ad360data[4]) { url_scroll(obj.ad360data[4].imptk); } } if (sixthTop - 862 < 0 && window.first_item_360bool_6) { window.first_item_360bool_6 = false; if (obj.ad360data[5]) { url_scroll(obj.ad360data[5].imptk); } } if (sevenTop - 862 < 0 && window.first_item_360bool_7) { window.first_item_360bool_7 = false; if (obj.ad360data[6]) { url_scroll(obj.ad360data[6].imptk); } } if (eightTop - 862 < 0 && window.first_item_360bool_8) { window.first_item_360bool_8 = false; if (obj.ad360data[7]) { url_scroll(obj.ad360data[7].imptk); } } if (nineTop - 862 < 0 && window.first_item_360bool_9) { window.first_item_360bool_9 = false; if (obj.ad360data[8]) { url_scroll(obj.ad360data[8].imptk); } } if (tenTop - 862 < 0 && window.first_item_360bool_10) { window.first_item_360bool_10 = false; if (obj.ad360data[9]) { url_scroll(obj.ad360data[9].imptk); } } }); }, proConfig.message_flow_showId, 10); }, 1000); Mini.get360Ad(1, function (res) { if (res[0]) { $('.right_pannel .case:eq(0)').html('
' + '' + '
' + '

' + res[0].title + '

' + '
' + '广告' + '
' + '
') url_scroll(res[0].imptk); upload($('.right_pannel .case:eq(0) .img_click_gg'),'show') } if (res[1]) { $('.right_pannel .case:eq(1)').html('
' + '' + '
' + '

' + res[1].title + '

' + '
' + '广告' + '
' + '
') url_scroll(res[1].imptk); } }, proConfig.top_right_showId, 2); Mini.get360Ad(1, function (res) { if (res[0]) { $('.right_pannel .showcase:eq(0)').html('
' + '' + '
' + '

' + res[0].title + '

' + '
' + '广告' + '
' + '
') url_scroll(res[0].imptk); upload($('.right_pannel .showcase:eq(0) .img_click_gg'),'show') } },"", 1); }, error: function () { } }); } }) // return 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'); proConfig.ad360ClickNum ++; // obj.blackList(); }); }, // 瀑布流初始化 waterfallInit: function () { var obj = this; $.ajax({ url: '//news.toutiaobashi.com/api/daohang_news_data/mininewjx/34/11', type: 'get', dataType: 'json', success: function (res) { var dataArr = res.data; obj.flowArr.push(dataArr); $.each(dataArr, function (index, item) { $(".cascade_flow").append('

' + item.title + '

' + item.cat_name + '' + item.source + '
'); }); Mini.waterfall_data(); } }) }, // 瀑布流初始数据获取 waterfall_data: function (params) { var divs = $(".cascade_flow div"); var pageWidth = 887; var boxWidth = 268; var gap = 10; var cols = 3;//列数 var arr = []; //设置第一行的盒子 for (var i = 0; i < cols; i++) { //第一行盒子的top是0 divs[i].style.top = 0; //设置盒子的left值 divs[i].style.left = i * (boxWidth + gap) + "px"; //将盒子的高度添加到数组中,方便后续的排列 arr.push(divs[i].offsetHeight); } //其他的盒子 for (i = cols; i < divs.length; i++) { //1. 获取到数组最小列的下标 var index = 0;//假设数组第0项就是最小值 var min = arr[0]; //遍历数组 for (var j = 0; j < arr.length; j++) { if (min > arr[j]) { min = arr[j]; index = j; } } //2. 设置left divs[i].style.left = index * (boxWidth + gap) + "px"; //3. 设置top divs[i].style.top = min + gap + "px"; //4. 修改高度 arr[index]:最小列的高度 加上刚刚新增的盒子的高度 arr[index] += divs[i].offsetHeight + gap; } }, // 页面初始化数据获取 fetch_data: function (params, btn) { var loading_dom = '
加载中⋅⋅⋅
'; $('.content').prepend(loading_dom); var obj = this; var onlineUrl1 = proConfig.loadUrl.online_url1; var onlineUrl2 = proConfig.loadUrl.online_url2; if (obj.refresh_dev) { onlineUrl = onlineUrl1 + proConfig.typeKey[params.type] + '/10/' + proConfig.typeKeyRow[params.type] } if (obj.refresh_scroll || obj.refresh_tab) { onlineUrl = onlineUrl1 + proConfig.typeKey[params.type] + '/10/' + proConfig.typeKeyRow[params.type] } $.ajax({ url: onlineUrl, type: 'get', dataType: 'json', cache: false, error: function () { fetch_data(null); }, success: function (res) { if (res.status == 1) { proConfig.typeKeyRow[params.type] = res.data.last_row; res.data = res.data.list; //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); }); setTimeout(function () { obj.get360Ad(obj.bottomOutTime, function (res) { Mini.refreshClick=true; 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; window.first_item_360bool_7 = true; window.first_item_360bool_8 = true; window.first_item_360bool_9 = true; window.first_item_360bool_10 = true; $.each(res, function (index, val) { obj.ad360data.push(val); obj.imptk360.push(val.imptk); }); if (res[0]) { obj.renderBig360('.scroll_con .list_item:eq(0)', res[0]); url_scroll(res[0].imptk); } if (res[1]) { obj.render360('.scroll_con .list_item:eq(2)', res[1]); url_scroll(res[1].imptk); } if (res[2]) { obj.render360('.scroll_con .list_item:eq(4)', res[2]); // url_scroll(res[2].imptk); } if (res[3]) { obj.render360('.scroll_con .list_item:eq(6)', res[3]); } if (res[4]) { obj.render360('.scroll_con .list_item:eq(8)', res[4]); } if (res[5]) { obj.render360('.scroll_con .list_item:eq(10)', res[5]); } if (res[6]) { obj.render360('.scroll_con .list_item:eq(12)', res[6]); } if (res[7]) { obj.render360('.scroll_con .list_item:eq(14)', res[7]); } if (res[8]) { obj.render360('.scroll_con .list_item:eq(16)', res[8]); } if (res[9]) { obj.render360('.scroll_con .list_item:eq(18)', res[9]); } var showRefreshBool = true; $('.content').on('scroll', function (event) { var SCROLL_TOP = $(this).scrollTop(); var thirdTop = $('.scroll_con .list_item')[4] ? $('.scroll_con .list_item')[4].getBoundingClientRect().top : 862; var fourththirdTop = $('.scroll_con .list_item')[6] ? $('.scroll_con .list_item')[6].getBoundingClientRect().top : 862; var fifthTop = $('.scroll_con .list_item')[8] ? $('.scroll_con .list_item')[8].getBoundingClientRect().top : 862; var sixthTop = $('.scroll_con .list_item')[10] ? $('.scroll_con .list_item')[10].getBoundingClientRect().top : 862; var sevenTop = $('.scroll_con .list_item')[12] ? $('.scroll_con .list_item')[12].getBoundingClientRect().top : 862; var eightTop = $('.scroll_con .list_item')[14] ? $('.scroll_con .list_item')[14].getBoundingClientRect().top : 862; var nineTop = $('.scroll_con .list_item')[16] ? $('.scroll_con .list_item')[16].getBoundingClientRect().top : 862; var tenTop = $('.scroll_con .list_item')[18] ? $('.scroll_con .list_item')[18].getBoundingClientRect().top : 862; if (thirdTop - 862 < 0 && window.first_item_360bool_3) { // $('#refresh').show(); window.first_item_360bool_3 = false; if (obj.ad360data[2]) { url_scroll(obj.ad360data[2].imptk); } } if (fourththirdTop - 862 < 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 - 862 < 0 && window.first_item_360bool_5) { window.first_item_360bool_5 = false; if (obj.ad360data[4]) { url_scroll(obj.ad360data[4].imptk); } } if (sixthTop - 862 < 0 && window.first_item_360bool_6) { window.first_item_360bool_6 = false; if (obj.ad360data[5]) { url_scroll(obj.ad360data[5].imptk); } } if (sevenTop - 862 < 0 && window.first_item_360bool_6) { window.first_item_360bool_7 = false; if (obj.ad360data[6]) { url_scroll(obj.ad360data[6].imptk); } } if (eightTop - 862 < 0 && window.first_item_360bool_6) { window.first_item_360bool_8 = false; if (obj.ad360data[7]) { url_scroll(obj.ad360data[7].imptk); } } if (nineTop - 862 < 0 && window.first_item_360bool_6) { window.first_item_360bool_9 = false; if (obj.ad360data[8]) { url_scroll(obj.ad360data[8].imptk); } } if (tenTop - 862 < 0 && window.first_item_360bool_6) { window.first_item_360bool_10 = false; if (obj.ad360data[9]) { url_scroll(obj.ad360data[9].imptk); } }0 }); }, proConfig.message_flow_showId, 10); }, 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]) { obj.render360('.scroll_con .list_item:eq(' + (list_len + 2) + ')', res[0], list_len + 2); } if (res[1]) { obj.render360('.scroll_con .list_item:eq(' + (list_len + 6) + ')', res[1], list_len + 6); } if (res[2]) { 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 (620 + SCROLL_TOP > list_360item_h_1 && item_360bool_1) { item_360bool_1 = false; if (obj.imptk360[0]) { url_scroll(obj.imptk360[0]); } } if (1500 + SCROLL_TOP > list_360item_h_2 && item_360bool_2) { item_360bool_2 = false; if (obj.imptk360[1]) { url_scroll(obj.imptk360[1]); } } if (1500 + SCROLL_TOP > list_360item_h_3 && item_360bool_3) { item_360bool_3 = false; if (obj.imptk360[2]) { url_scroll(obj.imptk360[2]); } } }); obj.bool = true; },proConfig.message_flow_showId) } } 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.bottom_right_showId, recommend_adnum = num || 3, recommendk_uid = recommend_uid(), recommend_param; 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; } 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; } $.ajax({ type: 'get', url: recommend_param, dataType: 'jsonp', jsonp: 'jsonp', success: function (data) { var d = data.ads ? data.ads : []; callback && callback(d); }, error: function () { callback(null); } }) }, // 数据渲染 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 , important_href = '', 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'; var cat_name=""; for(var i in proConfig.name){ if(content.cat_id==proConfig.name[i]){ cat_name=i; } } if (content.content_img_num == 3 || content.content_img_num == 4) { var more_imgs = ''; var should_reduce_h = ''; if (content.content_img_list.length == 4) { $.each(content.content_img_list, function (index, val) { if (val.indexOf('://') > -1) { val = '//' + val.split('://')[1]; } more_imgs += ''; }); } else { $.each(content.content_img_list, function (index, val) { if (val.indexOf('://') > -1) { val = '//' + val.split('://')[1]; } more_imgs += ''; }); more_imgs += '查看详情>>' } dom = '
' + '' + '

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

' + '

'+cat_name+'来源:' + type_dom + author_info + '

' + '
' + '
' + more_imgs + '
' + '
'; } else { if (content.cover) { dom = '
' + '' + '
' + '

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

' + '

'+cat_name+'来源:' + content.source + '

' + '
' + '
'; } else if (content.content_img_list[0]) { content.content_img_list[0] = '//' + content.content_img_list[0].split('//')[1]; dom = '
' + '' + '
' + '

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

' + '

'+cat_name+'来源:' + content.source + '

' + '
' + '
'; } } if (render_way == 'prepend') { $(target_dom).prepend(dom); } else { $(target_dom).append(dom); } // pdata.init(); }, // 百度广告右上一 renderTopRightBaiduO: function (target_dom) { $(target_dom).eq(0).append('
'); loadPjs('//www.nkscdn.com/smu0/o.js', 'b-toprighto', 'toprighto', proConfig.right_top_baidu_smua_1); }, renderHotBaidu1: function (target_dom) { if (proConfig.hot_baidu_smua_1) { $(target_dom).after('
  • '); loadPjs('//www.nkscdn.com/smu0/o.js', 'b-hotad', 'hotad', proConfig.hot_baidu_smua_1); } }, // 百度广告24小时热闻_2 renderHotBaidu2: function (target_dom) { if (proConfig.hot_baidu_smua_2) { $(target_dom).after('
  • '); loadPjs('//www.nkscdn.com/smu0/o.js', 'b-hotad', 'hotad2', proConfig.hot_baidu_smua_2); } }, // 360广告数据流 render360: function (target_dom, adData) { this.ad360index++; if (adData.type == 2) { if(adData.imgh == adData.imgw){ var more_imgs = ''; $.each(adData.assets, function (i, v) { more_imgs += '
    ' }) var dom = '
    ' + '' + '

    ' + adData.title + '

    ' + '
    ' + '
    ' + more_imgs + '
    ' + '

    广告·' + adData.src + '

    ' + '
    '; }else{ var more_imgs = ''; $.each(adData.assets, function (i, v) { more_imgs += '
    ' }) var dom = '
    ' + '' + '

    ' + adData.title + '

    ' + '
    ' + '
    ' + more_imgs + '
    ' + '

    广告·' + adData.src + '

    ' + '
    '; } } else { var dom = '
    ' + '' + '
    ' + '

    ' + adData.title + '

    ' + '

    广告

    ' + '
    ' + '
    '; } $(target_dom).before(dom); }, renderBig360: function (target_dom, adData, tagPosition) { this.ad360index++; var dom = '
    ' + '' + '

    ' + adData.title + '广告

    ' + '
    ' + '
    ' + '
    '; $(target_dom).before(dom); }, // tab切换 change_view: function (btn) { this.ad360data = []; this.ad360index = 0; this.bottomOutTime = 1; window.first_item_360bool_3 = true; window.first_item_360bool_4 = true; window.first_item_360bool_5 = true; window.first_item_360bool_6 = true; if (btn.hasClass('nav_item')) { if (btn.index() == window.current_index1) { return } } else { if (btn.attr('click_time') == 1) { $('.more_nav .nav_item_part').attr('click_time', ''); return } } $('.content').scrollTop(0); this.startkey = ''; this.newkey = ''; var obj = this; this.bool = true; this.pgnum_bot = 1; this.pgnum_top = 1; var oType = btn.attr('date-type'); if (oType === 'lieqi') { $('#refresh').hide(); } else { $('#refresh').show(); } this.type = oType; this.bottomOutTime = 1; proConfig.qid_index[oType] = 1; var params = { type: oType, startkey: obj.startkey, newkey: obj.newkey, pgnum: obj.pgnum_bot, uid: user_uid, qid: '01747', }; $('.scroll_con').html("").attr('class', 'scroll_con ' + oType); obj.refresh_tab = true; obj.fetch_data(params, btn); }, /** * 黑名单系统 * @constructor */ blackList: function (){ var urlblack; var qid=Common.GetQueryString('qid'); var project="mininews_ys001"; var uid=Common.GetQueryString('uid') || "none"; var redirectUrl=window.location.href.split("?")[1]; if(location.host === 'news.7654.com'){ urlblack ='http://ssp.7654.com/monitor?qid='+qid+'&project='+project+'&uid='+uid; }else{ urlblack = 'http://test-ssp.7654.com/monitor?qid='+qid+'&project='+project+'&uid='+uid; } $.ajax({ url:urlblack, type:'GET', dataType:'json', success:function(res){ if(res.ret==0||proConfig.ad360ClickNum>20){ upload($('.scroll_con .news_item:eq(0)' ),'otherurl_show'); // 右上show上报 window.location.href='http://news.7654.com/mini_new4/0101/?'+redirectUrl; } } }) } }; // 广告uid function recommend_uid() { return (+new Date()) + Math.random().toString(10).substring(2, 6); } /*360曝光*/ var url_scroll = function (arr) { $.each(arr, function (index, val) { $('body').append(''); }); }; var Mini = new Mini_page(); Mini.bindEvent(); //点击刷新 $(".refresh").click(function(){ if(!Mini.refreshClick){ return; } Mini.refreshClick=false; this.ad360data = []; this.ad360index = 0; this.bottomOutTime = 1; window.first_item_360bool_3 = true; window.first_item_360bool_4 = true; window.first_item_360bool_5 = true; window.first_item_360bool_6 = true; $('.content').scrollTop(0); this.startkey = ''; this.newkey = ''; var obj = this; this.bool = true; this.pgnum_bot = 1; this.pgnum_top = 1; var oType = $(".left_nav .active").attr('date-type'); if (oType === 'lieqi') { $('#refresh').hide(); } else { $('#refresh').show(); } this.type = oType; this.bottomOutTime = 1; proConfig.qid_index[oType] = 1; var params = { type: oType, startkey: Mini.startkey, newkey: Mini.newkey, pgnum: Mini.pgnum_bot, uid: user_uid, qid: '01747', }; $('.scroll_con').html("").attr('class', 'scroll_con ' + oType); Mini.refresh_tab = true; Mini.fetch_data(params,$(".left_nav .active")); }) // 热闻数据init $.ajax({ url: proConfig.loadUrl.hotUrl, type: 'get', dataType: 'json', success: function (res) { var today_news_data; today_news_data = res.data; var arr_today = []; var arr_week = []; var arr_hot = []; var arr_bottom=[]; $.each(today_news_data, function (index, val) { if (index < 3) { arr_today.push(val); }else if(index<5&index>2){ arr_bottom.push(val); }else if (index > 4 && index < 12) { arr_week.push(val); } else if (index > 11) { arr_hot.push(val); } }); renderTodayNews(arr_today, $('.news ul'), 1); renderTodayNews(arr_week, $('.week ul'), 2); renderTodayNews(arr_hot, $('.hot_news'), 3); renderTodayNews(arr_bottom,$(".news_bottom ul"),4) var box = $(".hot_news"); var lis = $(".hot_news li"); setInterval(function () { lis.eq(0).toggle("new_hide"); }, 3000) } }); //渲染新闻热点 function renderTodayNews(arr, Dom, num) { var dom = ''; $.each(arr, function (index, val) { if (num === 1) { dom += '
  • ' + (index + 1) + '

    ' + val.title + '

  • '; } if (num === 2) { dom += '
  • .

    ' + val.title + '

  • '; } if (num === 3) { dom += '
  • ' + val.title.substring(0,14) + '

  • '; } if (num === 4) { dom += '
  • ' + (index + 1) + '

    ' + val.title + '

  • '; } }); Dom.append(dom); } $(".cascade_flow").scroll(function () { var divs = $(".cascade_flow div") var pageHeight = 626; var scrollTop = $(".cascade_flow").scrollTop(); var offsetTop = divs[divs.length - 1].offsetTop; if (pageHeight + scrollTop >= offsetTop) { $.each(Mini.flowArr[0], function (index, val) { $(".cascade_flow").append('

    ' + val.title + '

    ' + val.cat_name + '' + val.source + '
    '); }); Mini.waterfall_data(); } }); // 天气获取 $.ajax({ url: '//iplocation.7654.com/v1', type: 'get', dataType: 'json', success: function (res) { var city = res.city; var str1 = city.substr(city.length - 1, 1); if (str1 === "市") city = city.substring(0, city.length - 1); $.ajax({ // url: '//weather.shzhanmeng.com/api/weather/'+encodeURIComponent(city), url: 'http://weather.shzhanmeng.com/api/weather_jsonp/'+encodeURIComponent(city), dataType:"jsonp", jsonpCallback:"weaterCallback", success: function (res) { var weather = res.data[0].weather; $('.weather').html('' + city + ''); }, error: function(err){ console.log("weather--err",err); } }); } }); function upload(target,actType) { $.getJSON("//ad.kuaizip.com/advertise/userclick", { time: new Date().getTime(), localUrl: $.base64.encode("kZip.com" + location.pathname), project: $.base64.encode("mininews_ys001"), position:$.base64.encode($(target).attr('position-tag')), qid:$.base64.encode(Common.GetQueryString('qid')), env:$.base64.encode(Common.GetQueryString('env')), uid:$.base64.encode(Common.GetQueryString('uid') || "none"), act:$.base64.encode(actType), type:$.base64.encode($(target).attr("position-ad")), }).done(function(data) {}); } // $(document).ready(function () { // Mini.blackList(); // }); // function upload(target,actType) { // $.getJSON("//ad.kuaizip.com/advertise/userclick", { // time: new Date().getTime(), // localUrl: $.base64.encode("kZip.com" + location.pathname), // project: $.base64.encode("mininews_ys001"), // position:$(target).attr('position-tag'), // act:actType, // type:$(target).attr("position-ad"), // }).done(function(data) {}); // }