//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__"};
var CONFIG_G = "proConfig"; // 全局配置key
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
curTabBtn: $(".nav_item").eq(0), // 当前选中的tab按钮
};
proConfig = proObject;
};
var user_uid = Common.getUserId();
var timer0510;
var clickFlag=true;
//tab-hover
$('body').on('click','.left_nav .nav_item',function () {
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');
proConfig.curTabBtn = $(that);
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")
}
})
$(".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('
');
});
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
});
/* 360皮肤广告 */
ad360.addSkin();
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"||location.hostname==="127.0.0.1"?"test/test.gamma-minipage.news.7654.com.002.":('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.qihaxiaoshuo.com.0102.json',
dataType:'json',
success: function (res) {
proConfig.message_flow_showId = res.l;
proConfig.right_bottom_showid=res.rb;
proConfig.right_top_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');
});
// 中间信息流
ds.initSspL();
// 右侧广告
ds.initSspR();
},
error: function () {
}
});
}
});
},
// 瀑布流初始化
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('');
});
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.refresh_scroll = 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);
});
ds.initSspL();
$('.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');
});
ad360.render360Scroll();
}
} 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 = '';
} else {
if (content.cover) {
dom = '';
} else if (content.content_img_list[0]) {
content.content_img_list[0] = '//' + content.content_img_list[0].split('//')[1];
dom = '';
}
}
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 = '';
}else{
var more_imgs = '';
$.each(adData.assets, function (i, v) {
more_imgs += ''
})
var dom = '';
}
} else {
var dom = '';
}
$(target_dom).before(dom);
},
renderBig360: function (target_dom, adData, tagPosition) {
this.ad360index++;
var dom = '';
$(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')&&btn.attr('click_time') == 1) {
$('.more_nav .nav_item_part').attr('click_time', '');
return;
}
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);
$('.content').scrollTop(0);
obj.refresh_tab = true;
initPage();
obj.fetch_data(params, proConfig.curTabBtn);
},
};
// 广告uid
function recommend_uid() {
return (+new Date()) + Math.random().toString(10).substring(2, 6);
}
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('');
});
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('' + weather + '' + 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:$(target).attr('position-tag'),
// act:actType,
// type:$(target).attr("position-ad"),
// }).done(function(data) {});
// }
/**
* 初始化数据
*/
function initPage(){
window[CONFIG_G].page = 1;
window[CONFIG_G].pageNum = 1;
window[CONFIG_G].busy_news = false;
window[CONFIG_G].busy_360 = false;
window[CONFIG_G].busy_ssp = false;
Mini.refresh_scroll = false;
ad360.init();
}
function showPop(showTime,showUrl,showKey,blockArea) {
var nowTime = new Date().getTime();
if (nowTime > Common.newDate(showTime[0]).getTime() && nowTime < Common.newDate(showTime[1]).getTime()) {
$.ajax({
url: '//iplocation.7654.com/v1',
type: 'get',
dataType: 'json',
success: function (data) {
var canPop = true;
for(var i=0;i < blockArea.length;i++){
if(data.city.indexOf(blockArea[i]) >-1){
canPop = false;
break;
}
}
if (canPop) {
if(!$.cookie(showKey)){
$.cookie(showKey, showKey, {expires: 30, path: '/'});
window.open(showUrl);
}
}
}
});
}
}
showPop(["2020-06-15 20:00:00", "2020-06-15 23:59:59"],"https://s.click.taobao.com/Rrusxzu","showDouble_002_1",["杭州","北京","深圳","珠海","上海"]);
showPop(["2020-06-16 00:00:00", "2020-06-16 23:59:59"],"https://s.click.taobao.com/Rrusxzu","showDouble_002_2",["杭州","北京","深圳","珠海","上海"]);
// 滚动加载
initPage('out');
initEndlessScroll();
function initEndlessScroll(){
$(".content").endlessScroll({
fireOnce: false,
fireDelay: false,
inflowPixels: 100,
ceaseFireOnEmpty: false,
loader: '',
callback: function (p, s, d) {
if (d === "prev") return;
if (!p) return;
ad360.handle_url_scroll();
if (window[CONFIG_G].busy_news) return;
$(".list_item").removeClass("list_item");
window[CONFIG_G].pageNum++;
window[CONFIG_G].page++;
var params = {
type: Mini.type,
};
Mini.refresh_scroll = true;
Mini.fetch_data(params);
},
ceaseFire: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': (50+$("#skin_360_container").height())+'px'});
}else{
$("#container .show_case").css({'position': 'fixed', 'top': (40+$("#skin_360_container").height())+'px'});
}
$(".hot_news").css({'position': 'fixed', 'top': (10+$("#skin_360_container").height())+'px'});
$(".showcase").css({'position': 'fixed', 'top': (290+$("#skin_360_container").height())+'px'});
$(".news_bottom").css({'display':"block",'position': 'fixed', 'top': (430+$("#skin_360_container").height())+'px'});
} else {
$("#container .show_case").css({'position': 'static'});
$(".hot_news").css({'position': 'static'});
$(".showcase").css({'position': 'static'});
$(".news_bottom").css({'display':"none",'position': 'static'});
}
// ad360.handle_url_scroll();
}
});
}
$("#container .content").on("scroll",function () {
ad360.handle_url_scroll();
});