$(function () {
function fixedNav() {
$(window).scroll(function () {
let scrollPos = $(window).scrollTop()
$('.anchorpoint').each(function (i) {
let thisPos = $(this).offset().top - 400
if (scrollPos >= thisPos) {
setTimeout(function () {
if (i == 2) {
$('.video_player').trigger('click')
$('.anchorpoint').eq(i).find('.video-lazyload').removeClass('video-lazyload')
} else {
$('.anchorpoint').eq(i).removeClass('video-lazyload')
}
}, 800)
}
})
})
}
fixedNav()
let kvTop = $('.anchorpoint').eq(0).offset().top
if (kvTop == 0) {
setTimeout(function () {
$('.anchorpoint').eq(0).removeClass('video-lazyload')
}, 1200)
}
var mySwiper = new Swiper('.as-tpl-hm-banner01', {
loop: false,
pagination: {
el: '.swiper-pagination01',
clickable: true,
renderBullet: function (index, className) {
switch (index) {
case 0:
text = '辅助驾驶更舒心'
break
case 1:
text = '人驾更安全'
break
case 2:
text = ''
break
}
return (
'' +
text +
''
)
},
},
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) {
let sliderWidth = $('.ias-tpl-hm-section03-01 .swiper-pagination-bullet').width()
let allWidth = sliderWidth * this.activeIndex
let transitionWidth = allWidth + 'px'
$('.ias-tpl-hm-section03-01 .ias-tpl-hm-tool .ias-tpl-pagination-bg').css('left', transitionWidth)
$('.as-tpl-hm-banner01').find('img').trigger('appear')
},
slideChangeTransitionEnd: function () {
gatabswiper(this)
},
},
})
var mySwiper2 = new Swiper('.as-tpl-hm-banner04', {
loop: false,
pagination: {
el: '.swiper-pagination04',
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-next04',
prevEl: '.swiper-button-prev04',
},
slidesPerView: 1,
loop: false,
autoplay: false,
spaceBetween: 4,
keyboard: true,
observer: true,
observeParents: true,
on: {
transitionStart: function (mySwiper2) {
let sliderWidth = $('.ias-tpl-hm-section03-04 .swiper-pagination-bullet').width()
let allWidth = sliderWidth * this.activeIndex
let transitionWidth = allWidth + 'px'
$('.ias-tpl-hm-section03-04 .ias-tpl-hm-tool .ias-tpl-pagination-bg').css('left', transitionWidth)
$('.as-tpl-hm-banner04').find('img').trigger('appear')
},
slideChangeTransitionEnd: function () {
gatabswiper(this)
},
},
})
setTimeout(function () {
let sliderBullet = $('.ias-tpl-hm-section03-02 .swiper-pagination-bullet').eq(0).innerWidth()
$('.ias-tpl-hm-section03-02 .ias-tpl-hm-tool .ias-tpl-pagination-bg').width(sliderBullet)
}, 50)
var mySwiper2 = new Swiper('.as-tpl-hm-banner02', {
loop: false,
pagination: {
el: '.swiper-pagination02',
clickable: true,
renderBullet: function (index, className) {
switch (index) {
case 0:
text = '高精 ADB'
break
case 1:
text = '照明光毯'
break
case 2:
text = '辅助驾驶灯语'
break
case 3:
text = '互动迎宾'
break
case 4:
text = '露天影院'
break
case 5:
text = '体感游戏'
break
}
return (
'' +
text +
''
)
},
},
navigation: {
nextEl: '.swiper-button-next02',
prevEl: '.swiper-button-prev02',
},
slidesPerView: 1,
loop: false,
autoplay: false,
spaceBetween: 4,
keyboard: true,
observer: true,
observeParents: true,
on: {
transitionStart: function (mySwiper2) {
let sliderWidth = $('.ias-tpl-hm-section03-02 .swiper-pagination-bullet').eq(this.activeIndex).innerWidth()
let sliderActiveWidth = $('.ias-tpl-hm-section03-02 .swiper-pagination-bullet').eq(this.activeIndex).position().left
$('.ias-tpl-hm-section03-02 .ias-tpl-hm-tool .ias-tpl-pagination-bg').css({ 'left': sliderActiveWidth, 'width': sliderWidth })
$('.as-tpl-hm-banner02').find('img').trigger('appear')
},
slideChangeTransitionEnd: function () {
gatabswiper(this)
},
},
})
setTimeout(function () {
let sliderBullet = $('.ias-tpl-hm-section03-05 .swiper-pagination-bullet').eq(0).innerWidth()
$('.ias-tpl-hm-section03-05 .ias-tpl-hm-tool .ias-tpl-pagination-bg').width(sliderBullet)
}, 50)
var mySwiper5 = new Swiper('.as-tpl-hm-banner05', {
loop: false,
pagination: {
el: '.swiper-pagination05',
clickable: true,
renderBullet: function (index, className) {
switch (index) {
case 0:
text = '辅助驾驶更舒心'
break
case 1:
text = '人驾更安全'
break
case 2:
text = '轻松观影'
break
case 3:
text = '智能算法'
break
}
return (
'' +
text +
''
)
},
},
navigation: {
nextEl: '.swiper-button-next05',
prevEl: '.swiper-button-prev05',
},
slidesPerView: 1,
loop: false,
autoplay: false,
spaceBetween: 4,
keyboard: true,
observer: true,
observeParents: true,
on: {
transitionStart: function (mySwiper2) {
let sliderWidth = $('.ias-tpl-hm-section03-05 .swiper-pagination-bullet').eq(this.activeIndex).innerWidth()
let sliderActiveWidth = $('.ias-tpl-hm-section03-05 .swiper-pagination-bullet').eq(this.activeIndex).position().left
$('.ias-tpl-hm-section03-05 .ias-tpl-hm-tool .ias-tpl-pagination-bg').css({ 'left': sliderActiveWidth, 'width': sliderWidth })
$('.as-tpl-hm-banner05').find('img').trigger('appear')
},
slideChangeTransitionEnd: function () {
gatabswiper(this)
},
},
})
setTimeout(function () {
let sliderBullet = $('.ias-tpl-hm-section03-03 .swiper-pagination-bullet').eq(0).innerWidth()
$('.ias-tpl-hm-section03-03 .ias-tpl-hm-tool .ias-tpl-pagination-bg').width(sliderBullet)
}, 50)
var mySwiper2 = new Swiper('.as-tpl-hm-banner03', {
loop: false,
pagination: {
el: '.swiper-pagination03',
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-next03',
prevEl: '.swiper-button-prev03',
},
slidesPerView: 1,
loop: false,
autoplay: false,
spaceBetween: 4,
keyboard: true,
observer: true,
observeParents: true,
on: {
transitionStart: function (mySwiper2) {
let sliderWidth = $('.ias-tpl-hm-section03-03 .swiper-pagination-bullet').eq(this.activeIndex).innerWidth()
let sliderActiveWidth = $('.ias-tpl-hm-section03-03 .swiper-pagination-bullet').eq(this.activeIndex).position().left
$('.ias-tpl-hm-section03-03 .ias-tpl-hm-tool .ias-tpl-pagination-bg').css({ 'left': sliderActiveWidth, 'width': sliderWidth })
$('.as-tpl-hm-banner03').find('img').trigger('appear')
},
slideChangeTransitionEnd: function () {
gatabswiper(this)
},
},
})
$('.ias-tpl-tip1').on('click', function () {
let currentPosition = $(window).scrollTop()
let top = $('.ias-tpl-hm-bm').offset().top - 60
$('html, body').animate(
{
scrollTop: top,
},
1000
)
$('.ias-tpl-hm-bm p').removeClass('active')
$('.ias-tpl-tip01').addClass('active')
currentPositionTop = currentPosition
return currentPositionTop
})
$('.ias-tpl-hm-bm').on('click', '.ias-tpl-tip01.active', function () {
$('html, body').animate(
{
scrollTop: currentPositionTop,
},
1000
)
$('.ias-tpl-hm-bm p').removeClass('active')
})
$(document).ready(function () {
let video = $('#myVideo')[0] // 获取video DOM元素
let interval = null // 用于控制视频播放速度的变量
let speed = 0.3 // 调整速度的变量,可根据需要调整
$('#myVideo').on('wheel', function (event) {
let deltaY = event.originalEvent.deltaY
let currentTime = video.currentTime // 获取当前播放时间
let duration = video.duration // 获取视频总时长
let newTime // 新的播放时间
if (deltaY > 0) {
// 鼠标向下滚动
newTime = currentTime + speed // 增加当前时间,加快播放速度
if (newTime > duration) newTime = duration // 防止超过视频总时长
} else {
// 鼠标向上滚动
newTime = currentTime - speed // 减少当前时间,减慢播放速度
if (newTime < 0) newTime = 0 // 防止小于0
}
video.currentTime = newTime // 设置新的播放时间
})
$(document).on('click', '.js_video_player_add', function () {
})
$(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')
},
})
})