$(function () { let product = 3,spaceBetween = 30; if(window.innerWidth <= 768){ product = 1; spaceBetween = 0 } //banner var bannerSwiper = new Swiper ('.banner-wrapper', { autoplay: { delay: 4000, stopOnLastSlide: false, disableOnInteraction: false, }, autoplayDisableOnInteraction : false, /* effect : 'fade', fadeEffect: { crossFade: true, },*/ loop: true, // 循环模式选项 // 如果需要分页器 pagination: { el: '.swiper-pagination', clickable :true, }, observer:true,//修改swiper自己或子元素时,自动初始化swiper observeParents:true,//修改swiper的父元素时,自动初始化swiper on: { slideChangeTransitionStart: function(){ $(".progress-bar").removeClass("progress-ani"); var index = this.realIndex; $('.swiper-pagination') .find('span') .eq(index) .addClass('swiper-pagination-bullet-active') .siblings() .removeClass('swiper-pagination-bullet-active'); }, slideChangeTransitionEnd: function(){ $(".progress-bar").addClass("progress-ani"); }, }, }); $(".text-btn button").hover(function () { bannerSwiper.autoplay.stop(); },function () { bannerSwiper.autoplay.start(); }); $(".video-btn").click(function () { showVideo() }); //产品特性 /* 定义产品轮播图 */ var swiper = new Swiper('.product-swiper', { loop: false, //initialSlide: 1, slidesPerView: product, spaceBetween: spaceBetween, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, on:{ }, }); /* 定义合作伙伴轮播图 */ var swiper1 = new Swiper('.partner-swiper', { slidesPerView: 1, speed: 1000, spaceBetween: 0, navigation: { nextEl: '.swiper-button-next1', prevEl: '.swiper-button-prev1', }, freeMode: true,//使之移动比较顺滑,有惯性 }); });