$(function () {
// 第一屏
var screenwidth = $(window).width();
window.addEventListener('scroll', function () {
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
var scrollHeight = $('.ias-tpl-hmkv-con').height();
var scrHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
var src = (scrollTop / scrHeight) * 100;
// document.querySelector('.ias-tpl-hmkv-con').style.transform = `translateY(${src}%)`
var fixedh = $('.ias-tpl-hmkv-con-bg').offset().top + 300;
if (
(scrollTop >= fixedh && screenwidth >= 850) ||
(scrollTop >= fixedh && screenwidth <= 500)
) {
$('.ias-tpl-hmkv-con').addClass('active');
document.querySelector('.ias-tpl-hmkv-con').style.top = '-300px';
} else {
$('.ias-tpl-hmkv-con').removeClass('active');
document.querySelector('.ias-tpl-hmkv-con').style.top = '0';
}
// 20250611
// var banner03Top = $('#banner03').offset().top - 100
// if (scrollTop >= banner03Top) {
// $('.video_player4').trigger('click')
// }
});
var FirstmaxScale = 2.5;
if (screenwidth <= 500) {
FirstmaxScale = 1.3;
}
if (screenwidth <= 370) {
FirstmaxScale = 1.2;
}
// 第二屏
window.onscroll = function () {
function rotat(a) {
var rotatable = document.getElementById('ias-tplrotatable');
var maxRotation = 60;
var maxScale = FirstmaxScale;
var maxSopacity = 2;
var docScrollTop = document.documentElement.scrollTop;
var maxScrollTop = a;
var scrollRatio = docScrollTop / maxScrollTop;
var rotation = maxRotation * scrollRatio - (maxRotation * scrollRatio ** 2) / 2;
var scale = maxScale - maxScale * scrollRatio;
var opacity = maxSopacity - maxSopacity * scrollRatio;
if (scale <= 1) {
rotatable.style.transform = 'scale(' + 1 + ', ' + 1 + ')';
} else {
rotatable.style.transform = 'scale(' + scale + ', ' + scale + ')';
}
}
function rotat1(a, b) {
var rotatable1 = document.getElementById('ias-tplrotatable2');
var maxRotation1 = 60;
var maxScale1 = FirstmaxScale;
var maxSopacity1 = 2;
var docScrollTop1 = document.documentElement.scrollTop;
var maxScrollTop1 = a;
var scrollRatio1 = docScrollTop1 / maxScrollTop1;
var rotation1 = maxRotation1 * scrollRatio1 - (maxRotation1 * scrollRatio1 ** 2) / 2;
var scale1 = maxScale1 - maxScale1 * scrollRatio1;
var opacity1 = scrollRatio1;
rotatable1.style.transform = 'scale(' + scale1 + ', ' + scale1 + ')';
if (docScrollTop1 > b) {
// rotatable1.style.opacity = opacity1
} else {
rotatable1.style.opacity = 0;
}
if (scale1 <= 1) {
rotatable1.style.transform = 'scale(' + 1 + ', ' + 1 + ')';
rotatable1.style.opacity = 1;
} else {
rotatable1.style.transform = 'scale(' + scale1 + ', ' + scale1 + ')';
rotatable1.style.opacity = 1;
}
}
if (screenwidth <= 2700 && screenwidth >= 2160) {
rotat(1400);
rotat1(1400, 600);
}
if (screenwidth <= 2170 && screenwidth >= 1930) {
rotat(1200);
rotat1(1200, 200);
}
if (screenwidth <= 1930 && screenwidth >= 1600) {
rotat(1400);
rotat1(1400, 600);
}
if (screenwidth <= 1600 && screenwidth >= 1500) {
rotat(1200);
rotat1(1200, 400);
}
if (screenwidth <= 1500 && screenwidth >= 1380) {
rotat(1200);
rotat1(1200, 400);
}
if (screenwidth <= 1380 && screenwidth >= 1200) {
rotat(600);
rotat1(600, 50);
}
if (screenwidth <= 1200 && screenwidth >= 900) {
rotat(300);
rotat1(300, 50);
}
if (screenwidth <= 900 && screenwidth >= 500) {
rotat(1200);
rotat1(1200, 200);
}
if (screenwidth <= 500) {
rotat(1600);
rotat1(1600, 1200);
}
};
// 轮播一
var mySwiper = new Swiper('.as-tpl-hm-banner01', {
// direction: "vertical",
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 = '迎宾灯语远程 DIY';
break;
case 3:
text = '全景行车记录仪';
break;
case 4:
text = '手机远程控车';
break;
}
return (
// '' + text + "";
'' +
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) {
var sliderwidth = $('.ias-tpl-hm-section03-01 .swiper-pagination-bullet').width();
var allwidth = sliderwidth * this.activeIndex;
var wd = allwidth + 'px';
$('.ias-tpl-hm-section03-01 .ias-tpl-hm-tool .ias-tpl-pagination-bg').css('left', wd);
},
slideChangeTransitionEnd: function () {
$('.player-outer-box').find('video').trigger('pause');
if (screenwidth > 900) {
$('.js_video_player').removeClass('invisible');
$('.ias-tpl-hm-section03 .swiper .ias-tpl-hmpc-show img').removeClass('invisible');
}
$('.as-tpl-hm-banner01').find('img').trigger('appear');
gatabswiper(this);
},
},
});
// $(document).on('click', '.swiper-pagination02 span:nth-child(2)', function () {
// $('.video_player3').trigger('click')
// })
// 轮播二
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 = '车辆问题专业会诊';
break;
case 1:
text = '车管家';
break;
case 2:
text = '';
break;
}
return (
// '' + text + "";
'' +
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) {
var sliderwidth = $('.ias-tpl-hm-section03-02 .swiper-pagination-bullet').width();
var allwidth = sliderwidth * this.activeIndex;
var wd = allwidth + 'px';
$('.ias-tpl-hm-section03-02 .ias-tpl-hm-tool .ias-tpl-pagination-bg').css('left', wd);
$('.as-tpl-hm-banner02').find('img').trigger('appear');
// if ($('.as-tpl-hm-banner02 .swiper-slide2').hasClass('swiper-slide-active')) {
// $('.video_player3').trigger('click')
// }
},
slideChangeTransitionEnd: function () {
gatabswiper(this);
},
},
});
$(document).on('click', '.swiper-pagination03 span:nth-child(2)', function () {
$('.as-tpl-hm-banner03 .video_player3').trigger('click');
});
// 轮三
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 + "";
'' +
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) {
var sliderwidth = $('.ias-tpl-hm-section03-03 .swiper-pagination-bullet').width();
var allwidth = sliderwidth * this.activeIndex;
var wd = allwidth + 'px';
$('.ias-tpl-hm-section03-03 .ias-tpl-hm-tool .ias-tpl-pagination-bg').css('left', wd);
$('.as-tpl-hm-banner03').find('img').trigger('appear');
if ($('.as-tpl-hm-banner03 .swiper-slide2').hasClass('swiper-slide-active')) {
$('.as-tpl-hm-banner03 .video_player3').trigger('click');
}
},
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 = 'TSP';
break;
case 3:
text = 'eSIM 服务';
break;
}
return (
// '' + text + "";
'' +
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) {
var sliderwidth = $('.ias-tpl-hm-section03-04 .swiper-pagination-bullet').width();
var allwidth = sliderwidth * this.activeIndex;
var wd = allwidth + 'px';
$('.ias-tpl-hm-section03-04 .ias-tpl-hm-tool .ias-tpl-pagination-bg').css('left', wd);
$('.as-tpl-hm-banner04').find('img').trigger('appear');
},
slideChangeTransitionEnd: function () {
gatabswiper(this);
},
},
});
if (screenwidth < 900) {
$('.ias-tpl-hm-section03 .swiper-pagination .swiper-pagination-bullet').text('');
}
$('.ias-tpl-tip1').on('click', function () {
var currentPosition = $(window).scrollTop();
var 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');
});
// 20250329
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()) {
$('.wechat-hide').hide();
$('.wechat-show').show();
} else {
$('.wechat-hide').show();
$('.wechat-show').hide();
}
// 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: 100, // 提前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');
$('.ias-tpl-hmkv-con .kv-title').removeClass('lazyload-txt');
$('.ias-tpl-hmkv .ias-tpl-play-icon').removeClass('lazyload-txt');
});
}
},
load: function () {
// 加载完成回调
$(this).addClass('lazy-loaded');
},
});
const scrollButton01 = document.getElementById('wen1');
const section1 = document.getElementById('da1');
scrollButton01.addEventListener('click', () => {
var aaa = $('#da1').offset().top;
console.log(aaa + 'dianji');
section1.scrollIntoView({ block: 'center', behavior: 'smooth' });
section1.classList.add('active');
section2.classList.remove('active');
section3.classList.remove('active');
});
const scrollButton2 = document.getElementById('wen2');
const section2 = document.getElementById('da2');
scrollButton2.addEventListener('click', () => {
section2.scrollIntoView({ block: 'center', behavior: 'smooth' });
section2.classList.add('active');
section1.classList.remove('active');
section3.classList.remove('active');
});
// const scrollButton3 = document.getElementById('wen3');
// const section3 = document.getElementById('da3');
// scrollButton3.addEventListener('click', () => {
// section3.scrollIntoView({ block: 'center', behavior: 'smooth' });
// section3.classList.add('active');
// section1.classList.remove('active');
// section2.classList.remove('active');
// });
});