$(function () { var winw = $(window).width(); var winH = $(window).height(); var offAnimate = true; function init() { // 设置视频全屏居中显示 var winw = $(window).width(); var winh = $(window).height(); if (winw > 1200) { // 获取对象 var videoObj = $('.banner-pc .video video'); // pc端添加视频播放 videoObj.attr('src', videoObj.data('url')); // 视频长度 var video = { w: 1920, h: 842 } // 设置视频位置 if (winw / winh > video.w / video.h) { videoObj.css({ 'width': '100%', 'marginTop': -(winw / (video.w / video.h) - winh) / 2 }); } else { videoObj.css({ 'height': '100%', 'marginLeft': -((video.w / video.h) * winh - winw) / 2 }); } // ------------------------------------------------------ // 设置banner区域高度 var screenObj = $('.banner-pc .js-screen'); var screenLength = screenObj.length; var showH = 600; $('.banner-pc').height(screenLength * showH); $('.banner-pc .aboutBtn').on('click', function () { $('html,body').animate({ 'scrollTop': screenLength * showH + 100 }) }) // 默认显示当前位置的文字 screenObj.eq(Math.ceil($('html').scrollTop() / showH)).addClass('show').removeClass( 'bottom top'); // 设置文字随滚动条显示隐藏 // var defaultTop = 0; $(window).scroll(function () { var top = $('html').scrollTop(); if (!$('body').hasClass('position-fix')) { var index = Math.ceil(top / showH); for (var i = 0; i < screenLength; i++) { if (i < index) { screenObj.eq(i).addClass('top').removeClass('bottom'); $('.banner-pc .point ul li').eq(i).addClass('active').siblings() .removeClass('active'); } else { screenObj.eq(i).addClass('bottom').removeClass('top'); } } screenObj.eq(index).addClass('show').removeClass('bottom top').siblings() .removeClass( 'show'); } // defaultTop = top; }) // 点击最后一屏幕的back to top 按钮放回顶部 $('.banner-pc .text .text-five .text-tips').on('click', function () { $('html,body').animate({ 'scrollTop': 0 }) }) } else { // 头部导航条的高度 var headerH = 0; if (winw > 992) { headerH = $('.nav-new').height() + $('.layout-breadcrumb').height(); console.log(headerH) } else { headerH = $('.main-header').height(); } // 设置每个li个高度为100% $('.banner-wap > ul li').height(winh - headerH); // 获取对象 var imgObj = $('.banner-wap ul li .pic img'); // img长度 var imgSize = { ipadH: { w: 1024, h: 768 }, ipadV: { w: 768, h: 1024 }, wap: { w: 750, h: 1650 }, } // 设置视频位置 if (winw > 992) { if (winw / winh >= imgSize.ipadH.w / imgSize.ipadH.h) { imgObj.css({ 'width': '100%', 'marginTop': -(winw / (imgSize.ipadH.w / imgSize.ipadH.h) - winh) / 2 }); } else { imgObj.css({ 'height': '100%', 'marginLeft': -((imgSize.ipadH.w / imgSize.ipadH.h) * winh - winw) / 2 }); } } else if (winw < 992 && winw > 750) { if (winw / winh >= imgSize.ipadV.w / imgSize.ipadV.h) { imgObj.css({ 'width': '100%', 'marginTop': -(winw / (imgSize.ipadV.w / imgSize.ipadV.h) - winh) / 2 }); } else { imgObj.css({ 'height': '100%', 'marginLeft': -((imgSize.ipadV.w / imgSize.ipadV.h) * winh - winw) / 2 }); } } else { if (winw / winh >= imgSize.wap.w / imgSize.wap.h) { imgObj.css({ 'width': '100%', 'marginTop': -(winw / (imgSize.wap.w / imgSize.wap.h) - winh) / 2 }); } else { imgObj.css({ 'height': '100%', 'marginLeft': -((imgSize.wap.w / imgSize.wap.h) * winh - winw) / 2 }); } } //以下开始移动端触摸事件处理 if (window.addEventListener) { var obj = $('.banner-wap')[0]; var touch_startX = 0; //存放刚开始点击屏幕的X坐标 var touch_startY = 0; //存放刚开始点击屏幕的Y坐标 var touch_endX = 0; //存放点击移动结束X的坐标 var touch_endY = 0; //存放点击移动结束Y的坐标 var touch_distanceX = 0; //存放移动的横向距离 var touch_distanceY = 0; //存放移动的纵向距离 var gesture_Staus = 0; //判断手势状态0为初始,1位手势向上滑动,2为手势向下滑动 var nowScroll = 0; var sport_status = false; //动画状态,true=正在执行动画,false=当前无执行动画 var scrollScreen = 0; var oneTimeAnimation = false; obj.addEventListener('touchstart', function (event) { // 如果这个元素的位置内只有一个手指的话 if (event.targetTouches.length == 1) { event.stopPropagation(); var touch = event.targetTouches[0]; touch_startX = touch.clientX; touch_startY = touch.clientY; touch_endX = touch.clientX; touch_endY = touch.clientY; gesture_Staus = 0; nowScroll = $(window).scrollTop() } }, false); obj.addEventListener('touchmove', function (event) { // 如果这个元素的位置内只有一个手指的话 if (event.targetTouches.length == 1) { event.preventDefault(); var touch = event.targetTouches[0]; touch_endX = touch.clientX; touch_endY = touch.clientY; touch_distanceX = touch_endX - touch_startX; touch_distanceY = touch_endY - touch_startY; switch (gesture_Staus) { case 0: if (Math.abs(touch_distanceY) > Math.abs(touch_distanceX) * 1.5) { if (touch_distanceY > 10) { gesture_Staus = 2; } else if (touch_distanceY < -10) { gesture_Staus = 1; } } break; case 1: $("html,body").scrollTop(nowScroll - touch_distanceY); break; case 2: $("html,body").scrollTop(nowScroll - touch_distanceY); break; } } }, false); obj.addEventListener('touchend', function (event) { touch_distanceX = touch_endX - touch_startX; if (!sport_status) { sport_status = true; var scrollTop = $(window).scrollTop(); if (gesture_Staus == 1) { scrollScreen++; } else if (gesture_Staus == 2) { if (scrollScreen != 0) { scrollScreen--; } } $("html,body").animate({ "scrollTop": (winh - headerH) * scrollScreen }, function () { sport_status = false; if (scrollScreen == 5) { oneTimeAnimation = true; } $('.banner-wap .point ul li').eq(scrollScreen).addClass( 'active').siblings() .removeClass('active'); }); gesture_Staus = 0 } }, false); // 判断滚动条位置 var activeScrollTopNum = 0; $(window).scroll(function () { var scrollTop = $(window).scrollTop(); var fuorScreen = (winh - headerH) * 5 + headerH; if (oneTimeAnimation && scrollTop < activeScrollTopNum && scrollTop < fuorScreen) { oneTimeAnimation = false; scrollScreen--; var num = (winh - headerH) * scrollScreen; $("html,body").css('overflow', 'hidden') $("html,body").animate({ "scrollTop": num }, function () { sport_status = false; $("html,body").css('overflow', 'auto') }); } activeScrollTopNum = scrollTop; }) $('.banner-wap ul li:nth-child(1) .tips').on('click', function () { $('html,body').animate({ 'scrollTop': (winh - headerH) * 5 }, function () { // scrollScreen = 0; }) }) // 点击最后一屏幕的back to top 按钮放回顶部 $('.banner-wap ul li:nth-child(5) .tips').on('click', function () { $('html,body').animate({ 'scrollTop': 0 }, function () { scrollScreen = 0; }) }) } } } init(); $(window).on('resize', function () { init(); }) if ($('.e-module-202212280923').length > 0) { $('.e-module-202212280923').each(function () { if (winw < 920) { $(this).find('.e-btn-bd-white-xl').addClass('e-btn-bd-red-xl').removeClass('e-btn-bd-white-xl'); // $(this).find('.e-btn-bd-white-video-xl').addClass('e-btn-bd-black-video-xl').removeClass('e-btn-bd-white-video-xl'); // $(this).find('.e-btn-bd-red-xl').addClass('e-btn-bd-black-xl').removeClass('e-btn-bd-red-xl'); // $(this).find('.e-btn-bd-red-video-xl').addClass('e-btn-bd-black-video-xl').removeClass('e-btn-bd-red-video-xl'); } }) } $(window).on('scroll.e-module-202212281009', function () { if (offAnimate) { var scrollTop = $(window).scrollTop(); var boxTop = $('.e-module-202212281009').offset().top; if (scrollTop > boxTop - winH / 2) { offAnimate = false; $('.e-module-202212281009 ul li').each(function () { var numSpan = $(this).find('.num span'); var numem = $(this).find('.num span em'); var curNNumSpanText = numSpan.text(); var circle = $(this).find('.circle'); var circleLeft = $(this).find('.circle-left'); var circleRight = $(this).find('.circle-right'); var percent = numSpan.text() * 360 / 100; var transitionRotate = 0; var loop = setInterval(function () { if (percent) { if (transitionRotate < percent) { if (transitionRotate < 180) { circleLeft.css('transform', 'rotate(' + transitionRotate + 'deg)'); numSpan.text((transitionRotate / 360 * 100) .toFixed(1) + '%'); } else { circleRight.css('display', 'block'); circle.addClass('auto'); circleRight.css('transform', 'rotate(' + ( transitionRotate - 180) + 'deg)'); numSpan.text((transitionRotate / 360 * 100) .toFixed(1) + '%'); } transitionRotate += 1; } else { numSpan.text(curNNumSpanText + '%'); clearInterval(loop); } } }, 1) }) } } }) if ($('.e-module-202212281603').length > 0) { $('.e-module-202212281603').each(function () { var _this = $(this); var winW = $(window).width(); // 每次滚动的数量 var slidesPerGroup = 1; if (winW > 1200) { slidesPerGroup = 4; } else { slidesPerGroup = 2; } // 初始化con 轮播器功能 swiperList(_this); function swiperList(objConList) { // 判断当前下面con是否是否有轮播,数量是否超过1个 if (objConList.find('.swiper-slide').length > 1) { // 防止swiper重复调用。判断objConList.data('init')是否已经存在 if (objConList.data('init') == undefined) { // 第一次调用swiper后,禁止再次调用 objConList.data('init', 'true'); var slideLength = objConList.find(".swiper-slide").length; var mySwiper = new Swiper(objConList.find(".swiper"), { slidesPerView: 2, spaceBetween: 20, resistanceRatiao: 1, //触底不反弹 watchOverflow: true, //一屏显示左右按钮和pag centeredSlides: false, slidesPerGroup: slidesPerGroup, pagination: { el: objConList.find('.swiper-pagination'), clickable: true, }, autoplay: objConList.data("auto-time") ? { delay: objConList.data("auto-time"), stopOnLastSlide: false, disableOnInteraction: true } : false, loop: slideLength > 1 ? true : false, // 设置自动轮播 noSwiping: slideLength > 1 ? false : true, navigation: { nextEl: objConList.find('.icon-right'), prevEl: objConList.find('.icon-left') }, breakpoints: { 992: { slidesPerView: 4, spaceBetween: 40, }, }, on: { init: function () { if (slideLength > 1) { objConList.find(".swiper-slide").each(function () { var imgObj = $(this).find(".swiper-con .e-lazy img"); imgObj.attr("src", imgObj.data("original")); }) } }, } }); // 鼠标覆盖停止自动切换 mySwiper.el.onmouseover = function () { mySwiper.autoplay.stop(); } //鼠标离开开始自动切换 mySwiper.el.onmouseout = function () { mySwiper.autoplay.start(); } } } else { objConList.find('.swiper-pagination').css({ 'display': 'none' }); objConList.find('.swiper-btn').css({ 'display': 'none' }); } } }) } if (winw < 992) { var itemList = $('.item-list') $('.item-list li').eq(0).addClass('active').siblings().addClass('setH') $('body').on('mouseup', function (e) { if (!itemList.is(e.target) && itemList.has(e.target).length == 0) { $('.item-list li').removeClass('active') $('.item-list li').removeClass('setH') } else { $('.item-list li').on('click', function (event) { $(this).addClass('active').siblings().removeClass('active'); $(this).removeClass('setH').siblings().addClass('setH') }) } }) } if ($('.cooperate').length > 0) { $('.cooperate').each(function () { var _this = $(this); var winW = $(window).width(); // 每次滚动的数量 var slidesPerGroup = 1; if (winW > 992) { slidesPerGroup = 4; } else { slidesPerGroup = 2; } // 初始化con 轮播器功能 swiperList(_this); function swiperList(objConList) { // 判断当前下面con是否是否有轮播,数量是否超过1个 if (objConList.find('.swiper-slide').length > 1) { // 防止swiper重复调用。判断objConList.data('init')是否已经存在 if (objConList.data('init') == undefined) { // 第一次调用swiper后,禁止再次调用 objConList.data('init', 'true'); var slideLength = objConList.find(".swiper-slide").length; var mySwiper = new Swiper(objConList.find(".swiper"), { slidesPerView: 2, // spaceBetween: 20, resistanceRatiao: 1, //触底不反弹 watchOverflow: true, //一屏显示左右按钮和pag centeredSlides: false, slidesPerGroup: slidesPerGroup, autoplay: objConList.data("auto-time") ? { delay: objConList.data("auto-time"), stopOnLastSlide: false, disableOnInteraction: true } : false, loop: slideLength > 1 ? true : false, // 设置自动轮播 noSwiping: slideLength > 1 ? false : true, pagination: { el: objConList.find('.swiper-pagination'), clickable: true, }, navigation: { nextEl: objConList.find('.icon-right'), prevEl: objConList.find('.icon-left') }, breakpoints: { 992: { slidesPerView: 4, // spaceBetween: 40, }, }, on: { init: function () { if (slideLength > 1) { objConList.find(".swiper-slide").each(function () { var imgObj = $(this).find(".sw-con .e-lazy img"); imgObj.attr("src", imgObj.data("original")); }) } }, } }); //鼠标覆盖停止自动切换 mySwiper.el.onmouseover = function () { mySwiper.autoplay.stop(); } //鼠标离开开始自动切换 mySwiper.el.onmouseout = function () { mySwiper.autoplay.start(); } } } else { objConList.find('.swiper-pagination').css({ 'display': 'none' }); objConList.find('.swiper-btn').css({ 'display': 'none' }); } } }) } })