Init(); function Init(e) { const w = document.body.offsetWidth; if (w > 980) { new WOW().init(); header() } else { $(".z_header").addClass("on") $(".z_menu_btn").click(function () { $(this).toggleClass("on") $(".z_header_mask").toggleClass("on") }) } z_wow() // 分享 $('.zShare').click(function () { var e = { type: $(this).data('type') } zShare(e); }); videoPop() lenisInit() index() about() 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(); } function header() { $('.z_header_nav li:not(:first-child)').hover(function () { $(".z_header,.z_menu_mask").addClass("on") }); $('.z_header_warp').hover(function () { }, function () { $(".z_header,.z_menu_mask").removeClass("on") }); $(window).scroll(function () { var s = $(document).scrollTop(); if ($(this).scrollTop() > 300) { $(".z_header").addClass("on2") // $(".z_menu_mask").css({ "opacity": 1 }) // $('.z_header_warp').hover(function () { }, function () { // $(".z_header").addClass("on") // $(".z_menu_mask").css({ "opacity": 1 }) // }); } else { $(".z_header").removeClass("on2") // $(".z_header").removeClass("on") // $(".z_menu_mask").css({ "opacity": 0 }) } }); } function public() { $(".z_dz_nav a").hover(function () { $(this).addClass("active").siblings().removeClass("active") $(".z_dz_con .itembox").eq($(this).index()).addClass("active").siblings().removeClass("active") }) if ($(".z_hz_swiper").length) { setSwiper(".z_hz_swiper", { gridfill: "rows", //网格排列方式 gridrows: 3, //网格行数 slidesPerView: 8, spaceBetween: 20, slidesPerGroup: 8, paginationEl: ".z_hz_dot", mobile: { slidesPerView: 3, spaceBetween: 10, } }) } if ($(".z_casexq_swiper").length) { setSwiper(".z_casexq_swiper", { slidesPerView: 1, spaceBetween: $(window).width() * 0.0338, nextEl: ".z_cases_btn .next", prevEl: ".z_cases_btn .prev", mobile: { slidesPerView: 1, spaceBetween: 10, } }) } } function index() { if ($(".z_index_page").length) { let w = $(window).width() setSwiper('.z_banner', { loop: true, effect: "fade", speed: 1000, paginationEl: ".bannernum", paginationType: "fraction", on: { slideChangeTransitionStart: function () { $(".z_banner .pages").addClass("on") }, slideChangeTransitionEnd: function () { $(".z_banner .pages").removeClass("on") }, } }); $(".z_ser_num .all").text("0" + $(".z_ser_swiper li").length) setSwiper(".z_ser_swiper ", { autoplay: false, slidesPerView: "auto", paginationType: "progressbar", on: { slideChangeTransitionStart: function () { $(".z_ser_num .index").text("0" + (this.activeIndex +1)) if($(window).width()>980){ if(this.activeIndex==2){ $(".z_ser_num .index").text("0" +$(".z_ser_swiper li").length) } } }, } }) let _chars = new SplitText(".z_map_text", { type: "chars" }).chars; console.log() $(".z_map_text div").each(function (i) { $(this).addClass("wow fadeInRight"); $(this).attr("data-wow-delay", +(i * 0.1) + "s"); }) $(".z_case_swiper").each(function(i){ setSwiper(".z_case_swiper"+i, { autoplay: false, paginationType: "progressbar", slidesPerView: 3, spaceBetween: $(window).width() * 0.036, mobile: { slidesPerView: 1, } }) }) $(".z_case_nav a").hover(function () { $(this).addClass("active").siblings().removeClass("active") $(".z_case_swiper").eq($(this).index()).addClass("active").siblings().removeClass("active") }) setSwiper(".z_news_swiper", { autoplay: false, slidesPerView: 2, spaceBetween: $(window).width() * 0.03, nextEl: ".z_index_news .next", prevEl: ".z_index_news .prev", mobile: { slidesPerView: 1, } }) if (w > 980) { if ($('.z_banner').length > 0) { $(window).scroll(function () { var s = $(this).scrollTop() / 3; $('.z_banner').css({ 'transform': 'translateY(' + -s + 'px)' }); }); } } } } function about() { if ($(".z_about_page").length) { let whswiper = setSwiper(".z_wh_swiper", { direction: 'vertical', autoplay: false, noSwiping: true, noSwipingClass: 'stop-swiping', }) $(".z_wh_li li").hover(function () { $(this).addClass("active").siblings().removeClass("active") whswiper.slideTo($(this).index(), 1000, false); }) $(".z_year_swiper .swiper-slide-next").next("li").css('justify-content', 'flex-start') // $(".z_year_swiper .swiper-slide-prev").prev().css('justify-content', 'flex-end') console.log($(".z_year_swiper .swiper-slide-next").next()) let w = $(window).width() if (w > 980) { var hview = 6, yview = 4 } else { var hview = 3, yview = 1 } var yswiper = new Swiper(".z_year_con", { spaceBetween: 10, noSwiping: true, noSwipingClass: 'stop-swiping', }); new Swiper(".mySwiper", { spaceBetween: 50, slidesPerView: yview, centeredSlides: true, speed: 0, loop: true, navigation: { nextEl: ".z_year_swiper .next", prevEl: ".z_year_swiper .prev", }, on: { slideChangeTransitionStart: function () { $(".z_year_swiper .swiper-slide-next").next().css('justify-content', 'flex-start') $(".z_year_swiper .swiper-slide-prev").prev().css('justify-content', 'flex-end') yswiper.slideTo(this.realIndex, 1000, false); }, } }); var swiper = new Swiper(".z_honor_small1", { observer: true, observeParents: true, observeSlideChildren: true, spaceBetween: 10, slidesPerView: hview, freeMode: true, watchSlidesProgress: true, }); var swiper2 = new Swiper(".z_honor_big1", { observer: true, observeParents: true, observeSlideChildren: true, speed: 1200, spaceBetween: 10, noSwiping: true, noSwipingClass: 'stop-swiping', navigation: { nextEl: ".z_honor_warp .next", prevEl: ".z_honor_warp .prev", }, thumbs: { swiper: swiper, }, }); var hswiper = new Swiper(".z_honor_small2", { observer: true, observeParents: true, observeSlideChildren: true, spaceBetween: 10, slidesPerView: hview, freeMode: true, watchSlidesProgress: true, }); var hswiper2 = new Swiper(".z_honor_big2", { observer: true, observeParents: true, observeSlideChildren: true, speed: 1200, spaceBetween: 10, noSwiping: true, noSwipingClass: 'stop-swiping', navigation: { nextEl: ".z_honor_warp .next", prevEl: ".z_honor_warp .prev", }, thumbs: { swiper: hswiper, }, }); $(".z_honor_nav li").click(function () { $(this).addClass("active").siblings().removeClass("active") $(".z_honor_warp").eq($(this).index()).addClass("active").siblings().removeClass("active") }) } } 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') if (_this.find("li").length > 0) { _this.find("li").each(function (i, e) { $(this).addClass("wow " + ani + ""); $(this).attr("data-wow-delay", +(i * 0.2) + "s"); }); } else { _this.find("a").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) { 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) { //返回顶部 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, resistanceRatio: 0, 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 } } return 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 }, }) } class App{ swiperJson={}; constructor(){ this.init(); } /** * 初始化 */ init(){ this.banners();//轮播 } /** * 再次封装swiper * @param {*} e * @returns */ swiperBanner(e={}){ let opt=$.extend({ boxCell:'.lh-banner', paginationEl:'.hd', paginationType:'bullets', paginationBulletElement:'li', paginationDynamicBullets:false, paginationDynamicMainBullets:1, paginationClickable:true, paginationRenderBullet:null, paginationBulletActiveClass:'on', stopOnLastSlide:true, slidesPerView:1, spaceBetween:0, speed:750, loop:false, direction:'horizontal', initialSlide:0, effect:'slide', mousewheel:false, nextEl:'.next', prevEl:'.prev', noSwipingClass:'stop-swiping', on:null, observer:true, observeParents:true, observeSlideChildren:true, parallax:true, disableOnInteraction:false, mainCell:'.swiper-wrapper', autoPage:true, autoPlay:false, delay:4500, stopOnLastSlide:false, disableOnInteraction:false, hashNavigation:false, slidesPerColumn:1, grabCursor:false, loopedSlides:1, freeMode:false, nested:false, scrollbar:'.swiper-scrollbar', stop:false, centeredSlides:false, releaseOnEdges:false, draggable:false, eventsTarged:'.i', loopAdditionalSlides:0 },e); if($(opt.boxCell).find('.next').length>0){ var nextEl = $(opt.boxCell).find('.next'),prevEl = $(opt.boxCell).find('.prev'); }else{ var nextEl =opt.nextEl,prevEl =opt.prevEl; } if(opt.autoPlay){ opt.autoPlay ={ delay:opt.delay, stopOnLastSlide:opt.stopOnLastSlide, disableOnInteraction:opt.disableOnInteraction } }else{ opt.autoPlay=false; } if(opt.mousewheel){ opt.mousewheel={eventsTarged:opt.eventsTarged}; if(opt.releaseOnEdges){ opt.mousewheel['releaseOnEdges']=opt.releaseOnEdges; } } let _swiper=new Swiper(opt.boxCell,{ parallax : opt.parallax, slidesPerView:opt.slidesPerView, initialSlide :opt.initialSlide, pagination : { el : opt.paginationEl, type:opt.paginationType, bulletElement:opt.paginationBulletElement, dynamicBullets:opt.paginationDynamicBullets, dynamicMainBullets:opt.paginationDynamicMainBullets, clickable:opt.paginationClickable, renderBullet:opt.paginationRenderBullet, bulletActiveClass:opt.paginationBulletActiveClass }, speed:opt.speed, loop:opt.loop, effect : opt.effect, spaceBetween:opt.spaceBetween, navigation: { nextEl: nextEl, prevEl: prevEl, }, direction:opt.direction, mousewheel:opt.mousewheel, noSwipingClass:opt.noSwipingClass, on:opt.on, observeParents:opt.observeParents, observer:opt.observer, autoplay:opt.autoPlay, stopOnLastSlide:opt.stopOnLastSlide, disableOnInteraction:opt.disableOnInteraction, hashNavigation:opt.hashNavigation, slidesPerColumn:opt.slidesPerColumn, grabCursor:opt.grabCursor, //loopedSlides:opt.loopedSlides, freeMode:opt.freeMode, nested:opt.nested, scrollbar:{ el:opt.scrollbar, draggable:opt.draggable }, lazy: { loadPrevNext: true, }, observeSlideChildren:opt.observeSlideChildren, centeredSlides:opt.centeredSlides, loopAdditionalSlides:opt.loopAdditionalSlides, touchAngle:25, threshold:50 }) if(opt.stop){ $(opt.boxCell).mouseenter(function () { _swiper.autoplay.stop(); }) $(opt.boxCell).mouseleave(function () { _swiper.autoplay.start(); }) } return _swiper; } /** * 获取窗口尺寸 */ get viewport(){ let width = $(window).innerWidth(); let height = $(window).innerHeight(); let aspectRatio = width / height; return { width, height, aspectRatio }; } /** * 循环banner开启轮播 */ banners(){ let that=this; this.bannersBefore(); $('.l-banner').each((i,v)=>{ let boxCell='.'+$(v)[0].className.split(' ')[0], length=$(v).find('.swiper-slide').length, view=$(v).attr('data-view')||1, webView=$(v).attr('data-webView')||1, loopAdditionalSlides=$(v).attr('data-loopAdditionalSlides')||0, autoplay=$(v).attr('data-autoplay')||false, delay=Number($(v).attr('data-delay'))||4500, speed=Number($(v).attr('data-speed'))||750, initialSlide=Number($(v).attr('data-initialSlide'))||0, paginationEl='', loop=$(v).attr('data-loop')||false, loopedSlides=$(v).attr('data-loopedSlides')||1, prev='', next='', direction=$(v).attr('data-direction')||'horizontal',//horizontal||vertical effect=$(v).attr('data-effect')||'slide', stop=$(v).attr('data-stop')||false, paginationType=$(v).attr('data-paginationType')||'bullets', centeredSlides=$(v).attr('data-centeredSlides')||false, mousewheel=$(v).attr('data-mousewheel')||false, hashNavigation=$(v).attr('data-hashNavigation')||false, freeMode=$(v).attr('data-freeMode')||false, draggable=$(v).attr('data-draggable')||false, releaseOnEdges=$(v).attr('data-releaseOnEdges')||false, noSwipingClass=$(v).attr('data-noSwipingClass')||'stop-swiping', //eventsTarged=$(v).data('eventsTarged')||'.index-banner', paginationRenderBullet=null; if(this.viewport.width<=1024){ view=webView; } if($(v).find('.bannerHd').length>0){ paginationEl = '.'+$(v).find('.bannerHd')[0].className.split(' ')[0]; $(v).find('.bannerHd').hide(); }else if($(v).closest('.bannerBox').find('.bannerHd').length>0){ paginationEl = '.'+$(v).closest('.bannerBox').find('.bannerHd')[0].className.split(' ')[0]; $(v).closest('.bannerBox').find('.bannerHd').hide(); } if($(v).find('.bannerBtn').length>0){ if($(v).find('.bannerBtn .prevs').length>0)prev = '.'+$(v).find('.bannerBtn .prevs')[0].className.split(' ')[0]; if($(v).find('.bannerBtn .nexts').length>0)next = '.'+$(v).find('.bannerBtn .nexts')[0].className.split(' ')[0]; $(v).find('.bannerBtn').hide(); }else if($(v).closest('.bannerBox').find('.bannerBtn').length>0){ if($(v).closest('.bannerBox').find('.bannerBtn .prevs').length>0)prev = '.'+$(v).closest('.bannerBox').find('.bannerBtn .prevs')[0].className.split(' ')[0]; if($(v).closest('.bannerBox').find('.bannerBtn .nexts').length>0)next = '.'+$(v).closest('.bannerBox').find('.bannerBtn .nexts')[0].className.split(' ')[0]; $(v).closest('.bannerBox').find('.bannerBtn').hide(); } if($(v).find('.bannerNum').length>0){ $(v).find('.bannerNum').hide(); }else if($(v).closest('.bannerBox').find('.bannerNum').length>0){ $(v).closest('.bannerBox').find('.bannerNum').hide(); } that.setBannerNum(v); if(length>view||(view=='auto'&&length>1)){ let _swiper=this.swiperBanner({ boxCell:boxCell, slidesPerView:view, autoPlay:autoplay?true:false, delay:delay, speed:speed, paginationEl:paginationEl, loop:loop?true:false, loopedSlides:loopedSlides, prevEl:prev, nextEl:next, effect:effect, direction:direction, stop:stop?true:false, noSwipingClass:noSwipingClass, paginationType:paginationType, centeredSlides:centeredSlides?true:false, mousewheel:mousewheel?true:false, hashNavigation:hashNavigation?true:false, freeMode:freeMode?true:false, draggable:draggable?true:false, releaseOnEdges:releaseOnEdges?true:false, paginationRenderBullet:paginationRenderBullet, initialSlide:initialSlide, loopAdditionalSlides:loopAdditionalSlides, on:{ slideChangeTransitionStart(){ let _index=this.realIndex; that.setBannerNum(this); } } }) if($(v).find('.bannerBtn').length>0){ $(v).find('.bannerBtn').show(); }else if($(v).closest('.bannerBox').find('.bannerBtn').length>0){ $(v).closest('.bannerBox').find('.bannerBtn').show(); } if($(v).find('.bannerHd').length>0){ $(v).find('.bannerHd').show(); }else if($(v).closest('.bannerBox').find('.bannerHd').length>0){ $(v).closest('.bannerBox').find('.bannerHd').show(); } if($(v).find('.bannerNum').length>0){ $(v).find('.bannerNum').show(); }else if($(v).closest('.bannerBox').find('.bannerNum').length>0){ $(v).closest('.bannerBox').find('.bannerNum').show(); } this.swiperJson[boxCell]=_swiper; } }); this.bannerAfter(); } /** * 轮播之前执行事件 */ bannersBefore(){ } /** * 轮播之后执行事件 */ bannerAfter(){ let that=this; } /** * 设置轮播数字 * @param {*} e */ setBannerNum(e){ if(e.$el !=undefined && e.$el){//设置current let _index=e.realIndex+1; let _this=e.$el; if($(_this).find('.bannerNum').length>0){ let _num=$(_this).find('.bannerNum'); if(_index<10){ _index='0'+_index; } _num.find('.current').text(_index); }else if($(_this).parents('.bannerBox').find('.bannerNum').length>0){ let _num=$(_this).parents('.bannerBox').find('.bannerNum'); if(_index<10){ _index='0'+_index; } _num.find('.current').text(_index);; } }else{//设置total let _total=$(e).find('.bd .swiper-slide').length, _class=$(e)[0].className.split(' ')[0]; /*单独设置total*/ if($(e).data('view')){ let _view=$(e).data('view')-1; _total=_total-_view; } if($(e).find('.bannerNum').length>0){ let _num=$(e).find('.bannerNum'); if(length<10){ _total='0'+_total; } _num.find('.total').text(_total); }else if($(e).parents('.bannerBox').find('.bannerNum').length>0){ let _num=$(e).parents('.bannerBox').find('.bannerNum'); if(_total<10){ _total='0'+_total; } _num.find('.total').text(_total); } } } } const _app=new App();