$(document).ready(function () { var screenwidth = $(window).width() if (screenwidth < 900) { $('.ias-tpl-hmpc-show ').remove() var kv_vd = $('.slide-ab').data('url') $('.slide-ab').find('video').attr('src', kv_vd) var kv_vd01 = $('.slide-ab01').data('url') $('.slide-ab01').find('video').attr('src', kv_vd01) } else { $('.ias-tpl-hmmob-show ').remove() var vd01 = $('.vd01').data('url') $('.vd01').find('video').attr('src', vd01) var vd1 = $('.vd1').data('url') $('.vd1').find('video').attr('src', vd1) var vd2 = $('.vd2').data('url') $('.vd2').find('video').attr('src', vd2) var vd3 = $('.vd3').data('url') $('.vd3').find('video').attr('src', vd3) var vd4 = $('.vd4').data('url') $('.vd4').find('video').attr('src', vd4) var vd5 = $('.vd5').data('url') $('.vd5').find('video').attr('src', vd5) var vd6 = $('.vd6').data('url') $('.vd6').find('video').attr('src', vd6) } }) $(function () { var screenwidth = $(window).width() if (screenwidth < 900) { $('.ias-tpl-hmpc-show ').remove() } else { $('.ias-tpl-hmmob-show ').remove() } // 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') $('.safety-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') }, }, }) if (mySwiperlive && mySwiperlive.initialized) { mySwiperlive.autoplay.stop() } 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()) }) } 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(); // }); // kv var isUserInteracting = false var hands = 'null' 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') }, // 251125埋码 // 开始拖拽 // 监听触摸开始 touchStart: function () { isUserInteracting = true }, // 监听滑动结束 touchEnd: function () { // 短暂延迟后重置状态,确保能捕获到切换事件 clearTimeout(hands) hands = setTimeout(() => { isUserInteracting = false }, 1000) }, slideChangeTransitionEnd: function () { if (isUserInteracting) { gakvswiper(this) // 手动滑动后的处理逻辑 } else { // 自动播放后的处理逻辑 } }, }, }) // 首页kv 轮播点 $(document).on('click', '.swiper-pagination-kv span', function () { const $_slide = $('.ias-car-kvbanner .swiper-slide-active') pageName = window.gaInfo && window.gaInfo.pageName pageCategory = window.gaInfo && window.gaInfo.pageCategory let kvhash = $_slide.data('kvhash') let kvactiontype = $_slide.data('kvactiontype') let kvmodule = $_slide.data('kvmodule') let kvbuttonname = $_slide.data('kvbuttonname') let kvtitle = $_slide.data('kvtitle') let kvurl = $_slide.data('kvurl') window.dataLayer.push({ event: 'pic_switch', page_category: pageCategory, page_name: pageName, page_hash: kvhash, action_type: kvactiontype, module: kvmodule, button_name: kvbuttonname, pic_title: kvtitle, pic_url: kvurl, }) // console.log({ // event: 'pic_switch', // page_category: pageCategory, // page_name: pageName, // page_hash: kvhash, // action_type: kvactiontype, // module: kvmodule, // button_name: kvbuttonname, // pic_title: kvtitle, // pic_url: kvurl, // }); }) //方案 if (screenwidth < 900) { 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') }, slideChangeTransitionEnd: function () { gatabswiper(this) }, }, }) // 华为乾崑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-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 isUserInteractingcar = false var handscar = 'null' 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 = '昊铂 A800' break case 1: text = '全新奥迪 Q5L' break case 2: text = '享界 S9' break case 3: text = '阿维塔 12' break case 4: text = '尚界 H5' 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') }, // 251125埋码 // 开始拖拽 // 监听触摸开始 touchStart: function () { isUserInteractingcar = true }, // 监听滑动结束 touchEnd: function () { // 短暂延迟后重置状态,确保能捕获到切换事件 clearTimeout(handscar) handscar = setTimeout(() => { isUserInteractingcar = false }, 1000) }, slideChangeTransitionEnd: function () { if (isUserInteractingcar) { gatabswiper(this) // 手动滑动后的处理逻辑 } else { // 自动播放后的处理逻辑 } }, }, }) $(document).on('click', '.swiper-pagination-sec03 span', function () { const $_slide = $('.sec03-banner .swiper-slide-active') const pageName = window.gaInfo && window.gaInfo.pageName const pageCategory = window.gaInfo && window.gaInfo.pageCategory let tabhash = $_slide.data('tabhash') let tabactiontype = $_slide.data('tabactiontype') let tabmodule = $_slide.data('tabmodule') let tabname = $_slide.data('tabname') window.dataLayer.push({ event: 'tab_click', page_category: pageCategory, page_name: pageName, page_hash: tabhash, action_type: tabactiontype, module: tabmodule, tab_name: tabname, }) // console.log({ // event: 'tab_click', // page_category: pageCategory, // page_name: pageName, // page_hash: tabhash, // action_type: tabactiontype, // module: tabmodule, // tab_name: tabname, // }); }) 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) // 视频中心 vdflag = true $(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'); if (vdflag) { if (screenwidth < 900) { var vd = $('.fa-video').data('url') $('.ias-car-section04').find('video').attr('src', vd) } else { var vd7 = $('.vd7').data('url') $('.vd7').find('video').attr('src', vd7) } vdflag = false } // $('.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() $('.video-wx').remove() $('.wx-pic').show() } // 判断终端为小米手机 function isXiaomiDevice() { const ua = navigator.userAgent.toLowerCase() // 主要检测逻辑 const isXiaomi = ua.includes('mi ') || // MI设备 ua.includes('redmi ') || // Redmi设备 ua.includes('xiaomi ') || // Xiaomi设备 ua.includes('miui/') || // MIUI系统 ua.includes('hm') || // 红米设备型号 ua.includes('210') || // 小米设备型号开头 ua.includes('mibrowser') || // 小米浏览器 ua.includes('miuibrowser') // MIUI浏览器 return isXiaomi } // 使用 // if (isXiaomiDevice()) { // $('.video-xiaomi-hide').remove() // $('.video-xiaomi').show() // } // 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() } }) document.addEventListener('DOMContentLoaded', function () { var video1 = document.getElementById('myVideo1') var video2 = document.getElementById('myVideo2') // 微信环境检测 function isWeixin() { return /MicroMessenger/i.test(navigator.userAgent) } if (isWeixin()) { // 微信环境下使用WeixinJSBridge if (typeof WeixinJSBridge != "undefined") { WeixinJSBridge.invoke('getNetworkType', {}, function () { video1.play() video2.play() }) } else { document.addEventListener('WeixinJSBridgeReady', function () { WeixinJSBridge.invoke('getNetworkType', {}, function () { video1.play() video2.play() }) }, false) } } else { // 非微信环境正常播放 video1.play().catch(function (e) { console.log("Autoplay prevented:", e) }) video2.play().catch(function (e) { console.log("Autoplay prevented:", e) }) } })