// swiper杞挱 var swiper = new Swiper(".mySwiper", { pagination: { el: ".swiper-pagination", clickable: true, }, // 鏃犻檺寰幆 loop: true, // 鑷姩鎾斁 autoplay: { delay: 3000, disableOnInteraction: false, }, }); var titleIndex = 0; //鏍囬鍒囨崲鎸夐挳鐨勪笅鏍 var cutIndex = 0; // 鍒嗛〉鎸夐挳涓嬫爣 var pageSize = 9; var totalPage = 0; $(".main_wrap .main").eq(titleIndex).css("display", "block"); $(".title li").eq(titleIndex).addClass("active"); // tab鍒囨崲 灞曠ず瀵瑰簲鍐呭 var main = document.querySelectorAll(".main_wrap .main"); $(".title li").click(function () { titleIndex = $(this).index(); $(this).addClass("active").siblings().removeClass("active"); // $(".main_wrap .main").eq($(this).index()).show().siblings().hide(); cutIndex = 0; paginate() }); // 鍒嗛〉 // 绗竴姝ュ垱寤哄垏鎹㈡寜閽 function createEle() { // 褰撳墠鍒楄〃鏁版嵁澶т簬9鏉℃墠鏄剧ず缈婚〉 if (totalPage <= 1) { $(".page_plugin_wrap").css("display", "none"); } else { $(".page_plugin_wrap").css("display", "block"); } var btn_num = document.getElementById("btn_num"); // 鏍规嵁鏁版嵁闀垮害鍒涘缓鏍囩 $(".btn_num").children().remove(); //娓呴櫎涓婁竴涓〉闈㈢殑鎸夐挳 for (let i = 1; i <= totalPage; i++) { var element = document.createElement("div"); element.innerHTML = i; btn_num.appendChild(element); } $(".btn_num div").removeClass("active").eq(cutIndex).addClass("active") } // 绗簩姝 鐐瑰嚮鏍囩灞曠ず瀵瑰簲鍐呭 function pageNum() { $(".btn_num div").click(function () { cutIndex = $(this).index(); if (cutIndex > 0) { $(".prev").removeClass("notAllowed"); } else if (cutIndex === 0) { $(".prev").addClass("notAllowed"); } paginate() }); } function cutMain() { $(".main_wrap .main li").hide(); if(titleIndex === 0){ let _size = $(".main_wrap .main li").size() totalPage = Math.floor(_size / pageSize) + (_size%pageSize===0?0:1); $(".main_wrap .main li").slice(cutIndex*pageSize,cutIndex*pageSize+pageSize).show(); }else{ let _size = $(".case-"+titleIndex).size() totalPage = Math.floor(_size / pageSize) + (_size%pageSize===0?0:1); $(".case-"+titleIndex).slice(cutIndex*pageSize,cutIndex*pageSize+pageSize).show(); } // var mainLi = $(".main").eq(titleIndex).find("li"); // var tabLi = $(".btn_num div"); // if (cutIndex === 0) { // mainLi.eq(9).prevAll().css("display", "block"); // mainLi.eq(8).nextAll().css("display", "none"); // tabLi.eq(cutIndex).addClass("active").siblings().removeClass("active"); // } else if (cutIndex === 1) { // mainLi.eq(9).prevAll().css("display", "none"); // mainLi.eq(8).nextAll().css("display", "block"); // mainLi.eq(17).nextAll().css("display", "none"); // tabLi.eq(cutIndex).addClass("active").siblings().removeClass("active"); // } else if (cutIndex === 2) { // mainLi.eq(18).prevAll().css("display", "none"); // mainLi.eq(17).nextAll().css("display", "block"); // mainLi.eq(26).nextAll().css("display", "none"); // tabLi.eq(cutIndex).addClass("active").siblings().removeClass("active"); // } else if (cutIndex === 3) { // mainLi.eq(27).prevAll().css("display", "none"); // mainLi.eq(26).nextAll().css("display", "block"); // mainLi.eq(35).nextAll().css("display", "none"); // tabLi.eq(3).addClass("active").siblings().removeClass("active"); // } } // 绗笁姝 涓婁笅鍒囨崲 if (cutIndex === 0) { $(".prev").addClass("notAllowed"); } // 涓婁竴椤 $(".prev").click(function () { if (cutIndex > 0) { $(".prev").removeClass("notAllowed"); $(".next").removeClass("notAllowed"); cutIndex--; } if (cutIndex === 0) { $(".prev").addClass("notAllowed"); cutIndex = 0; } paginate() }); // 涓嬩竴椤 $(".next").click(function () { if (cutIndex >= 0) { $(".prev").removeClass("notAllowed"); } // if (cutIndex + 1 === totalPage) { // $(".btn_num div").length if (cutIndex + 2 === totalPage) { $(".next").addClass("notAllowed"); } if (cutIndex + 1 === totalPage) { // 0 + 1 2 return; } cutIndex++; paginate() }); function paginate() { cutMain(); createEle(); pageNum(); } paginate() // 鏂囧瓧鍔犲姩鐢 var windowHeight = $(window).height(); $(window).scroll(function () { // 瀹㈡埛妗堜緥 var scrollTop = document.documentElement.scrollTop; if (scrollTop > $(".case_wrap").offset().top - windowHeight) { $(".case_wrap").addClass("translateY2"); } if (scrollTop > $(".caseCenter").offset().top - windowHeight) { $(".caseCenter").addClass("translateY2"); } });