$(document).ready(function () { new WOW().init(); var observer = new IntersectionObserver(function (entries) { entries.forEach(entry => { if (entry.isIntersecting) { animateNumber($(entry.target)); observer.unobserve(entry.target); } }); }); $('#num1, #num2, #num3, #num4').each(function () { observer.observe(this); }); function animateNumber($el) { var finalValue = parseFloat($el.data('final-value')); var currentVal = parseFloat($el.text()); var increment = finalValue / 100; // 增量,可以根据需要调整 var timer = setInterval(function () { if (parseFloat($el.text()) < finalValue) { currentVal += increment; $el.text(currentVal.toFixed(0)); // 根据需要调整小数位数 } else { clearInterval(timer); } }, 20); // 每20毫秒检查一次 } $(".zzjg-content ul li").on("click", function () { var index = $(this).index(); $(this).addClass("active").siblings().removeClass("active"); $(".zzjg-contain .zzjg-item").hide().eq(index).show(); }); $(".dl-chtitle li").on("click", function () { var index = $(this).index(); $(this).addClass("active").siblings().removeClass("active"); $(".dl-zsum").css('display', 'none'); $(".dl-chsum .dl-sum").hide().eq(index).show(); }); setTimeout(function () { // 同时开始 .bssy-g 的淡出动画和 .bssy-r 的淡入动画 $('.bssy-g').animate({ opacity: 0 }, 1000); $('.bssy-r').animate({ opacity: 1 }, 1000); }, 1000); //导航判断 $(".second-menu-right ul li a").each(function () { $this = $(this); if ($this[0].href == String(window.location)) { $(this).parent().addClass("active"); } }) //判断详情页作者来源有无 $(".detail-intro div").each(function () { var $span = $(this).find('span'); if ($span.text() === '') { $(this).addClass("detail-hidden"); } else { $(this).removeClass("detail-hidden"); } }) //文化内涵海报 var hbSwiper = new Swiper('.hb-swiper', { slidesPerView: 4, spaceBetween: 25, slidesPerGroup: 1, breakpoints: { 1020: { slidesPerView: 2.16, slidesPerGroup: 1, spaceBetween: 20.7, }, 750: { slidesPerView: 2.16, slidesPerGroup: 1, spaceBetween: 10.35, } }, navigation: { nextEl: '.hb-next', prevEl: '.hb-prev', }, }); var swiper = new Swiper("#ldlySlideThumbs", { spaceBetween: 14, slidesPerView: 5, freeMode: true, autoplay: { delay: 4000, // 自动播放的延迟时间(毫秒) }, watchSlidesProgress: true, slideThumbActiveClass: 'swiper-slide-thumb-active', breakpoints: { 1020: { loop: true, autoplay: { delay: 3000, // 自动播放的延迟时间(毫秒) }, }, } }); var swiper2 = new Swiper("#ldlySlide", { spaceBetween: 14, autoplay: { delay: 4000, // 自动播放的延迟时间(毫秒) }, navigation: { nextEl: ".ldly-next", prevEl: ".ldly-prev", }, thumbs: { swiper: swiper, }, breakpoints: { 1020: { loop: true, autoplay: { delay: 3000, // 自动播放的延迟时间(毫秒) }, }, } }); function setInitialThumbActive() { if (!swiper || !swiper.slides || !swiper.slides[0]) { console.log('Swiper或slides未初始化'); return; } var firstThumb = swiper.slides[0]; if (firstThumb) { firstThumb.classList.add('swiper-slide-thumb-active'); } } swiper2.on('slideChangeTransitionEnd', function () { var activeIndex = swiper2.activeIndex; Array.from(swiper.slides).forEach(function (slide, index) { if (index === activeIndex) { slide.classList.add('swiper-slide-thumb-active'); } else { slide.classList.remove('swiper-slide-thumb-active'); } }); }); setInitialThumbActive(); });