$(function () { proindex(); if($(window).width()>1024){ scolltext(".peoduct_typebox dd p"); } }) function proindex(){ settimeout(function () { $(".peoduct_type_tab li").eq(0).click(); }, 200); if($(window).width()>767){ if($(".peoduct_type_slider li").length>8){ $(".peoduct_type_tab .pro_but").show() } }else{ if($(".peoduct_type_slider li").length>2){ $(".peoduct_type_tab .pro_but").show() } } if($(window).width()>1024){ if($(".peoduct_type_slider li").length>1){ var pro2 = new swiper('.peoduct_type_slider .swiper-container', { nextbutton: '.peoduct_type .swiper-button-next', prevbutton: '.peoduct_type .swiper-button-prev', slidesperview: 1, slidespergroup: 1, paginationclickable: true, spacebetween: 10, noswiping : true, effect : 'fade', fade: { crossfade: false, } }); } }else{ if($(".peoduct_type_slider li").length>1){ var pro2 = new swiper('.peoduct_type_slider .swiper-container', { nextbutton: '.peoduct_type .swiper-button-next', prevbutton: '.peoduct_type .swiper-button-prev', slidesperview: 1, slidespergroup: 1, paginationclickable: true, spacebetween: 10, noswiping : true, autoheight: true, fade: { crossfade: false, } }); } } if($(".peoduct_type_tab li").length>1){ var pro1 = new swiper('.peoduct_type_tab .swiper-container', { direction: 'vertical', nextbutton: '.peoduct_type .swiper-button-next', prevbutton: '.peoduct_type .swiper-button-prev', slidesperview: 8, slidespergroup: 1, paginationclickable: true, spacebetween: 8, noswiping : true, oninit: function(swiper){ var i = $('.peoduct_type_tab .swiper-slide.on').index(); swiper.slideto(i-1); }, onslidechangeend: function(swiper) { console.log(swiper.activeindex); }, breakpoints: { 1200: { direction: 'horizontal', slidesperview: 5, }, 767: { direction: 'horizontal', slidesperview: 2, } } }); } var _ind = 0; var _len = $(".peoduct_type_tab .swiper-slide").length; var url = $(".peoduct_type_tab .swiper-slide").eq(0).data("src"); btnjudge(); $(".peoduct_type_tab .swiper-slide").click(function(){ _ind = $(this).index(); $(this).addclass("on").siblings().removeclass("on"); $(".peoduct_type_slider li").eq($(this).index()).addclass("cur").siblings().removeclass("cur"); pro1.slideto(_ind, 1000, false); pro2.slideto(_ind, 500, false); btnjudge(); imgratio(); }) $(".peoduct_type .swiper-button-prev").click(function() { _ind--; btnjudge() $(".peoduct_type_tab .swiper-slide").eq(_ind).addclass("on").siblings().removeclass("on"); $(".peoduct_type_tab .swiper-slide.on").click(); // var srcurl=$(".peoduct_type_tab .swiper-slide").eq(_ind).find("img").attr("src"); // console.log(srcurl) // $(".pro_bigimg img").attr("src",srcurl) imgratio(); }) //点击又按钮,实现_ind自加1 $('.peoduct_type .swiper-button-next').click(function() { _ind++; btnjudge() $(".peoduct_type_tab .swiper-slide").eq(_ind).addclass("on").siblings().removeclass("on"); $(".peoduct_type_tab .swiper-slide.on").click(); // var srcurl=$(".peoduct_type_tab .swiper-slide").eq(_ind).find("img").attr("src"); // console.log(srcurl) // $(".pro_bigimg img").attr("src",srcurl); imgratio() }) function btnjudge() { if(_ind >= _len - 1) { $('.peoduct_type_tab .swiper-button-next').addclass("disabled") _ind = _len - 1; } else { $('.peoduct_type_tab .swiper-button-next').removeclass("disabled") } if(_ind <= 0) { $(".peoduct_type_tab .swiper-button-prev").addclass("disabled") _ind = 0; } else { $(".peoduct_type_tab .swiper-button-prev").removeclass("disabled") } } }