$(function () { //banner图手机端pc端 $(window).resize(function(){ if($(".menu-bon").is(":visible")){ $(".bg_ph").each(function(){ $(this).attr("src",$(this).attr("data-img")) }) }else{ $(".bg_pc").each(function(){ $(this).attr("src",$(this).attr("data-img")) }) } }) $(window).resize() //首页banner $(".swiper_list").each(function (e) { $(this).addClass("swiper1" + e); var pcn=$(this).data("pcn"), phn = $(this).data("phn") var nm3 = pcn; if ($(window).width() < 1000) { nm3 = phn; } setTimeout(function(){ var mySwiper3 = new Swiper('.swiper1' + e + ' .swiper-container', { calculateHeight: true, paginationClickable: true, slidesPerView: nm3, resizeReInit : true, loop : true, speed:800, pagination : '.swiper1' + e + ' .pagination', autoplay :5000, onSlideChangeStart: function() { $('.swiper1' + e + ' .btn-box a').removeClass("over"); if (mySwiper3.activeIndex == 0) { $('.swiper1' + e + ' .ban-left').addClass("over"); } if (mySwiper3.activeIndex == mySwiper3.slides.length-1) { $('.swiper1' + e + ' .ban-right').addClass("over"); } } }); $('.swiper1' + e + ' .ban-left').on('click', function (e) { e.preventDefault() mySwiper3.swipePrev() }) $('.swiper1' + e + ' .ban-right').on('click', function (e) { e.preventDefault() mySwiper3.swipeNext() }) },1) }) })