...
|
...
|
@@ -27,12 +27,15 @@ function hiddenTips($ele) { |
|
|
class Detail extends Page {
|
|
|
constructor() {
|
|
|
super();
|
|
|
lazyLoad($('img.lazy'));
|
|
|
this.selector = {
|
|
|
introUrl: $('#introUrl'),
|
|
|
productDesc: $('#productDesc')
|
|
|
|
|
|
};
|
|
|
this.getIntro();
|
|
|
this.goSwiper();
|
|
|
this.toTop();
|
|
|
}
|
|
|
|
|
|
getIntro() {
|
...
|
...
|
@@ -82,7 +85,66 @@ class Detail extends Page { |
|
|
}
|
|
|
});
|
|
|
}
|
|
|
goSwiper() {
|
|
|
setTimeout(() => {
|
|
|
// 顶部swiper
|
|
|
let swiper = new Swiper('.banner-swiper', {
|
|
|
preloadImages: false,
|
|
|
lazyLoading: true,
|
|
|
lazyLoadingInPrevNext: true,
|
|
|
lazyLoadingOnTransitionStart: true,
|
|
|
paginationClickable: true,
|
|
|
pagination: '.banner-top .pagination-inner',
|
|
|
nextButton: '.my-swiper-button-next',
|
|
|
prevButton: '.my-swiper-button-prev',
|
|
|
spaceBetween: 3
|
|
|
});
|
|
|
|
|
|
$('.banner-swiper').click(function() {
|
|
|
$('.banner-top').toggleClass('hover');
|
|
|
swiper.onResize();
|
|
|
});
|
|
|
$('.banner-top-single').click(function() {
|
|
|
$('.banner-top-single').toggleClass('hover');
|
|
|
});
|
|
|
}, 500);
|
|
|
}
|
|
|
toTop() {
|
|
|
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')) {
|
|
|
let offset = $('.back-to-top').offset();
|
|
|
|
|
|
if (!offset) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
let top = offset.top -
|
|
|
$('.float-top').offset().top +
|
|
|
($('.back-to-top').height() - $('.float-top').height()) / 2;
|
|
|
let left = 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')) {
|
|
|
$('.float-top').addClass('hover').removeClass('animation').removeAttr('style');
|
|
|
}
|
|
|
} else {
|
|
|
if ($('.float-top').hasClass('hover')) {
|
|
|
$('.float-top').removeClass('hover');
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
$(() => {
|
|
|
new Detail();
|
...
|
...
|
|