/** * Created by wangzhiwei on 2019/6/20. */ $(function () { var bannerContainer = $(".banner-container").length && new Swiper(".banner-container", { watchOverflow: true, parallax: true, mousewheel: true, speed: 1000, loop: true, preloadImages: false, loopedSlides: 5, // updateOnImagesReady: true, autoplay: { delay: 5000, }, effect: "fade", fadeEffect: { crossFade: true, }, // autoHeight: true, pagination: { el: ".swiper-pagination", //自动隐藏 clickable: true, // type: "custom", // renderCustom: function(swiper, current, total) { // return current + " / " + total; // }, }, navigation: { nextEl: ".swiper-button-next", //自动隐藏 prevEl: ".swiper-button-prev", //自动隐藏 }, on: { init: function () { }, }, }); function initCeoPagination() { var len = $(".banner-container .swiper-slide").length - bannerContainer.loopedSlides * 2; var navNumSlides = ""; for (var i = 0; i < len; i++) { var ni = i + 1 < 10 ? "0" + (i + 1) : i + 1; navNumSlides += '
' + ni + "
"; } $(".ceo-pagination-container .swiper-wrapper").html(navNumSlides); } initCeoPagination(); var ceoPagination = new Swiper(".ceo-pagination-container", { speed: 1000, loop: true, mousewheel: true, direction: "vertical", slidesPerView: 3, loopedSlides: 5, // autoplay: true, centeredSlides: true, centeredSlidesBounds: true, }); if ($(".ceo-pagination-container").length) { bannerContainer.controller.control = ceoPagination; //Swiper1控制Swiper2,需要在Swiper2初始化后 ceoPagination.controller.control = bannerContainer; //Swiper2控制Swiper1,需要在Swiper1初始化后 } })