/**
* Created by mac on 16/11/28.
*/
$(function () {
getListInfo(page);
});
var page = 1;
var totalPage = 1;
var stop = true;
$('.nav .row .nav').find('li').on('click', function (e) {
var index_ = $(this).index();
if (!$(this).hasClass('active')) {
$(this).addClass('active')
}
$(this).siblings().removeClass('active');
$('.tab-box .tb').eq(index_).fadeIn();
$('.tab-box .tb').eq(index_).siblings().fadeOut();
console.log()
if (index_ == 1) {
stop = false;
} else {
stop = true;
}
});
$(document).scroll(function () {
scro();
});
function scro() {
totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());
//console.log(totalheight+":总值"+$(".page-list").height()+":长度")
if ($(".page-list").height() <= totalheight && stop == false) {
if(page > totalPage){
$('.list-load').text('已全部加载!').fadeIn();
return
}else{
stop = true;
$('.list-load').show();
getListInfo(page,function(){
stop = false;
$('.list-load').fadeOut();
})
}
} else {
}
}
var mai_li = '
\
\
\

\
\
\
\
\
昵称不少于五个字昵称不少于五个字昵称不少于五个字
\
\
\
\
\
';
//获取买家秀信息
function getListInfo(e,callback) {
var data = {
page: e
};
$.ajax({
type: "POST",
url: "/viza/upload_img/website",
dataType: "json",
data: data,
async: true,
success: function (data) {
console.log(data);
var json = eval(data);
var list = json.slide_show_list;
totalPage = json.zong_page;
//if(page >1){
// stop = false;
//}
for (var i in list) {
$('.page-1').append(mai_li);
var maiLast = $('.mai:last');
maiLast.find('.frist-img').css('background-image', 'url('+list[i].picture1+')');//第一个秀图
maiLast.find('.mai-user-img').attr('src', list[i].user_img);//头像
maiLast.find('.user-name').text(list[i].user_name);//名字
maiLast.find('.user-st').text("分享文案:"+list[i].text);//文案
maiLast.find('.indent_number').text(list[i].indent_number);//编号
setMaiListLi(maiLast,list[i].picture1,0);
setMaiListLi(maiLast,list[i].picture2,1);
setMaiListLi(maiLast,list[i].picture3,2);
setMaiListLi(maiLast,list[i].picture4,3);
// setMaiListLi(maiLast,list[i].picture5,4);
}
page ++;
callback&&callback()
},
error: function () {
//alert("网路异常!请重试!!");
console.log("网路异常!请重试!")
}
})
}
function setMaiListLi(obj,e,index){
if(e){
obj.find('.mai-ul').find('li:eq('+index+') img').attr('src', e);
}else{
obj.find('.mai-ul').find('li:eq('+index+')').hide();
}
}
$('.page-1').on('click','.mai',function(){
var index_ = $(this).index();
var it_num = $(this).find('.indent_number').text();
//window.open("mai_info.html");
window.open("/viza/upload_img/website_show_only/"+it_num)
})