$(function () { // var images = $('.lazyload') // function callback(entries) { // for (let i of entries) { // if (i.isIntersecting) { // let img = i.target // let trueSrc = img.getAttribute('data-src') // img.setAttribute('src', trueSrc) // img.addEventListener('load', function () { // setTimeout(function () { // img.classList.remove('lazyload') // }, 1200) // }) // observer.unobserve(img) // } // } // } // const observer = new IntersectionObserver(callback) // for (let i of images) { // observer.observe(i) // } // 第一屏 var screenwidth = $(window).width() // 轮播一 var mySwiper = new Swiper('.ias-abus-banner-banner01', { // direction: "vertical", loop: false, pagination: { el: '.swiper-pagination01', type: 'fraction', }, navigation: { nextEl: '.swiper-button-next01', prevEl: '.swiper-button-prev01', }, slidesPerView: 1, speed: 500, loop: false, autoplay: false, spaceBetween: 4, keyboard: true, observer: true, observeParents: true, on: { transitionStart: function (mySwiper) { $('.ias-abus-banner-banner01').find('img').trigger('appear') }, slideChangeTransitionEnd: function () { gatabswiper(this); }, }, }) // 轮播二 var mySwiper = new Swiper('.ias-abus-banner-banner02', { // direction: "vertical", loop: false, pagination: { el: '.swiper-pagination02', type: 'fraction', }, navigation: { nextEl: '.swiper-button-next02', prevEl: '.swiper-button-prev02', }, slidesPerView: 1, speed: 500, loop: false, autoplay: false, spaceBetween: 4, keyboard: true, observer: true, observeParents: true, on: { transitionStart: function (mySwiper) { $('.ias-abus-banner-banner02').find('img').trigger('appear') }, slideChangeTransitionEnd: function () { gatabswiper(this); }, }, }) // 轮播三 var mySwiper = new Swiper('.ias-abus-banner-banner03', { // direction: "vertical", loop: false, pagination: { el: '.swiper-pagination03', type: 'fraction', }, navigation: { nextEl: '.swiper-button-next03', prevEl: '.swiper-button-prev03', }, slidesPerView: 1, speed: 500, loop: false, autoplay: false, spaceBetween: 4, keyboard: true, observer: true, observeParents: true, on: { transitionStart: function (mySwiper) { $('.ias-abus-banner-banner03').find('img').trigger('appear') }, slideChangeTransitionEnd: function () { gatabswiper(this); }, }, }) // 轮播四 var mySwiper = new Swiper('.ias-abus-banner-banner05', { // direction: "vertical", loop: false, pagination: { el: '.swiper-pagination05', type: 'fraction', }, navigation: { nextEl: '.swiper-button-next05', prevEl: '.swiper-button-prev05', }, slidesPerView: 1, speed: 500, loop: false, autoplay: false, spaceBetween: 4, keyboard: true, observer: true, observeParents: true, on: { transitionStart: function (mySwiper) { $('.ias-abus-banner-banner05').find('img').trigger('appear') }, slideChangeTransitionEnd: function () { gatabswiper(this); }, }, }) $('.ias-abus-banner-banner05 .swiper-slide').each(function (i) { i += 1 $('.ias-abus-banner-banner05 .ias-abus-banner-title span ').text(i) }) // 轮播五 var mySwiper = new Swiper('.ias-abus-banner-banner06', { // direction: "vertical", loop: false, pagination: { el: '.swiper-pagination06', type: 'fraction', }, navigation: { nextEl: '.swiper-button-next06', prevEl: '.swiper-button-prev06', }, slidesPerView: 1, speed: 500, loop: false, autoplay: false, spaceBetween: 4, keyboard: true, observer: true, observeParents: true, on: { transitionStart: function (mySwiper) { $('.ias-abus-banner-banner06').find('img').trigger('appear') }, slideChangeTransitionEnd: function () { gatabswiper(this); }, }, }) let flag = true $(window).on('scroll', function () { var countUP_top = $('#ias-abus').offset().top - 220, high = $(window).scrollTop() if (high > countUP_top && flag) { countNumber(['ias-abus-num01', 'ias-abus-num02', 'ias-abus-num03', 'ias-abus-num04']) flag = false } if (high < countUP_top) { flag = true } }) function countNumber(elementarray, options) { options = Object.assign({}, options, { allTime: 3500, speed: 50, }) var allTime = options.allTime, speed = options.speed if (elementarray instanceof Array) { var oneNumArray = [], elementidArray = [], countArray = [], valueOneArray = [] for (var i = 0; i < elementarray.length; i++) { var elementid = document.getElementById(elementarray[i]), valueN = elementid.getAttribute('data-value'), valueOne = 0 if (valueN instanceof Array) { valueOne = eval(valueN)[0] } else { valueOne = valueN } valueOneArray[i] = valueOne oneNumber = Math.floor(valueOne / (allTime / speed)) || 1 oneNumArray[i] = oneNumber elementidArray[i] = elementid countArray[i] = 0 } var datetime = setInterval(function () { var countClear = 0 for (var k = 0; k < elementidArray.length; k++) { countArray[k] += oneNumArray[k] if (countArray[k] >= valueOneArray[k]) { countClear++ countArray[k] = valueOneArray[k] } elementidArray[k].innerText = countArray[k] } if (countClear >= 4) { clearInterval(datetime) } }, 30) } if (typeof elementarray === 'string') { var e = document.getElementById(elementarray), allNum = eval(e.getAttribute('data-value'))[0] ? eval(e.getAttribute('data-value'))[0] : 0, oneNumber = Math.floor(allNum / (allTime / speed)), count = 0 var datetime = setInterval(function () { count += oneNumber if (count >= allNum) { clearInterval(datetime) count = allNum } e.innerText = count }, 30) } } // 20250319 var des = '

视频由专业人士在确保安全情况下拍摄,请勿模仿。

' $(document).on('click', '.js_video_player_tips', function () { $('.vjs-big-play-centered').append(des) }) $(document).on('click', '.close-video-popup', function () { $('.video-tips').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) 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') }, }) }) $('.ias-abus-section-con a').each(function () { var currentHref = $(this).attr('href') $(this).removeAttr('target') $(this).attr('href', currentHref.replace('https://www.yw-beta.com/', 'https://auto.huawei.com/')) })