$(function () {
const VIDEO_DESC =
'
视频创意,仅供参考,产品外观、功能界面、效果等请以实物为准。
'
$(document).on('click', '.js_video_player_tips', function () {
$('.vjs-big-play-centered').append(VIDEO_DESC)
})
$(document).on('click', '.close-video-popup', function () {
$('.video-tips').remove()
})
const SCREEN_WIDTH = $(window).width()
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 = 'AI 交互式星环散射体'
break
case 1:
text = 'AI 调音魔方'
break
case 2:
text = 'AI 环绕声场'
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)
},
slideChangeTransitionEnd: function () {
$('.player-outer-box').find('video').trigger('pause')
if (SCREEN_WIDTH > 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)
},
},
})
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
case 3:
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').width()
let allWidth = sliderWidth * this.activeIndex
let transitionWidth = allWidth + 'px'
$('.ias-tpl-hm-section03-02 .ias-tpl-hm-tool .ias-tpl-pagination-bg').css('left', transitionWidth)
$('.as-tpl-hm-banner02').find('img').trigger('appear')
},
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 = 'HAMOMO 哈蒙蒙'
break
case 1:
text = '影视空间'
break
case 2:
text = '无麦 K 歌 3.0'
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').width()
let allWidth = sliderWidth * this.activeIndex
let transitionWidth = allWidth + 'px'
$('.ias-tpl-hm-section03-03 .ias-tpl-hm-tool .ias-tpl-pagination-bg').css('left', transitionWidth)
$('.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 = '小艺智能体 - 车控'
break
case 3:
text = '语音控车'
break
case 4:
text = '新闻百科'
break
case 5:
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)
},
},
})
if (SCREEN_WIDTH < 900) {
$('.ias-tpl-hm-section03 .swiper-pagination .swiper-pagination-bullet').text('')
}
$('.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')
})
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()
}
let isUserInteracting = false
let hands = 'null'
var mySwiperKv = new Swiper('.ias-car-kvbanner', {
loop: true,
pagination: {
el: '.swiper-pagination-kv',
clickable: true,
},
navigation: {
nextEl: '.swiper-button-next-kv',
prevEl: '.swiper-button-prev-kv',
},
slidesPerView: 1,
speed: 500,
autoplay: {
delay: 8000,
disableOnInteraction: false,
},
spaceBetween: 4,
keyboard: true,
observer: true,
observeParents: true,
on: {
transitionStart: function (mySwiperKv) {
$('.ias-car-kvbanner').find('img').trigger('appear')
},
// 开始拖拽
// 监听触摸开始
touchStart: function () {
isUserInteracting = true
},
// 监听滑动结束
touchEnd: function () {
// 短暂延迟后重置状态,确保能捕获到切换事件
clearTimeout(hands)
hands = setTimeout(() => {
isUserInteracting = false
}, 1000)
},
slideChangeTransitionEnd: function () {
if (isUserInteracting) {
gakvswiper(this)
// 手动滑动后的处理逻辑
} else {
// 自动播放后的处理逻辑
}
},
},
})
$(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,
})
})
// 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-conctrol-kvtxt").removeClass("lazy-text")
$(".ias-tpl-play-icon").removeClass("lazy-text")
$('.ias-tpl-hmkv-con .kv-title').removeClass('lazyload-txt')
})
}
},
load: function () {
// 加载完成回调
$(this).addClass('lazy-loaded')
},
})
})