$(function () { // 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); let webpSrc = $img.closest('picture').find('source[type="image/webp"]').data('srcset'); // const webpSrcMob = $img // .closest('picture') // .find('source[type="image/webp"][media*="max-width: 768px"]') // .data('srcset'); // if ($(window).width() < 900) { // if (webpSrcMob != undefined) { // webpSrc = webpSrcMob; // } // } 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: 0, // 提前300px加载 failure_limit: 15, // 最大容错数量 skip_invisible: true, // 加载隐藏图片 appear: function () { // 加载前回调 let _this = $(this); // if (_this.data('original') != undefined) { _this.on('load', function () { _this.css('background', 'transparent'); _this.removeClass('lazyload'); $('.kv-text').removeClass('lazy-text'); $('.kv-txt-chewei').removeClass('lazy-text'); $('.kv-ads-txt').removeClass('lazy-text'); // mySwiperKv.autoplay.start(); // mySwipercar.autoplay.start(); }); // } }, load: function () { // 加载完成回调 $(this).addClass('lazy-loaded'); }, }); // 直播 var mySwiperlive = new Swiper('.ias-live-banner', { direction: 'vertical', loop: true, loopFillGroupWithBlank: true, // effect: 'fade', // centeredSlides: true, // pagination: { // el: '.swiper-pagination-kv', // clickable: true, // }, // navigation: { // nextEl: '.swiper-button-next-kv', // prevEl: '.swiper-button-prev-kv', // }, slidesPerView: 3, slidesPerGroup: 1, speed: 500, // 20250925 autoplay: { delay: 30000, disableOnInteraction: false, }, // autoplay: true, spaceBetween: 16, keyboard: true, observer: true, observeParents: true, mousewheel: true, on: { transitionStart: function (mySwiperlive) { $('.ias-live-banner').find('img').trigger('appear'); }, }, }); let removedVideoBoxes = []; function isMobile01() { return window.innerWidth <= 900; } function restoreVideoBoxes() { if (isMobile01() && removedVideoBoxes.length > 0) { $('body').append(removedVideoBoxes); removedVideoBoxes = []; } } $(window).resize(function () { var width = $('.live-show').width(); var height = (width * 9) / 16; var heightbox = height + 'px'; $('.live-show').height(height); $('.video_box,.ias-live-banner-con').height(heightbox); }); $('.play_video').click(function () { $('body').addClass('active'); if (isMobile01()) { $('.video-box').each(function () { removedVideoBoxes.push($(this).detach()); }); } $('body').addClass('active'); mySwiperlive.autoplay.start(); $('.ias-live-banner').find('img').trigger('appear'); let videoSrc = $(this).attr('data-video'); $('.popup_box2').addClass('active'); var width = $('.live-show').width(); var height = (width * 9) / 16; var heightbox = height + 'px'; $('.live-show').height(height); $('.video_box,.ias-live-banner-con').height(heightbox); setTimeout(function () { $('.live-show iframe').attr('src', videoSrc); }, 200); }); $('.popup_box2 .video_close').click(function () { $('body').removeClass('active'); mySwiperlive.autoplay.stop(); $('.popup_box2').removeClass('active'); $('.live-show iframe').attr('src', ''); restoreVideoBoxes(); }); // $('.popup_box2 .popup_bg').click(function () { // $('.popup_box2').removeClass('active'); // $('.live-show iframe').attr('src', ''); // restoreVideoBoxes(); // }); var screenwidth = $(window).width(); // kv var mySwiperKv = new Swiper('.ias-car-kvbanner', { // direction: "vertical", loop: true, pagination: { el: '.swiper-pagination-kv', clickable: true, }, navigation: { nextEl: '.swiper-button-next-kv', prevEl: '.swiper-button-prev-kv', }, slidesPerView: 1, speed: 500, // 20250925 autoplay: { delay: 8000, disableOnInteraction: false, }, // autoplay: true, spaceBetween: 4, keyboard: true, observer: true, observeParents: true, on: { transitionStart: function (mySwiperKv) { $('.ias-car-kvbanner').find('img').trigger('appear'); }, }, }); //方案 if (screenwidth < 900) { setTimeout(function () { $('.ias-tpl-hmpc-show ').remove(); }, 50); var mySwiper = new Swiper('.section02-banner', { // direction: "vertical", loop: false, pagination: { el: '.swiper-pagination-sec02', clickable: true, renderBullet: function (index, className) { switch (index) { case 0: text = '乾崑智驾'; break; case 1: text = '鸿蒙座舱'; break; case 2: text = '乾崑车控'; break; case 3: text = '乾崑车载光'; break; case 4: text = '乾崑车云服务'; break; } return ( '' + text + '' ); }, }, navigation: { nextEl: '.swiper-button-next-kv', prevEl: '.swiper-button-prev-kv', }, slidesPerView: 1, speed: 400, // 20250925 // autoplay: { // delay: 8000, // disableOnInteraction: false, // }, // autoplay: true, spaceBetween: 4, keyboard: true, observer: true, observeParents: true, on: { transitionStart: function (mySwiper) { $('.section02-banner').find('img').trigger('appear'); }, }, }); // 华为乾崑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'); }); } else { $('.ias-tpl-hmmob-show ').remove(); } $('.ias-car-section02 .swiper-slide').hover( function () { $(this).find('.js_video_player').trigger('click'); $(this).find('video')[0].play(); $(this).addClass('active'); }, function () { $('.ias-car-section02 .swiper-slide').find('video').trigger('pause'); $(this).find('video')[0].pause(); $('.ias-car-section02 .swiper-slide').removeClass('active'); } ); //首页合作车型 var scrollTopY = window.scrollY; var topcar = $('.ias-car-section03').offset().top - 500; if (scrollTopY >= topcar) { $('.sec03-banner').find('img').trigger('appear'); } var isMobile = screenwidth < 900; var mySwipercar = new Swiper('.sec03-banner', { // direction: "vertical", loop: false, // loopedSlides: 2, // centeredSlides: true, pagination: { el: '.swiper-pagination-sec03', clickable: true, renderBullet: function (index, className) { switch (index) { case 0: text = '阿维塔 12'; break; case 1: text = '尚界 H5'; break; case 2: text = '问界 M7'; break; case 3: text = '阿维塔 07'; break; case 4: text = '享界 S9T'; break; } return ( '' + text + '' ); }, }, navigation: { nextEl: '.swiper-button-next-sec03', prevEl: '.swiper-button-prev-sec03', }, slidesPerView: 'auto', speed: 400, // 20250925 autoplay: isMobile ? false : { delay: 8000, disableOnInteraction: false, }, // autoplay: false, spaceBetween: 8, keyboard: true, observer: true, observeParents: true, breakpoints: { 900: { // PC端 loop: true, loopedSlides: 2, centeredSlides: true, spaceBetween: 20, keyboard: true, observer: true, observeParents: true, // slideToClickedSlide: true, }, }, on: { transitionStart: function (mySwipercar) { // $('.sec03-banner').find('img').trigger('appear'); }, realIndexChange: function () { var sliderwidth = $('.ias-car-section03 .swiper-pagination-bullet') .eq(this.realIndex) .outerWidth(); var allwidth = $('.ias-car-section03 .swiper-pagination-bullet') .eq(this.realIndex) .position().left; var wd = allwidth + 'px'; $(' .ias-car-sec03-banner .pagination-sec03 .pagination-sec03-con .bg').css({ left: wd, width: sliderwidth, }); $('.sec03-banner').find('img').trigger('appear'); }, slideChangeTransitionEnd: function (mySwipercar) {}, slideChange: function (mySwipercar) { // const activeIndex = this.activeIndex; // const realIndex = this.realIndex; // console.log('当前激活幻灯片索引:', activeIndex); // console.log('真实索引(适用于loop模式):', realIndex); // 获取激活的分页指示器 // const activeBullet = $('.ias-car-sec03-banner .swiper-pagination-bullet-active'); // if (activeBullet) { // console.log('激活的bullet元素:', activeBullet); // } // activeBullet.addClass('red'); // console.log(this.realIndex); }, }, }); var sliderwidth = $('.ias-car-section03 .swiper-pagination-bullet').eq(0).outerWidth(); $(' .ias-car-sec03-banner .pagination-sec03 .pagination-sec03-con .bg').css({ left: 0, width: sliderwidth, }); $(document).on('click', '.ias-car-sec03-banner .swiper-slide-prev', function () { $('.swiper-button-prev-sec03').trigger('click'); }); $(document).on('click', '.ias-car-sec03-banner .swiper-slide-next', function () { $('.swiper-button-next-sec03').trigger('click'); }); setTimeout(function () { mySwipercar.loopDestroy(); mySwipercar.loopCreate(); }, 100); // 视频中心 // $(window).scroll(function () { // var scrollTop = $(window).scrollTop(); // var top = $('.ias-car-section04').offset().top - 240; // if (scrollTop >= top) { // $('.ias-car-section04').find('.js_video_player_pc').trigger('click'); // $('.ias-car-section04').find('video')[0].play(); // $('.ias-car-section04 .kv-video').addClass('active'); // } // }); // 微信端 function isMobileWeChatBrowser() { const ua = navigator.userAgent.toLowerCase(); const isWeChat = ua.indexOf('micromessenger') !== -1; // 微信浏览器检测‌:ml-citation{ref="2,7" data="citationList"} const isMobile = /android|iphone|ipad/i.test(ua); // 移动端检测‌:ml-citation{ref="7,8" data="citationList"} return isWeChat && isMobile; } // 使用示例 if (isMobileWeChatBrowser()) { $('.js_video_player_pc').remove(); } // 20250829 $('.kv-swiper1 .ias-tpl-play-icon01').click(function () { $('.video-box').first().addClass('kv-vd'); }); $('.kv-swiper1 .ias-tpl-play-icon').click(function () { $('.video-box').eq(1).addClass('kv-vd'); }); $('.ias-mobile-tpl-header-nav-item:nth-child(5)').click(function () { $('body').removeClass('ias-tpl-overflow-hidden'); $('.ias-mobile-header-menu').removeClass('ias-mobile-header-menu-active'); $('.ias-mobile-tpl-header-nav-list').removeClass('ias-mobile-tpl-header-nav-list-active'); }); // 251118 function isIOSSafari() { const ua = navigator.userAgent; // 必须是iOS设备 const isIOS = /iPad|iPhone|iPod/.test(ua); if (!isIOS) return false; // 必须是Safari浏览器(排除其他iOS浏览器) const isSafari = /Safari/.test(ua); const isChrome = /CriOS/.test(ua); // iOS Chrome const isFirefox = /FxiOS/.test(ua); // iOS Firefox const isEdge = /EdgiOS/.test(ua); // iOS Edge // 是Safari且不是其他浏览器 return isSafari && !isChrome && !isFirefox && !isEdge; } if (isIOSSafari()) { $('.other').hide(); $('.ios').show(); } else { $('.other').show(); $('.ios').hide(); } });