$(document).ready(function () { var screenwidth = $(window).width() var mySwiper = new Swiper('.as-tpl-hm-banner01', { autoHeight: true, loop: false, pagination: { el: '.swiper-pagination01', clickable: true, }, navigation: { nextEl: '.swiper-button-next01', prevEl: '.swiper-button-prev01', }, slidesPerView: 1, speed: 500, loop: false, autoplay: false, spaceBetween: 10, keyboard: true, observer: true, observeParents: true, breakpoints: { // 当窗口宽度 >= 900px (平板/小PC) 900: { slidesPerView: 1, spaceBetween: 20 }, }, on: { transitionStart: function (mySwiper) { $('.as-tpl-hm-banner01').find('img').trigger('appear') }, slideChangeTransitionEnd: function () { gatabswiper(this) }, }, }) var mySwiper = new Swiper('.as-tpl-hm-banner02', { loop: false, pagination: { el: '.swiper-pagination01', clickable: true, }, navigation: { nextEl: '.swiper-button-next02', prevEl: '.swiper-button-prev02', }, slidesPerView: 1, speed: 500, loop: false, autoplay: false, spaceBetween: 10, keyboard: true, observer: true, observeParents: true, breakpoints: { // 当窗口宽度 >= 900px (平板/小PC) 900: { slidesPerView: 3.4, spaceBetween: 20 }, }, on: { transitionStart: function (mySwiper) { $('.as-tpl-hm-banner01').find('img').trigger('appear') }, slideChangeTransitionEnd: function () { gatabswiper(this) }, }, }) }) $(function () { var screenwidth = $(window).width() // WebP支持检测(首次运行时缓存结果) function checkWebPSupport(callback) { if ( typeof localStorage !== "undefined" && localStorage.getItem("webpSupport") !== null ) { return callback(localStorage.getItem("webpSupport") === "true") } const img = new Image() img.onload = function () { const result = img.width > 0 && img.height > 0 localStorage.setItem("webpSupport", result) callback(result) } img.onerror = function () { localStorage.setItem("webpSupport", false) callback(false) } img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=" } checkWebPSupport(function (isSupported) { $("img").each(function () { const $img = $(this) const webpSrc = $img .closest("picture") .find('source[type="image/webp"]') .data("srcset") const fallbackSrc = $img.data("src") // 动态设置真实图片路径 $img.data("original", isSupported ? webpSrc : fallbackSrc) }) $("img").lazyload({ threshold: 200, effect: "fadeIn", appear: function () { const realSrc = $(this).data("original") $(this).attr("src", realSrc) $(this).addClass("lazy-loaded") }, load: function () { $(this).addClass("lazy-loaded") }, error: function () { $(this).attr("src", "img/error.jpg") }, }) }) // 初始化懒加载 $("img").lazyload({ effect: "fadeIn", // 淡入效果 threshold: 100, // 提前300px加载 failure_limit: 15, // 最大容错数量 skip_invisible: true, // 加载隐藏图片 appear: function () { // 加载前回调 $(this).css("background", "transparent") $(this).removeClass("lazyload") }, load: function () { // 加载完成回调 $(this).addClass("lazy-loaded") }, }) if (screenwidth < 900) { setTimeout(function () { $('.ias-tpl-hmpc-show ').remove() }, 50) // 华为乾崑app $(document).on('click', '.ias-car-section06 .section06-con .wechat-con li h4', function (e) { e.stopPropagation() if ($(this).hasClass('active')) { $(this).removeClass('active') $(this).next('.mob-wechat-pop').hide() } else { $(this).addClass('active') $(this).next('.mob-wechat-pop').show() $(this).parent('li').siblings().find('.mob-wechat-pop').hide() $(this).parent('li').siblings().find('h4').removeClass('active') } }) $(document).on('click', '.mob-wechat-pop', function (e) { e.stopPropagation() $(this).show() }) $(document).on('click', function () { $('.mob-wechat-pop').hide() $('.ias-car-section06 .section06-con .wechat-con li h4').removeClass('active') }) var kv_vd01 = $('.slide-ab01').data('url') $('.slide-ab01').find('video').attr('src', kv_vd01) // $('.slide-ab01').find('video')[0].play() } else { $('.ias-tpl-hmmob-show ').remove() var vd01 = $('.vd01').data('url') $('.vd01').find('video').attr('src', vd01) } $(".setion5_desc .tit").click(function () { var _this = $(this) _this.parent().toggleClass('active').siblings().removeClass('active') _this.next().slideToggle() _this.parent().siblings().find('.txt').slideUp() if (screenwidth < 900) { $(".ias-mobile-tpl-header").hide() setTimeout(function () { $('html, body').animate({ scrollTop: _this.parent().offset().top - 150 }, 500) setTimeout(function () { $(".ias-mobile-tpl-header").show() }, 500) }, 500) } }) $(".setion5_desc .all.all1").click(function () { $(".setion5_desc").addClass('active') for (let i = 0; i < $(".setion5_desc .list").length; i++) { $(".setion5_desc .list").eq(i).addClass('active') $(".setion5_desc .list").eq(i).find('.txt').slideDown() } }) $(".setion5_desc .all.all2").click(function () { $(".setion5_desc").removeClass('active') for (let i = 0; i < $(".setion5_desc .list").length; i++) { $(".setion5_desc .list").eq(i).removeClass('active') $(".setion5_desc .list").eq(i).find('.txt').slideUp() } }) })