...
|
...
|
@@ -11,10 +11,12 @@ var $ = require('yoho-jquery'), |
|
|
|
|
|
require('./detail/page-render')(function() {
|
|
|
var $discountFolder = $('.goods-discount .discount-folder'),
|
|
|
$discountArrow = $('.goods-discount .first-item span');
|
|
|
$discountArrow = $('.goods-discount .first-item span'),
|
|
|
$bannerSwiper = $('.banner-swiper');
|
|
|
|
|
|
var goodsDiscountEl = document.getElementById('goodsDiscount'),
|
|
|
goodsDiscountHammer = goodsDiscountEl && new Hammer(goodsDiscountEl),
|
|
|
bannerSwiperHammer = new Hammer($bannerSwiper[0]),
|
|
|
$discountFirstItem = $(goodsDiscountEl).find('.first-item');
|
|
|
|
|
|
var $cart = $('.cart-bar');
|
...
|
...
|
@@ -48,7 +50,7 @@ require('./detail/page-render')(function() { |
|
|
}
|
|
|
|
|
|
// 顶部swiper
|
|
|
new Swiper('.banner-swiper', {
|
|
|
var swiper = new Swiper('.banner-swiper', {
|
|
|
lazyLoading: true,
|
|
|
lazyLoadingInPrevNext: true,
|
|
|
paginationClickable: true,
|
...
|
...
|
@@ -57,6 +59,10 @@ require('./detail/page-render')(function() { |
|
|
prevButton: '.my-swiper-button-prev',
|
|
|
spaceBetween: 3
|
|
|
});
|
|
|
bannerSwiperHammer.on('tap', function() {
|
|
|
$('.banner-top').toggleClass('hover');
|
|
|
swiper.onResize();
|
|
|
})
|
|
|
|
|
|
// 初始化goods-discount
|
|
|
if ($discountFolder.children().length === 0) {
|
...
|
...
|
@@ -151,6 +157,31 @@ require('./detail/page-render')(function() { |
|
|
if ($('.good-detail-page').length > 0) {
|
|
|
$('#yoho-footer').css('border-top', '1px solid #e0e0e0');
|
|
|
}
|
|
|
//加载详情页的返回顶部按钮并注册事件
|
|
|
|
|
|
$(document).scroll(function() {
|
|
|
if($(document).scrollTop() >= $(document).height() - $(window).height() - 20) {
|
|
|
if (!$('.float-top').hasClass('animation')) {
|
|
|
console.log('animation')
|
|
|
var top = $('.back-to-top').offset().top - $('.float-top').offset().top + ($('.back-to-top').height()-$('.float-top').height())/2;
|
|
|
var left = $('.back-to-top').offset().left - $('.float-top').offset().left;
|
|
|
$('.float-top').addClass('animation').css({
|
|
|
'transform': 'translate('+left+'px, '+top+'px) scale(0, 0)',
|
|
|
});
|
|
|
}
|
|
|
} else if ($('.product-detail').length && $(document).scrollTop() >= $('.product-detail').offset().top) {
|
|
|
if (!$('.float-top').hasClass('hover') || $('.float-top').hasClass('animation')) {
|
|
|
console.log('hover')
|
|
|
$('.float-top').addClass('hover').removeClass('animation').removeAttr('style');
|
|
|
}
|
|
|
} else {
|
|
|
if ($('.float-top').hasClass('hover')) {
|
|
|
console.log('remove hover')
|
|
|
$('.float-top').removeClass('hover');
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
//加载详情页的返回顶部按钮并注册事件-end
|
|
|
});
|
|
|
|
|
|
|
...
|
...
|
|