...
|
...
|
@@ -13,15 +13,13 @@ var $ = require('yoho-jquery'), |
|
|
PullRefresh = require('../plugin/pull-refresh');
|
|
|
|
|
|
var $window = $(window),
|
|
|
stopLoading = false,
|
|
|
$mainContent = $('.main-content'),
|
|
|
$headTab = $('.head-tab'),
|
|
|
headTabH = $headTab.height(),
|
|
|
scrollH = $(window).height() - headTabH,
|
|
|
$loadingTip = $('.loading-tip'),
|
|
|
$starMain = $('.star-main'),
|
|
|
$bannerTop = $('.banner-top'),
|
|
|
$starArticle = $('.star-article'),
|
|
|
$avatarWrap = $('.avatar-wrap'),
|
|
|
bannerLen = $('.avatar-wrap').find('.swiper-slide').length,
|
|
|
u = navigator.userAgent,
|
|
|
isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
|
|
|
|
|
|
/*
|
|
|
$swiperView = $('.swiper-view'),
|
|
|
$viewImg = $('.view-img'),
|
...
|
...
|
@@ -32,22 +30,19 @@ var $window = $(window), |
|
|
var mySwiper;
|
|
|
*/
|
|
|
|
|
|
var avatarKey, bannerLen, res, avatarSwiper, avatarSwiperClone, getIndexHtml,
|
|
|
$avatarClone, $starArticle, $avatarWrap, starIScroll;
|
|
|
var res, avatarSwiper, avatarSwiperClone, $avatarClone;
|
|
|
|
|
|
var swiperNum = $('.avatar-wrap .swiper-slide').width() / 2;
|
|
|
|
|
|
require('../common');
|
|
|
|
|
|
if ($window.width() === 375 && isiOS) {
|
|
|
swiperNum = 32;
|
|
|
}
|
|
|
|
|
|
require('../common');
|
|
|
|
|
|
lazyLoad($('img.lazy'));
|
|
|
ellipsis.init();
|
|
|
|
|
|
$window.on('mousewheel', false);
|
|
|
|
|
|
// 限制标题字数
|
|
|
function txtLimit(dom, item1, item2) {
|
|
|
var $title = dom.find(item1),
|
...
|
...
|
@@ -79,7 +74,7 @@ function setAvatar($userAvatar) { |
|
|
|
|
|
// 明星头像点击居中显示或跳转
|
|
|
function bindAvatar(dom) {
|
|
|
avatarKey = dom.index();
|
|
|
var avatarKey = dom.index();
|
|
|
|
|
|
if (!dom.hasClass('swiper-slide-active')) {
|
|
|
if (avatarKey >= (2 * bannerLen + 1)) {
|
...
|
...
|
@@ -97,7 +92,16 @@ function bindAvatar(dom) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
function setIndexAction() {
|
|
|
// 初始化首页各种效果
|
|
|
function initAction() {
|
|
|
$starMain.before($('.avatar-swiper').clone().addClass('avatar-clone').hide());
|
|
|
$avatarClone = $('.avatar-clone');
|
|
|
|
|
|
// 限制标题字数
|
|
|
$('.cont-area').each(function() {
|
|
|
txtLimit($(this), '.title', '.cont-txt');
|
|
|
});
|
|
|
|
|
|
$('.avatar').each(function(key, item) {
|
|
|
$(item).addClass('avatar-' + key);
|
|
|
});
|
...
|
...
|
@@ -164,85 +168,12 @@ function setIndexAction() { |
|
|
return false;
|
|
|
});
|
|
|
|
|
|
$('img').on('load', function() {
|
|
|
starIScroll.iScroll.refresh();
|
|
|
});
|
|
|
cloneAvatarInit();
|
|
|
}
|
|
|
|
|
|
function initAction() {
|
|
|
$starArticle = $('.star-article');
|
|
|
$avatarWrap = $('.avatar-wrap');
|
|
|
bannerLen = $('.avatar-wrap').find('.swiper-slide').length;
|
|
|
|
|
|
if ($avatarClone) {
|
|
|
$avatarClone.remove();
|
|
|
}
|
|
|
|
|
|
$loadingTip.before($('.avatar-swiper').clone().addClass('avatar-clone').hide());
|
|
|
|
|
|
$avatarClone = $('.avatar-clone');
|
|
|
|
|
|
// 限制标题字数
|
|
|
$('.cont-area').each(function() {
|
|
|
txtLimit($(this), '.title', '.cont-txt');
|
|
|
});
|
|
|
|
|
|
lazyLoad($('img.lazy'));
|
|
|
|
|
|
setIndexAction();
|
|
|
}
|
|
|
|
|
|
|
|
|
// 首页数据请求
|
|
|
getIndexHtml = function() {
|
|
|
loading.showLoadingMask();
|
|
|
$.ajax({
|
|
|
url: '/guang/star/getIndexHtml',
|
|
|
dataType: 'html',
|
|
|
success: function(data) {
|
|
|
stopLoading = false;
|
|
|
|
|
|
if (data) {
|
|
|
if (avatarSwiperClone) {
|
|
|
avatarSwiperClone.destroy(true, true);
|
|
|
avatarSwiperClone = '';
|
|
|
}
|
|
|
|
|
|
$mainContent.html(data);
|
|
|
|
|
|
initAction();
|
|
|
}
|
|
|
|
|
|
loading.hideLoadingMask();
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
initAction();
|
|
|
|
|
|
// 下拉刷新,上拉加载
|
|
|
starIScroll = new PullRefresh('.star-main', {
|
|
|
height: scrollH,
|
|
|
pullDown: function() {
|
|
|
if (!stopLoading) {
|
|
|
stopLoading = true;
|
|
|
getIndexHtml();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
starIScroll.iScroll.on('scrollStart', function() {
|
|
|
// 下拉
|
|
|
if (this.directionY === -1) {
|
|
|
$loadingTip.slideDown();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
starIScroll.iScroll.on('scroll', function() {
|
|
|
if ($avatarWrap.offset().top <= headTabH) {
|
|
|
// 悬浮明星头像
|
|
|
function cloneAvatarInit() {
|
|
|
if ($window.scrollTop() >= $bannerTop.height() + parseInt($starMain.find('.avatar').css('margin-top'))) {
|
|
|
$avatarClone.show();
|
|
|
|
|
|
if (!avatarSwiperClone) {
|
...
|
...
|
@@ -267,15 +198,16 @@ starIScroll.iScroll.on('scroll', function() { |
|
|
avatarSwiperClone.params.control = avatarSwiper;
|
|
|
avatarSwiper.params.control = avatarSwiperClone;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if ($avatarWrap.offset().top > $('.avatar-1')[0].scrollHeight) {
|
|
|
} else {
|
|
|
$avatarClone.hide();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
initAction();
|
|
|
|
|
|
starIScroll.iScroll.on('scrollEnd', function() {
|
|
|
$loadingTip.slideUp();
|
|
|
$window.scroll(function() {
|
|
|
cloneAvatarInit();
|
|
|
});
|
|
|
|
|
|
window.setCookie('guangStarUid', window.queryString.uid);
|
...
|
...
|
|