...
|
...
|
@@ -16,7 +16,8 @@ var $window = $(window), |
|
|
$starArticle = $('.star-article'),
|
|
|
$headTab = $('.head-tab'),
|
|
|
stopLoading = false,
|
|
|
avatarSwiper = [];
|
|
|
avatarSwiper = [],
|
|
|
getIndexHtml;
|
|
|
|
|
|
/*
|
|
|
$swiperView = $('.swiper-view'),
|
...
|
...
|
@@ -49,132 +50,62 @@ function txtLimit(dom, item1, item2) { |
|
|
// 设置默认头像
|
|
|
function setAvatar($userAvatar) {
|
|
|
var myImage = new Image(),
|
|
|
avatar;
|
|
|
avatar = '';
|
|
|
|
|
|
// 部分老用户没有头像,显示默认头像
|
|
|
avatar = $userAvatar.data('avatar');
|
|
|
myImage.src = avatar || '';
|
|
|
|
|
|
if (avatar) {
|
|
|
myImage.src = avatar;
|
|
|
}
|
|
|
|
|
|
myImage.onload = function() {
|
|
|
$userAvatar.css('background-image', 'url(' + avatar + ')');
|
|
|
};
|
|
|
}
|
|
|
|
|
|
function ajaxHtml() {
|
|
|
loading.showLoadingMask();
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/guang/star/ajaxIndexHtml',
|
|
|
dataType: 'html',
|
|
|
success: function(data) {
|
|
|
stopLoading = false;
|
|
|
|
|
|
if (data === '') {
|
|
|
stopLoading = true;
|
|
|
tip.show('没有更多内容了');
|
|
|
}
|
|
|
|
|
|
$('.star-main').html(data);
|
|
|
|
|
|
// 限制标题字数
|
|
|
$('.cont-area').each(function() {
|
|
|
txtLimit($(this), '.title', '.cont-txt');
|
|
|
});
|
|
|
|
|
|
loading.hideLoadingMask();
|
|
|
lazyLoad($('img.lazy'));
|
|
|
bannerLen = $('.avatar-0 .swiper-slide').length;
|
|
|
|
|
|
setTimeout(function() {
|
|
|
setIndexAction();
|
|
|
}, 100);
|
|
|
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function setIndexAction() {
|
|
|
var starIScroll;
|
|
|
|
|
|
var $avatar0 = $('.avatar-0'),
|
|
|
$avatar1 = $('.avatar-1');
|
|
|
var commonHeaderTop = $('#yoho-header').outerHeight();
|
|
|
var $loadingTip = $('.loading-tip');
|
|
|
var $avatarWrap = $('.avatar-wrap');
|
|
|
|
|
|
// 下拉刷新,上拉加载
|
|
|
starIScroll = new PullRefresh('.star-wrap', {
|
|
|
height: $(window).height() - $('#yoho-header').height() - $('.head-tab').height(),
|
|
|
height: $(window).height() - commonHeaderTop,
|
|
|
pullDown: function() {
|
|
|
if (!stopLoading) {
|
|
|
stopLoading = true;
|
|
|
ajaxHtml();
|
|
|
getIndexHtml();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// pullUp: function() {
|
|
|
// // $headTab.slideUp();
|
|
|
// }
|
|
|
});
|
|
|
|
|
|
starIScroll.iScroll.on('scrollStart', function() {
|
|
|
$window.trigger('scroll');
|
|
|
|
|
|
// 上滑
|
|
|
if (this.directionY === 1) {
|
|
|
$headTab.slideUp();
|
|
|
} else {
|
|
|
$headTab.slideDown();
|
|
|
}
|
|
|
|
|
|
// 下拉
|
|
|
if (this.directionY === -1) {
|
|
|
$('.fliptop').slideDown();
|
|
|
$headTab.slideDown();
|
|
|
$loadingTip.slideDown();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
starIScroll.iScroll.on('scroll', function() {
|
|
|
// var scale = 1;
|
|
|
|
|
|
// if (this.y < 0 && this.startY > -40) {
|
|
|
// console.log(headTabHeight + this.startY);
|
|
|
// scale = 2 / headTabHeight;
|
|
|
// }
|
|
|
// $headTab.css({
|
|
|
// transfrom: 'scale(' + scale + ')'
|
|
|
// });
|
|
|
|
|
|
if (this.startY < -180) {
|
|
|
$avatar0.hide();
|
|
|
$avatar1.show();
|
|
|
|
|
|
if (!avatarSwiper[1]) {
|
|
|
avatarSwiper[1] = new Swiper('.avatar-1', {
|
|
|
loop: true,
|
|
|
|
|
|
// loopedSlides: bannerLen,
|
|
|
initialSlide: 2,
|
|
|
centeredSlides: true,
|
|
|
slidesPerView: 'auto',
|
|
|
spaceBetween: 10,
|
|
|
slidesOffsetBefore: '-' + $('.avatar-1').find('li').not('.swiper-slide-visible').width() / 2,
|
|
|
watchSlidesProgress: true,
|
|
|
watchSlidesVisibility: true,
|
|
|
observer: true,
|
|
|
observeParents: true
|
|
|
});
|
|
|
|
|
|
avatarSwiper[0].params.control = avatarSwiper[1];// 需要在Swiper2初始化后,Swiper1控制Swiper2
|
|
|
avatarSwiper[1].params.control = avatarSwiper[0];// 需要在Swiper1初始化后,Swiper2控制Swiper1
|
|
|
}
|
|
|
|
|
|
// avatarSwiper[1].slideTo($avatar0.find('.swiper-slide-active').index(), 1000, false);
|
|
|
if (commonHeaderTop > $avatarWrap.offset().top) {
|
|
|
// $('.avatar-clone').css('top', $('.head-tab').outerHeight());
|
|
|
$('.avatar-clone').show();
|
|
|
starIScroll[0].update();
|
|
|
starIScroll[1].update();
|
|
|
} else {
|
|
|
$('.avatar-clone').hide();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
starIScroll.iScroll.on('scrollEnd', function() {
|
|
|
$window.trigger('scroll');
|
|
|
|
|
|
$('.fliptop').slideUp();
|
|
|
// 上滑
|
|
|
if (this.directionY === 1) {
|
|
|
$headTab.slideUp(1000);
|
|
|
}
|
|
|
$loadingTip.slideUp();
|
|
|
});
|
|
|
|
|
|
// 明星动态文章图片相关操作
|
...
|
...
|
@@ -268,7 +199,7 @@ function setIndexAction() { |
|
|
// }
|
|
|
|
|
|
if (bannerLen > 1) {
|
|
|
avatarSwiper[0] = new Swiper('.avatar-0', {
|
|
|
avatarSwiper = new Swiper('.avatar', {
|
|
|
loop: true,
|
|
|
|
|
|
// loopedSlides: bannerLen,
|
...
|
...
|
@@ -276,12 +207,15 @@ function setIndexAction() { |
|
|
centeredSlides: true,
|
|
|
slidesPerView: 'auto',
|
|
|
spaceBetween: 10,
|
|
|
slidesOffsetBefore: '-' + $('.avatar-0').find('li').not('.swiper-slide-visible').width() / 2,
|
|
|
slidesOffsetBefore: -($('.avatar').find('li').not('.swiper-slide-visible').width() / 2),
|
|
|
watchSlidesProgress: true,
|
|
|
watchSlidesVisibility: true,
|
|
|
observer: true,
|
|
|
observeParents: true
|
|
|
});
|
|
|
|
|
|
avatarSwiper[0].params.control = avatarSwiper[1];// 需要在Swiper2初始化后,Swiper1控制Swiper2
|
|
|
avatarSwiper[1].params.control = avatarSwiper[0];// 需要在Swiper1初始化后,Swiper2控制Swiper1
|
|
|
}
|
|
|
|
|
|
// 明星动态头像左右滑动
|
...
|
...
|
@@ -324,4 +258,43 @@ function setIndexAction() { |
|
|
|
|
|
}
|
|
|
|
|
|
ajaxHtml(); |
|
|
getIndexHtml = function() {
|
|
|
var $starMain = $('.star-main');
|
|
|
|
|
|
loading.showLoadingMask();
|
|
|
$.ajax({
|
|
|
url: '/guang/star/getIndexHtml',
|
|
|
dataType: 'html',
|
|
|
success: function(data) {
|
|
|
stopLoading = false;
|
|
|
|
|
|
if (!data) {
|
|
|
stopLoading = true;
|
|
|
tip.show('没有更多内容了');
|
|
|
}
|
|
|
|
|
|
$starMain.html(data);
|
|
|
bannerLen = $('.avatar .swiper-slide').length;
|
|
|
|
|
|
$starMain.prepend($('.avatar-swiper').clone().addClass('avatar-clone').hide());
|
|
|
|
|
|
// 限制标题字数
|
|
|
$('.cont-area').each(function() {
|
|
|
txtLimit($(this), '.title', '.cont-txt');
|
|
|
});
|
|
|
|
|
|
loading.hideLoadingMask();
|
|
|
lazyLoad($('img.lazy'));
|
|
|
|
|
|
setTimeout(function() {
|
|
|
setIndexAction();
|
|
|
}, 100);
|
|
|
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
getIndexHtml(); |
...
|
...
|
|