// 涓昏閫昏緫 $(function () { $('.navs>ul>li').on('click', function () { if (!$(this).hasClass('active')) { $('.navs>ul>li').removeClass('active') $(this).addClass('active') } }) // 1.鍖呭惈鑿滃崟鐨刲i琚Е鍙 // init $('.navs .menu .scroll').width($('.navs .menu .scroll .plate').length * $('.navs .menu').width()) // 鑾峰彇灞忓箷鍙瀹藉害 let clientWidth = document.body.clientWidth // 涓嬫媺鑿滃崟璁剧疆瀹藉害 $('.plate').width(clientWidth + 'px') // 寤舵椂瀹氭椂鍣 let t_delay = null let delay_interval = 300 $('.navs>.main-content>ul>li.hasmenu').on('mouseenter', function () { if (t_delay) { clearTimeout(t_delay) } let index = $('.navs>.main-content>ul>li.hasmenu').index($(this)) let long = $('.navs .menu').width() // 鍒囨崲鐗堝潡 $('.navs .menu .scroll').animate({ left: -index * long + 'px' }, 300) if (!$('.navs .menu-container').hasClass('open')) { $('.navs .menu-container').addClass('open') } if (!$('.navs .menu-bg').hasClass('open')) { $('.navs .menu-bg').addClass('open') } // 鍏朵粬妯″潡棰滆壊杩樺師 clearHoverColorForNav() clearHoverColorForSwitchLanguage() // 褰撳墠妯″潡棰滆壊鍙樼孩 addHoverColorForNav(this) }).on('mouseleave', function () { $('.navs .menu-bg').removeClass('open') t_delay = setTimeout(function () { $('.navs .menu-container').removeClass('open') }, delay_interval) }) $('.navs .menu-container').on('mouseenter', function () { if (t_delay) { clearTimeout(t_delay) } if (!$(this).hasClass('open')) { $(this).addClass('open') } if (!$('.navs .menu-bg').hasClass('open')) { $('.navs .menu-bg').addClass('open') } }).on('mouseleave', function () { let obj = $(this) t_delay = setTimeout(function () { obj.removeClass('open') }, delay_interval) $('.navs .menu-bg').removeClass('open') // 绉婚櫎鎵€鏈夌殑鍙樿壊 clearHoverColorForNav() }) // 2.骞荤伅鐗 // 鏈塴oop:true鏃讹紝11 22 44 33锛岄鍏堟墽琛岀殑鏄痮nSlideChangeEnd // 娌℃湁loop:true鏃讹紝22 44 33锛宱nSlideChangeEnd涓嶄細琚鍏堟墽琛 let flag = false let swiperFlag = false let mySwiper = new Swiper('.banner_index', { autoplay: 8000, // 鍙€夐€夐」锛岃嚜鍔ㄦ粦鍔 autoHeight: true, loop: true, pagination: '.banner_index .swiper-pagination', prevButton: '.banner_index .swiper-button-prev', nextButton: '.banner_index .swiper-button-next', paginationClickable: true, onSlideChangeEnd: function (swiper) { let _this = $('.banner_index .swiper-slide').eq(swiper.activeIndex) if (!swiperFlag) { swiperFlag = true } else { videoSelect(_this) } } }) videoSelect($('.banner_index .swiper-slide.swiper-slide-active')) /** * 鎾斁瑙嗛 * * @param _this */ function videoSelect(_this) { let flag = true let cc = _this.hasClass('ban_video') if (cc) { mySwiper.stopAutoplay() let videos = '' _this.append(videos) let aaa = setInterval(function () { if (!isNaN($('.vv').get(0).duration) && flag) { clearInterval(aaa) flag = false setTimeout(function () { _this.find('video').css('display', 'block') }, 500) } }, 10) _this.find('video').bind('ended', function () { mySwiper.slideNext() mySwiper.startAutoplay() }) } else { $('.vv').remove() } } // 3.鐖跺厓绱犲闄 // 鎵嬫満绔 if (clientWidth < 1100) { $('.key-products').find('.flex-item-wrap').each(function () { // 鍙栧嚭鐖剁骇鑺傜偣 $(this).parent().css('height', $(this).outerHeight(true) + 60 + 'px') }) } /** * 鑿滃崟鏄剧ず鍜岄殣钘 */ $('.language-left').mouseover(function () { clearHoverColorForNav() addHoverColorForNav(this) $(this).children('ul').show() }) $('.language-left').mouseout(function () { clearHoverColorForNav() clearHoverColorForSwitchLanguage() $(this).children('ul').hide() }) // 鏁板瓧婊氬姩 if ($('.num-box').length > 0 && $('.world-box').length > 0) { let options = { useEasing: true, useGrouping: false, separator: ',', decimal: '.' } let num1 = new CountUp('num1', 1000, 2010, 0, 1.5, options) let num2 = new CountUp('num2', 500, 2000, 0, 1.5, options) let num3 = new CountUp('num3', 100, 1000, 0, 1.5, options) let num4 = new CountUp('num4', 10, 300, 0, 1.5, options) let num5 = new CountUp('num5', 500, 300, 0, 1.5, options) let num6 = new CountUp('num6', 100, 1000, 0, 1.5, options) let num7 = new CountUp('num7', 10, 2000, 0, 2, options) $(window).on('scroll', function () { if ($(window).scrollTop() > $('.num-box').offset().top - 600) { num1.start() num2.start() num3.start() num4.start() } if ($(window).scrollTop() > $('.world-box').offset().top - 600) { num5.start() num6.start() num7.start() } }) } // 浜у搧鍐呴〉, 绌虹櫧浣嶇疆琛ュ叏 if ($('.inner-content-product-list').length > 0) { let imgLen = $('.inner-content-product-list').children('.product-flex-item').length let toBeSupplemented = 4 - imgLen % 4 // 璁剧疆绌鸿妭鐐 let blankNode = '
绌虹櫧
' for (let i = 0; i < toBeSupplemented; i++) { $('.inner-content-product-list').append(blankNode) } } }) /** * 鐐瑰嚮鎼滅储 */ function handleClickSearch() { // 閫昏緫 $('.fusion-mobile-menu-search').slideToggle() } /** * 鐐瑰嚮灞曞紑鑿滃崟 */ function handleClickViewMenu() { // 閫昏緫 $('.fusion-mobile-nav-holder').slideToggle() } /** * 鐐瑰嚮灞曞紑瀛愯彍鍗 * * @param node -褰撳墠鑺傜偣 */ function handleClickViewSubMenu(node) { // 閫昏緫 $(node).next('ul').slideToggle() } /** * 鏄剧ず瀵艰埅鍜屾悳绱㈡ā鍧 */ function showNavAndSearch() { // 闅愯棌 nav-ul, language $('.menu-search').hide() $('.nav-ul').show() $('.language').show() } /** * 闅愯棌瀵艰埅鍜屾悳绱㈡ā鍧 */ function hiddenNavAndSearch() { // 闅愯棌 nav-ul, language $('.nav-ul').hide() $('.language').hide() $('.menu-search').show() } /** * 鎵€鏈夊鑸殑棰滆壊杩樺師 */ function clearHoverColorForNav() { $('.nav-ul').children('.hasmenu').each(function () { $(this).find('i').css('color', '#FFFFFF') }) } /** * 褰撳墠瀵艰埅楂樹寒 * * @param node - 榛樿this */ function addHoverColorForNav(node) { $(node).find('i').css('color', 'red') } /** * 鍒囨崲瀛椾綋鐨勯鑹茶繕鍘 */ function clearHoverColorForSwitchLanguage() { $('.switch-language').find('i').css('color', '#FFFFFF') } /** * 璺宠浆 * * @param lang -璇█ * @param url -璺宠浆鍦板潃 */ function goUrl(lang, url) { // 閫昏緫 window.location.href = '/' + lang + '/' + url } /** * 澶撮儴鎼滅储 */ function searchFormForHeader(node) { console.log('鎮ㄧ偣鍑讳簡澶撮儴鍖哄煙鐨勬悳绱?) return false } /** * 鏁翠綋鎼滅储 */ function searchForm(node) { console.log('鎮ㄧ偣鍑讳簡鍐呭鍖哄煙鐨勬悳绱?) } /** * 榧犳爣鏀句笂鍘讳箣鍚庣殑鏁堟灉 * * @param node */ function handleMouseOver(node) { // 鍒囨崲鍥剧墖 // 鍙栧嚭 img 鑺傜偣 let imgNode = $(node).find('img').eq(0) // 鍙栧嚭 hover-src let hoverSrc = imgNode.attr('data-hover-src') // 璧嬪€ imgNode.attr('src', hoverSrc) } /** * 榧犳爣绉诲紑涔嬪悗鐨勬晥鏋 * * @param node */ function handleMouseOut(node) { // 鍙栧嚭 img 鑺傜偣 let imgNode = $(node).find('img').eq(0) // 鍙栧嚭 origin-src let originSrc = imgNode.attr('data-origin-src') // 璧嬪€ imgNode.attr('src', originSrc) }