/* 鍔犺浇瀹屾垚鏃惰繍琛屼簨浠 */ window.onload = function () { //aos 鍒濆鍖 AOS.init({ offset: 120, duration: 400, easing: 'ease', delay: 100, once: false, disable: window.innerWidth < 1024 }); //鍒濆杩愯蹇呴』鍑芥暟 if (getBrowserEngine() === 'IE') { alert('璇蜂娇鐢ㄩ潪IE娴忚鍣ㄨ繘琛屾煡鐪?); } bodyAddPaddingTop(); headerFixed(); scrollToHashElement(); } /* 婊氬姩鏉¤Е鍙戜簨浠 */ window.onscroll = function () { headerFixed(); } /* 缁戝畾浜嬩欢 */ $(window).bind( 'hashchange', function(e){ scrollToHashElement(); }); // 瀵艰埅鏍忔敹缂 $('[data-toggle=collapse]').click(function(){ const collapsedClass = 'collapsed'; const targetElement = $(this).data('target'); const targetElementCurrent = 'show'; if($(this).hasClass(collapsedClass)){ $(this).removeClass(collapsedClass) $(targetElement).removeClass(targetElementCurrent) $(targetElement).slideUp() return } $(this).addClass(collapsedClass) $(targetElement).addClass(targetElementCurrent) $(targetElement).slideDown() }) // 杩斿洖椤堕儴 function backTop() { $("html,body").animate({ scrollTop: 0 }, 300); } //杩斿洖椤堕儴鎸夐挳鏄剧ず function backTopBtnShow(){ let backTopBtn = $('#backTop'); //jq selector if ($(window).scrollTop() > $(window).height()) { backTopBtn.addClass('active'); } else { backTopBtn.removeClass('active'); } } //椤甸潰婊氬姩鍒版寚瀹氬厓绱犱綅缃 function scrollToElement(element){ $('body,html').animate({ scrollTop: $(element).offset().top - parseInt($('body').css('padding-top')) }, 500); } //椤甸潰婊氬姩鍒伴敋鐐逛綅缃 function scrollToHashElement(){ let hash = window.location.hash; if(hash !== undefined && hash !== null && hash !== ''){ scrollToElement(hash+'Hash'); } } //澶撮儴鍥哄畾 function headerFixed() { let header = $('.header'); //jq selector const headerCurrent = 'active'; let pageBanner = $('.page-banner'); //jq selector if (pageBanner.length === 0) { if ($(window).scrollTop() > 200) { header.addClass(headerCurrent); } else { header.removeClass(headerCurrent); } } else { if ($(window).scrollTop() > pageBanner.outerHeight() - header.outerHeight()) { header.addClass(headerCurrent); } else { header.removeClass(headerCurrent); } } } //缁檅ody娣诲姞绛変簬header楂樺害鐨勯《閮ㄥ唴杈硅窛 function bodyAddPaddingTop() { let header = $('.header'); //jq selector let pageBanner = $('.page-banner'); //jq selector if (pageBanner.length === 0) { $('body').css('padding-top', header.outerHeight()); } else { header.addClass('transparent'); } } // 鑾峰彇娴忚鍣ㄥ唴鏍 function getBrowserEngine() { let userAgent = navigator.userAgent; if (userAgent.indexOf('Trident') !== -1 || userAgent.indexOf('MSIE') !== -1) { return 'IE'; } else if (userAgent.indexOf('Firefox') !== -1) { return "Firefox"; } else if (userAgent.indexOf('Chrome') !== -1) { return 'Chrome'; } else if (userAgent.indexOf('Safari') !== -1) { return 'Safari'; } else { return; } } //鍒ゆ柇鏄惁鏄Щ鍔ㄧ function isMobile() { let a = navigator.userAgent.toLowerCase(), b = a.match(/ipad/i) == "ipad", c = a.match(/iphone os/i) == "iphone os", d = a.match(/midp/i) == "midp", e = a.match(/rv:1.2.3.4/i) == "rv:1.2.3.4", f = a.match(/ucweb/i) == "ucweb", g = a.match(/android/i) == "android", h = a.match(/windows ce/i) == "windows ce", i = a.match(/windows mobile/i) == "windows mobile"; return b || c || d || e || f || g || h || i; } // 鎵撳紑绗笁鏂规矡閫氱獥鍙 function openCustomServiceWindow() { const serviceUrl = ''; if (isMobile()) { window.open(serviceUrl) } const iWidth = window.outerWidth * 0.6; //寮瑰嚭绐楀彛鐨勫搴 const iHeight = window.outerHeight * 0.75; //寮瑰嚭绐楀彛鐨勯珮搴 let iTop = (window.screen.availHeight - 30 - iHeight) / 2; //鑾峰緱绐楀彛鐨勫瀭鐩翠綅缃 let iLeft = (window.screen.availWidth - 10 - iWidth) / 2; //鑾峰緱绐楀彛鐨勬按骞充綅缃 window.open(serviceUrl, 'windowForCustomService', 'height=' + iHeight + ',innerHeight=' + iHeight + ',width=' + iWidth + ',innerWidth=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=0,titlebar=no'); }