// 婊氬姩鍒版寚瀹氫綅缃?--begin function getScrollTop() { return (document.scrollingElement && document.scrollingElement.scrollTop) || document.documentElement.scrollTop || document.body.scrollTop; } function setScrollTop(st) { if (!st) st = 0; document.documentElement.scrollTop = document.body.scrollTop = st; } function scrollTop(scrollTop, time) { scrollTop = scrollTop ? scrollTop : 0; time = time ? time : 500; const cubic = function (value) { return Math.pow(value, 3) }; const easeInOutCubic = function (value) { return value < 0.5 ? cubic(value * 2) / 2 : 1 - cubic((1 - value) * 2) / 2 } const beginTime = Date.now(); const beginValue = getScrollTop(); const rAF = window.requestAnimationFrame || (function (func) { return setTimeout(func, 16) }); const frameFunc = function () { if (isNaN(+time) || +time === 0) { setScrollTop(scrollTop); return; } const progress = (Date.now() - beginTime) / time; if (progress < 1) { setScrollTop( scrollTop + (beginValue - scrollTop) * (1 - easeInOutCubic(progress)) ); rAF(frameFunc); } else { setScrollTop(scrollTop); } }; rAF(frameFunc); }; /** 鑾峰彇鎸囧畾鍏冪礌璺濈椤甸潰椤堕儴璺濈 */ function getElementToPageTop(el) { if(el.parentElement) { return getElementToPageTop(el.parentElement) + el.offsetTop } return el.offsetTop } /** 鑾峰彇鎸囧畾鍏冪礌楂樺害 */ function getElementHeight(el) { return el.clientHeight; } function playFirstVideo() { var videoContain = $($('.index-top-banner .swiper-slide')[0]); var curVideo = videoContain.find('video'); if (curVideo.length) { curVideo.trigger('play'); } } // 婊氬姩鍒版寚瀹氫綅缃?--end // 棣栭〉锛屾粴鍔ㄥ埌鍒扳€滄垜浠兘鍋氫粈涔堟椂鍔ㄧ敾鈥 $(function(){ var ua = navigator.userAgent; var ipad = ua.match(/(iPad).*OS\s([\d_]+)/), isIphone =!ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/), isAndroid = ua.match(/(Android)\s+([\d.]+)/), isMobile = isIphone || isAndroid; if(isMobile){ window.location.replace('/cn/m/'); } try { var navHeight = getElementHeight(document.getElementsByClassName('top-nav')[0]); var top = getElementToPageTop(document.getElementById('weAre')); $('.arrow-down').click(function() { scrollTop(top - navHeight, 500); }); } catch (error) { console.log(error) } //try { // var myIndexTopSwiper = new Swiper('.index-top-banner.swiper-container', { // autoplay: 5000, // autoplayDisableOnInteraction : false, // pagination: '.index-top-banner .swiper-pagination', // nextButton: '.index-top-banner .swiper-button-next', // prevButton: '.index-top-banner .swiper-button-prev', // resize: function() { // //绐楀彛鍙樺寲浜 // myIndexTopSwiper.updateSize(); // }, // onInit: function(swiper){ // //playFirstVideo(); // }, // onSlideChangeEnd: function (swiper){ // var videoContain = $($('.index-top-banner .swiper-slide')[this.activeIndex]); // var curVideo = videoContain.find('video'); // if (curVideo.length) { // curVideo.trigger('play'); // } // //var otherVideo = videoContain.siblings().find('video'); // //for (var i = 0; i < otherVideo.length; i++) { // // if (!!window.ActiveXObject || "ActiveXObject" in window) { // // return false; // // } else { // // otherVideo[i].currentTime = 0; // // otherVideo.trigger('pause'); // // } // //} // } // }); //} catch (error) { // console.log(error) //} //try { // function controlVideo() { // var videoContain = $($('.index-top-banner .swiper-slide')[0]); // var videos = videoContain.find('video'); // if (videos.length > 0) { // myIndexTopSwiper.stopAutoplay(); // videos[0].onended = function(){ // myIndexTopSwiper.startAutoplay(); // setTimeout(() => { // myIndexTopSwiper.slideNext() // }, 300); // } // } else { // myIndexTopSwiper.startAutoplay(); // } // } // controlVideo(); //} catch (error) { // console.log(error) //} });