on: { //切换结束时,告诉我现在是第几个slide slideChangeTransitionEnd: function () { var _them = $('.index-banner .swiper-slide-active').attr('data-them'); $('body').attr('data-them', _them); }, }, }); $('.index-block-a .swiper-container').each(function () { var _this = $(this); new Swiper(_this, { speed: 500, slidesPerView: 4, navigation: { nextEl: _this.parent().find('.next'), prevEl: _this.parent().find('.prev') }, breakpoints: { 1200: { slidesPerView: 2 } } }); }); var swiper3 = new Swiper('.index-block-b .swiper-container', { simulateTouch: false, slidesPerView: 3, breakpoints: { 992: { slidesPerView: 2 } } }); $('.index-block-b .btns .btn').hover(function () { var _class = $(this).attr('data-class'); $(this).addClass('on').siblings().removeClass('on'); productCheck(_class); }, function () { }); productCheck($('.index-block-b .btns .btn').eq(0).attr('data-class')); $('.index-block-b .btns .btn').eq(0).addClass('on').siblings().removeClass('on'); function productCheck(_class) { swiper3.destroy(false); $('.index-block-b .swiper-li').removeClass('swiper-slide'); $('.index-block-b .' + _class).addClass('swiper-slide'); swiper3 = new Swiper('.index-block-b .swiper-container', { simulateTouch: false, slidesPerView: 3, breakpoints: { 992: { slidesPerView: 2 } } }); } var swiper4 = new Swiper('.index-block-c .swiper-container', { slidesPerView: 2,//一行显示2个 slidesPerGroup: 2, pagination: { el: '.index-block-c .swiper-points', clickable: true } }); $(window).scroll(function () { var _window_height = $(window).height(); var _window_scroll = $(window).scrollTop(); var _obj_top = $('.index-block-d .flex-box').offset().top; var _obj_height = $('.index-block-d .flex-box').height(); if ($(".index-block-d .flex-box").attr('numscroll') !== 'true') { if (_window_scroll + _window_height * .9 > _obj_top) { $(".index-block-d .flex-box").attr('numscroll', 'true'); $(".index-block-d .num-val").each(function () { var _this = $(this); var _num = _this.attr('data-num'); _this.numberRock({ lastNumber: _num }); }); } } });