Init();
function Init(e) {
const w = document.body.offsetWidth;
if (w > 980) {
new WOW().init();
} else {
$(".z_menu_btn").click(function () {
$(this).toggleClass("on")
$(".z_header_mask").toggleClass("on")
})
}
z_wow()
videoPop()
lenisInit()
if($(".z_load_page").length>0){
load()
}
index()
public()
if ($('.timer').length > 0) {
$('.timer').countUp();
}
}
//初始化lenis
function lenisInit() {
let lenis;
const initSmoothScrolling = () => {
lenis = new Lenis({});
lenis.on('scroll', (e) => {
ScrollTrigger.update();
});
const scrollFn = (time) => {
lenis.raf(time);
requestAnimationFrame(scrollFn);
};
requestAnimationFrame(scrollFn);
};
initSmoothScrolling();
$(".lenisTop").click(function () {
lenis.scrollTo(0)
})
}
function public() {
$('.zShare').click(function () {
var e = {
type: $(this).data('type')
}
zShare(e);
});
let w = $(window).width()
$(window).scroll(function () {
if ($(window).scrollTop() >= 300) {
$('.z_header').addClass('on');
} else {
$('.z_header').removeClass('on');
}
});
$(".z_header_nav li>a").hover(function () {
$(".z_header_nav li").removeClass("on")
$(this).parent('li').addClass("on")
$(this).siblings(".downwarp").hover(function () {
}, function () {
$(this).parents('li').removeClass("on")
})
})
$(".z_header_nav").hover(function () {
}, function () {
$(this).find('li').removeClass("on")
})
if ($(".history_swiper").length) {
// 历程
let history = setSwiper(".history_swiper", {
autoplay: false,
effect: "fade"
});
$(".tabnavwarp li").each(function (i) {
if ($(this).hasClass("active")) {
$(this).parents(".itembox").addClass("active")
}
$(".tabnavwarp li").eq(i).click(function () {
$(".tabnavwarp li").removeClass("active")
$(".tabnavwarp li").eq(i).addClass("active")
$(".itembox").removeClass("active")
$(".tabnavwarp li").eq(i).parents(".itembox").addClass("active")
history.slideTo(i, 1000, false)
})
})
}
if ($(".z_news_swiper").length) {
setSwiper(".z_news_swiper", {
slidesPerView: 3,
spaceBetween: w * 0.043,
mobile: {
slidesPerView: 1,
}
});
}
if ($(".z_story_swiper").length) {
if (w > 980) {
new Swiper('.z_story_swiper', {
effect: 'coverflow',
slidesPerView: 4,
spaceBetween:30,
speed: 1500,
coverflowEffect: {
rotate: 15,
stretch: 0,
depth:30,
modifier:3 ,
slideShadows: true
},
navigation: {
nextEl: ".z_story_btn .next",
prevEl: ".z_story_btn .prev",
},
})
} else {
new Swiper('.z_story_swiper', {
spaceBetween: 10,
speed: 1500,
navigation: {
nextEl: ".z_story_btn .next",
prevEl: ".z_story_btn .prev",
},
})
}
if ($(".z_story_tab").length) {
$(".z_story_swiper").eq(0).show()
setSwiper('.z_story_class', {
speed: 1000,
autoplay: false,
direction: "vertical",
on: {
slideChangeTransitionStart: function () {
$(".z_story_swiper").eq(this.activeIndex).show().siblings().hide()
}
}
})
}
}
$(".z_index_tit").each(function () {
$(this).addClass("wow")
})
if ($(".z_video_banner").length > 0) {
setSwiper('.z_video_banner', {
loop: true,
speed: 1500,
autoplay: false,
effect: 'fade',
})
}
}
function index() {
// load()
// banner
let w = $(window).width()
if ($(".z_index_page").length) {
setSwiper('.z_video_banner', {
loop: true,
speed: 1500,
effect: 'fade',
autoplay: false,
on: {
slideChangeTransitionStart: function () {
// let _chars = new SplitText(".z_banner .en", { type: "chars" }).chars;
// let _chars2 = new SplitText(".z_banner .cn", { type: "chars" }).chars;
// gsap.from(_chars, {
// ease: 'power1.inOut',
// opacity: 0,
// xPercent: () => gsap.utils.random(-200, 200),
// yPercent: () => gsap.utils.random(-150, 150),
// stagger: { each: 0.01, grid: 'auto', from: 'random' },
// delay: 0.45
// });
// gsap.from(_chars2, {
// ease: 'power1.inOut',
// opacity: 0,
// scale: 0.6,
// 'will-change': 'opacity, transform',
// rotationZ: () => gsap.utils.random(-20, 20),
// stagger: 0.1,
// });
// gsap.from(".z_banner .ico", {
// rotation: 360,
// duration: 3,
// yoyo: true,
// repeat: -1
// })
},
}
});
setSwiper(".pro_swiper1", {
loop: true,
nextEl: ".z_index_pro .next",
noSwiping: true,
noSwipingClass: 'stop-swiping',
autoplay: false
});
setSwiper(".pro_swiper2", {
loop: true,
nextEl: ".z_index_pro .next",
noSwiping: true,
noSwipingClass: 'stop-swiping',
autoplay: false,
initialSlide:1
});
$(".z_whole_worlds .item").eq(1).addClass("on")
$(".z_whole_worlds .item").eq(1).find(".conbox").slideDown(500)
$(".z_whole_worlds .item").click(function () {
$(this).addClass("on").siblings().removeClass("on")
$(this).find(".conbox").slideDown(500)
$(this).siblings().find(".conbox").slideUp(500)
})
new SplitText(".z_global", { type: "chars" }).chars;
$(".z_global div").each(function (i, e) {
$(this).addClass("wow fadeInRight2");
$(this).attr("data-wow-delay", +(i * 0.2) + "s");
});
}
}
// 加载页
function load() {
var num = 0;
var id = setInterval(frame, 30);
function frame() {
if (num >= 100) {
clearInterval(id);
} else {
num++;
$(".z_load_page .num").text(num)
}
}
setTimeout(function () {
$(".z_load_page").addClass("close")
}, 4500)
let _chars = new SplitText(".textwarp .en", { type: "chars" }).chars;
let _chars2 = new SplitText(".textwarp .cn", { type: "chars" }).chars;
gsap.from(_chars, {
'will-change': 'opacity, transform',
opacity: 0,
duration: 1,
xPercent: () => gsap.utils.random(-200, 200),
yPercent: () => gsap.utils.random(100, -100)
});
gsap.from(_chars2, {
ease: 'power1.inOut',
opacity: 0,
scale: 0.6,
'will-change': 'opacity, transform',
rotationZ: () => gsap.utils.random(-20, 20),
stagger: 0.1,
});
const blobs = document.querySelectorAll(".limg");
const randomBorderRadius = () => {
return `${Math.floor(Math.random() * 60) + 60}% ${Math.floor(Math.random() * 60) + 40
}% ${Math.floor(Math.random() * 60) + 40}% ${Math.floor(Math.random() * 60) + 40
}% / ${Math.floor(Math.random() * 60) + 40}% ${Math.floor(Math.random() * 60) + 40
}% ${Math.floor(Math.random() * 60) + 40}% ${Math.floor(Math.random() * 60) + 40
}%`;
};
Array.from(blobs).forEach((c) =>
setInterval(() => {
c.style.borderRadius = randomBorderRadius();
c.style.setProperty("--b-before", randomBorderRadius());
c.style.setProperty("--b-after", randomBorderRadius());
}, 500)
);
const lis = document.querySelectorAll(".z_load_page li");
gsap.to(lis, {
duration: 6,
yPercent: () => gsap.utils.random(50, -50),
xPercent: () => gsap.utils.random(-50, 50),
scale: 1.1,
repeat: -1,
yoyo: true,
});
}
function gsapText(charsText) {
let _chars = new SplitText(charsText, { type: "chars" }).chars;
gsap.from(_chars, {
ease: 'power1.inOut',
opacity: 0,
scale: 0.6,
'will-change': 'opacity, transform',
rotationZ: () => gsap.utils.random(-20, 20),
stagger: 0.1,
scrollTrigger: {
trigger: charsText,
star: 'top center',
end: () => $(window).height(),
scrub: true,
}
});
}
// 动画
function z_wow() {
if ($(".z_wow").length > 0) {
$(".z_wow").each(function () {
var _this = $(this);
var ani = _this.attr('data-ani')
_this.find("li").each(function (i, e) {
$(this).addClass("wow " + ani + "");
$(this).attr("data-wow-delay", +(i * 0.2) + "s");
});
})
}
}
// 视频弹窗
function videoPop() {
const el = $('.z_play')
el.on('click', function () {
console.log($(this).attr("data-src"))
const html = `
`
$('body').append(html);
var vdo = document.getElementById("videopop")
vdo.play()
$(".z_video_pop .close_btn").on('click', function () {
vdo.pause()
$(".z_video_pop").remove()
})
})
}
// tab切换
function tab() {
if ($(".ztab").length > 0) {
$(".ztab").each(function () {
var _this = $(this)
if (_this.data('type')) {
_this.find('.z_tab_nav li').hover(function () {
var _index = $(this).index();
$(this).addClass('active').siblings().removeClass('active');
$(this).parents(".ztab").find(".z_tab_child").eq(_index).addClass(
'active')
$(this).parents(".ztab").find(".z_tab_child").eq(_index).siblings()
.removeClass('active')
});
} else {
_this.find('.z_tab_nav li').click(function () {
var _index = $(this).index();
$(this).addClass('active').siblings().removeClass('active');
$(this).parents(".ztab").find(".z_tab_child").eq(_index).addClass(
'active')
$(this).parents(".ztab").find(".z_tab_child").eq(_index).siblings()
.removeClass('active')
});
}
})
}
}
//分享
function zShare(e) {
console.log(e)
if (e.type == 'xinlang') {
window.open('https://service.weibo.com/share/share.php?title=' + encodeURIComponent(document
.title) +
'&url=' +
encodeURIComponent(location.href) + '&source=bookmark', '_blank', 'width=450,height=400');
}
if (e.type == 'weixin') {
if ($('#zCode').length > 0) {
return false;
}
var html =
'';
$('body').append(html);
$('#zCode>.ewm').qrcode(location.href);
$('#zCode>h2>i').click(function () {
$('#zCode').remove();
});
}
if (e.type == 'kongjian') {
window.open('https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + encodeURIComponent(
location.href) +
'&pics=&summary=' + encodeURIComponent(document.title), '_blank', 'width=450,height=400');
}
if (e.type == 'qqhy') {
window.open('https://connect.qq.com/widget/shareqq/index.html?url=' + encodeURIComponent(location
.href) + '&desc=' +
encodeURIComponent(document.title) + '&pics=&site=', '_blank',
'width=816,height=666,left=40,top=80');
}
}
// 分享
// function zShare($el) {
// const el = $('.zShare');
// el.on('click', (e) => {
// const es = $(e.target).attr("data-type")
// if (es == 'xinlang') {
// window.open('https://service.weibo.com/share/share.php?title=' + encodeURIComponent(document
// .title) +
// '&url=' +
// encodeURIComponent(location.href) + '&source=bookmark', '_blank', 'width=450,height=400');
// }
// if (es == 'weixin') {
// if ($('#zCode').length > 0) {
// return false;
// }
// var html =
// '';
// $('body').append(html);
// $('#zCode>.ewm').qrcode(location.href);
// $('#zCode>h2>i').click(function () {
// $('#zCode').remove();
// });
// }
// if (es == 'kongjian') {
// window.open('https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + encodeURIComponent(
// location.href) +
// '&pics=&summary=' + encodeURIComponent(document.title), '_blank', 'width=450,height=400');
// }
// if (es == 'qqhy') {
// window.open('https://connect.qq.com/widget/shareqq/index.html?url=' + encodeURIComponent(location
// .href) + '&desc=' +
// encodeURIComponent(document.title) + '&pics=&site=', '_blank',
// 'width=816,height=666,left=40,top=80');
// }
// })
// }
//返回顶部
function returnTop(e) {
$(document).on('click', '.z_retop', function () {
$('body,html').animate({
scrollTop: '0px'
}, 1000);
});
}
//鼠标跟随
function cursorFollow(e) {
var i = $('a,button,input,label,textarea,.Cursor');
i.on("mouseenter", function () {
TweenMax.to($('.lh-cursor i'), 0, {
width: "50px",
height: "50px",
ease: "none",
duration: 0
});
});
i.on("mouseleave", function () {
TweenMax.to($('.lh-cursor i'), 0, {
width: "20px",
height: "20px",
ease: "none",
duration: 0
});
});
$(document).on('mousemove', function (e) {
var clientX = e.clientX,
clientY = e.clientY;
var scrollLeft = $(this).scrollLeft(),
scrollTop = $(this).scrollTop();
var left = clientX + scrollLeft,
top = clientY + scrollTop;
TweenMax.to($('.lh-cursor'), .5, {
x: left,
y: top,
ease: "none",
duration: 0
});
})
}
// 图片视图差
function imgscroll() {
jQuery(document).ready(function () {
var fwindow = $(window);
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
var contents = [];
var backgrounds = [];
$('[data-type="content"]').each(function (index, e) {
var contentObj = $(this);
contentObj.__speed = (contentObj.data('speed') || 1);
contentObj.__fgOffset = contentObj.offset().top;
contents.push(contentObj);
});
$('[data-type="background"]').each(function () {
var backgroundObj = $(this);
backgroundObj.__speed = (backgroundObj.data('speed') || 1);
backgroundObj.__fgOffset = backgroundObj.offset().top;
backgrounds.push(backgroundObj);
});
fwindow.on('scroll', function () {
if ($(window).width() < 768) {
return;
}
scrollTop = window.pageYOffset || document.documentElement.scrollTop;
contents.forEach(function (contentObj) {
var yPos = contentObj.__fgOffset - scrollTop / contentObj.__speed;
contentObj.css('top', yPos);
})
backgrounds.forEach(function (backgroundObj) {
var yPos = -((scrollTop - backgroundObj.__fgOffset) / backgroundObj
.__speed);
backgroundObj.css({
backgroundPosition: '50% ' + yPos + 'px'
});
});
});
fwindow.trigger('scroll');
});
}
// swiper
function setSwiper(boxEl, params) {
let a = params || {};
boxEl = boxEl || '.swiper';
let opt = {
direction: 'horizontal',
speed: 1500,
delay: 4000,
loop: false,
autoplay: true,
effect: "slide",
observer: true,
observeParents: true,
observeSlideChildren: true,
stopOnLastSlide: false,
disableOnInteraction: false,
normalizeSlideIndex: false,
slideToClickedSlide: false,
paginationType: 'bullets',
prevEl: `${boxEl} .prev`,
nextEl: `${boxEl} .next`,
snapOnRelease: true,
noSwipingClass: 'stop',
mousewheel: false,
parallax: true,
gridfill: "", //网格排列方式
gridrows: 0, //网格行数
on: {}
}
opt = {
...opt,
...a
}
if (opt.autoplay) {
opt.autoplay = {
delay: opt.delay,
stopOnLastSlide: opt.stopOnLastSlide,
disableOnInteraction: opt.disableOnInteraction
}
}
if ($(window).width() < 980) {
opt = {
...opt,
...opt.mobile
}
}
var swiper = new Swiper(boxEl, {
pagination: {
el: opt.paginationEl || `${boxEl} .swiper-dot`,
type: opt.paginationType,
bulletElement: opt.paginationBulletElement || 'span',
dynamicBullets: opt.paginationDynamicBullets ? true : false,
dynamicMainBullets: opt.paginationDynamicMainBullets || 1,
clickable: opt.paginationClickable || true,
renderBullet: opt.paginationRenderBullet || null,
renderFraction: opt.paginationRenderFraction || null,
renderCustom: opt.paginationRenderCustom || null,
bulletClass: opt.paginationBulletClass || 'bullet',
bulletActiveClass: opt.paginationBulletActiveClass || 'on',
parallax: opt.parallax,
...opt.pagination,
},
effect: opt.effect,
delay: opt.delay,
grid: {
fill: opt.gridfill || null,
rows: opt.gridrows || null,
},
navigation: {
nextEl: opt.nextEl,
prevEl: opt.prevEl,
disabledClass: 'disabled',
hiddenClass: 'hide'
},
// scrollbar: {
// el: opt.scrollbarEl || `${boxEl} .scrollbar`,
// draggable: true,
// dragSize: opt.dragSize,
// snapOnRelease: opt.snapOnRelease
// },
...opt,
on: {
...opt.on
},
})
if (boxEl == ".z_video_banner") {
let timer = null;
function videoslidechange() {
const videos = swiper.el.querySelectorAll('video');
const video = () => swiper.slides[swiper.activeIndex].querySelector('video');
clearTimeout(timer);
if (video()) {
video().play();
video().addEventListener('ended', () => {
swiper.slideNext();
console.log("jieshu")
});
} else {
videos.forEach((e) => {
e.pause();
e.currentTime = 0;
});
timer = setTimeout(() => {
swiper.slideNext();
}, opt.delay || 4000);
}
}
videoslidechange();
swiper.on('slideChange', videoslidechange);
}
return swiper;
}