锘縱ar swiperExtend = { data: { leftSwiper: [], rightSwiper: [], }, Init: function () { swiperExtend.data.rightSwiper = new Swiper('#bannerRight', { slidesPerView: 'auto', direction: 'vertical' }); swiperExtend.data.leftSwiper = new Swiper('#bannerLeft', { pagination: '.swiper-pagination', paginationClickable: true, spaceBetween: 30, centeredSlides: true, autoplay: 4000, autoplayDisableOnInteraction: false, loop: true, loopAdditionalSlides: 1, onSlideChangeStart: function (swiper) { var activeIndex = $('#bannerLeft .swiper-slide').eq(swiper.activeIndex).attr("data-swiperight"); if (activeIndex == -1) { $('.bannerRight .active-nav').removeClass('active-nav'); } else { swiperExtend.updateNavPosition(activeIndex, true); } }, onImagesReady: function (swiper) { //Swiper鍒濆鍖栦簡 swiperExtend.rightHeightSet(); } }); $('.arrow-up').click(function () { var activeIndex = $('.bannerRight .active-nav').index() - 1; if (activeIndex < -1) { activeIndex = -1; } swiperExtend.updateNavPosition(activeIndex, false); }); $('.arrow-down').click(function () { var activeIndex = $('.bannerRight .active-nav').index() + 1; swiperExtend.updateNavPosition(activeIndex, false); }); $(".bannerRight .swiper-slide").click(function () { swiperExtend.updateNavPosition($(this).index(), false); }); var newsSwiper = new Swiper('#newsSwiper', { slidesPerView: 3, centeredSlides: false, paginationClickable: true, spaceBetween: 0, prevButton: '#newsLeft', nextButton: '#newsRight' }); }, updateNavPosition: function (activeIndex, fromLeft) { $('.bannerRight .active-nav').removeClass('active-nav'); if (activeIndex == swiperExtend.data.rightSwiper.slides.length) { var activeNav = $('.bannerRight .swiper-slide').eq(0).addClass('active-nav'); swiperExtend.data.rightSwiper.slideTo(0, 1000, false); if (!fromLeft) { var leftIndex = activeNav.attr("data-swipeleft"); swiperExtend.data.leftSwiper.slideTo(leftIndex, 1000); } return; } if (activeIndex == -1) { var next = swiperExtend.data.rightSwiper.slides.length - 1; var activeNav = $('.bannerRight .swiper-slide').eq(next).addClass('active-nav'); swiperExtend.data.rightSwiper.slideTo(next, 1000, false); if (!fromLeft) { var leftIndex = activeNav.attr("data-swipeleft"); swiperExtend.data.leftSwiper.slideTo(leftIndex, 1000); } return; } var activeNav = $('.bannerRight .swiper-slide').eq(activeIndex).addClass('active-nav'); var aa = activeNav.index() / 3; var next = activeNav.index() - 2; if (next < 0) { next = 0; } if (swiperExtend.data.rightSwiper.activeIndex != next) { swiperExtend.data.rightSwiper.slideTo(next, 1000, false); } if (!fromLeft) { var leftIndex = activeNav.attr("data-swipeleft"); swiperExtend.data.leftSwiper.slideTo(leftIndex, 1000); } }, rightHeightSet: function () { var leftHeight = $(".bannerLeft").outerHeight(); $(".bannerRight").height(leftHeight); var rightHeight = leftHeight - 70; $("#bannerRight").height(rightHeight); $(".bannerRight .swiper-slide").each(function () { $(this).height(rightHeight / 3); }); swiperExtend.data.rightSwiper = new Swiper('#bannerRight', { slidesPerView: 'auto', direction: 'vertical' }); } };