// 处于页面配置时,绑定方法 start if ($isDecorateMode) { document.addEventListener("diy_header/1", (event) => { const { field, value } = event.detail; console.log(field, value) }); } // 处于页面配置时,绑定方法 end $(function () { let solutionTabsStickPoint = null $("#logout").click(function () { $request .post("/api/user/logout") .then((res) => { // 跳转页面 location.href = "/"; }); }) // 防止一开始进入页面在底部不显示 setHeaderSticky() $(window).on('scroll', setHeaderSticky) $(window).on('resize', function () { solutionTabsStickPoint = null setHeaderSticky() }) function setHeaderSticky(){ let offset = $(window).scrollTop() if (offset > 0) { $('.ys-header').addClass('is-sticky') } else { $('.ys-header').removeClass('is-sticky') } setSolutionShowcaseState(offset) } function setSolutionShowcaseState(offset) { const tabsWrap = $('.solution-showcase__tabs-wrap') if (!tabsWrap.length) { $('body').removeClass('solution-showcase-at-top solution-showcase-tabs-stuck') solutionTabsStickPoint = null return } if (solutionTabsStickPoint === null) { refreshSolutionTabsStickPoint(tabsWrap) } const isAtTop = offset <= 0 const isTabsStuck = !isAtTop && offset >= solutionTabsStickPoint $('body').toggleClass('solution-showcase-at-top', isAtTop) $('body').toggleClass('solution-showcase-tabs-stuck', isTabsStuck) tabsWrap.toggleClass('is-stuck', isTabsStuck) } function refreshSolutionTabsStickPoint(tabsWrap) { const wasStuck = tabsWrap.hasClass('is-stuck') const body = $('body') tabsWrap.removeClass('is-stuck') body.removeClass('solution-showcase-tabs-stuck') tabsWrap.addClass('is-stuck') const stickyTabsHeight = tabsWrap.outerHeight() || 64 tabsWrap.removeClass('is-stuck') const hero = tabsWrap.prev('.solution-showcase__hero') const heroBottom = hero.length ? hero.offset().top + hero.outerHeight() : tabsWrap.offset().top solutionTabsStickPoint = Math.max(0, Math.ceil(heroBottom - stickyTabsHeight)) tabsWrap.css('--solution-tabs-height', stickyTabsHeight + 'px') tabsWrap.toggleClass('is-stuck', wasStuck) body.toggleClass('solution-showcase-tabs-stuck', wasStuck) } // 隐藏 导航栏 active function hideActiveCard() { $('.ys-header__nav .nav-item .ys-header__card.active').stop().fadeOut(300) } // 显示 导航栏 active function showActiveCard() { $('.ys-header__nav .nav-item .ys-header__card.active').stop().fadeIn(300) } // mega menu hover interaction $('.mega-sidebar-item').mouseenter(function() { let index = $(this).data('index'); $('.mega-sidebar-item').removeClass('active'); $(this).addClass('active'); $(this).closest('.ys-header__mega').find('.mega-panel').removeClass('active'); $(this).closest('.ys-header__mega').find(`.mega-panel[data-index="${index}"]`).addClass('active'); }); $('.close-mega-menu').click(function() { $(this).closest('.nav-item').trigger('mouseleave'); }); // 导航栏悬停 $('.ys-header__nav .nav-item').hover(function () { if(!$(this).find('.ys-header__card').hasClass('active')) hideActiveCard() $(this).find('.ys-header__card').addClass('show') if(!$(this).hasClass('ignore')) $('.ys-header__cover').removeClass('display-none') }, function () { if(!$(this).find('.ys-header__card').hasClass('active')) showActiveCard() $(this).find('.ys-header__card').removeClass('show') $('.ys-header__cover').addClass('display-none') }) // 搜索图标点击:参考 header/2 展开搜索区域 $('.ys-header__search-icon').click(function () { openSearchCard() $('.ys-header__search input').trigger('focus') }) $('.ys-header__search input').focus(function () { openSearchCard() }) function containsTarget(selector, target) { const node = $(selector)[0] return !!(node && node.contains(target)) } $(document).on('click', function (e) { if ( containsTarget(".ys-header .ys-header__search", e.target) || containsTarget(".ys-header .ys-header__search-icon", e.target) || $(".ys-header__search input").is(":focus") || containsTarget(".ys-header .ys-header__menu", e.target) || containsTarget(".ys-header .ys-header-menu", e.target) || containsTarget(".ys-header .ys-header-search--mobile", e.target) ) return closeSearchCard(); }) // 搜索 $('.ys-header__search input').keyup(function (e) { if (e.keyCode === 13) { search() } }) $('.ys-header__search .search-btn').click(function () { search() }) // 联系销售:与 rightNav/1 的在线客服保持一致 $('.ys-header__contact-btn').click(function (e) { e.preventDefault() // 优先走全局事件,复用 rightNav/1 的统一客服打开逻辑 window.dispatchEvent(new Event('openService')) // 兜底:当 rightNav 未挂载时,直接触发已知客服按钮 if ($('#aff-im-root .embed-icon-pcIcon5').length > 0) { $('#aff-im-root .embed-icon-pcIcon5').click() return } if ($('#newBridge .nb-icon-wrap').length > 0) { $('#newBridge .nb-icon-wrap').click() } }) // 展开搜索卡片 function openSearchCard() { $('.ys-header__nav').addClass('display-none') $('.ys-header__logo').addClass('display-none') $('.ys-header__right').addClass('open') } // 收起搜索卡片 function closeSearchCard() { $('.ys-header__nav').removeClass('display-none') $('.ys-header__logo').removeClass('display-none') $('.ys-header__right').removeClass('open') $('.ys-header').removeClass('is-show-mobile-search') } // 搜索事件 function search() { let val = $('.ys-header__search input').val() if (!val) return $message.warning('请输入搜索关键词') window.location.href = '/search_result.html?keyword=' + encodeURIComponent(val) closeSearchCard() } // 产品二级菜单切换 $('.ys-header__nav .product-item').hover(function () { $('.ys-header__nav .product-child').addClass('display-none') $('.ys-header__nav .product-item').removeClass('active') $(this).addClass('active') $(this).next().removeClass('display-none') }) // 点击遮罩 $('.ys-header__cover').click(function(){ closeMenuFold() }) // 移动端搜索 $('.ys-header .ys-header-search--mobile .icon-search').click(function(){ $('.ys-header').addClass('is-show-mobile-search') openSearchCard() }) // 抽屉 function openMenuFold() { $('.ys-header .ys-header-menu').addClass('show') $('.ys-header__cover').removeClass('display-none') $('body').addClass('popup-parent--hidden') } function closeMenuFold() { $('.ys-header__cover').addClass('display-none') $('.ys-header .ys-header-menu').removeClass('show') $('body').removeClass('popup-parent--hidden') closeAllMenuSecond() } $('.ys-header .ys-header__menu .icon-menu').click(openMenuFold) $('.ys-header .ys-header-menu .icon-close').click(closeMenuFold) }) // 二级菜单 $('.ys-header-menu').on('click', '.header-menu__more', function() { const item = $(this) const flag = item.next().hasClass('active') $('.header-menu__list').removeClass('active').stop().slideUp() if(flag) return item.next().addClass('active').stop().slideDown() }) $('.ys-header-menu').on('click', '.header-menu__button', function() { const item = $(this) closeAllMenuSecond() item.next().addClass('active') }) $('.ys-header-menu').on('click', '.header-second-back', function() { closeAllMenuSecond() }) function closeAllMenuSecond() { $('.header-menu__second').removeClass('active') } /******** 介绍 start *********/ $('.join-about__list .join-about__item').on('mouseenter', function () { $(this).find('.join-about__desc').stop().slideDown(); $(this).addClass('active') }) $('.join-about__list .join-about__item').on('mouseleave', function () { $(this).find('.join-about__desc').stop().slideUp() $(this).removeClass('active') }) /******** 介绍 start *********/ /******** 精彩活动 start *********/ new Swiper(".join-activity__box", { autoplay: 3000, loop: true, slidesPerView: 'auto', spaceBetween: 20, slidesPerGroup: 1, prevButton: ".join-activity__arrow .arrow-left", nextButton: ".join-activity__arrow .arrow-right", breakpoints: { 768: { slidesPerView: 1, }, }, }); /******** 精彩活动 start *********/ // 处于页面配置时,绑定方法 if ($isDecorateMode) { document.addEventListener('diy_footer/1', (event) => { const { field, value } = event.detail console.log(field, value) if (field === 'footer_ad') { const nodes = $( value .map((item) => `${item.alt}`) .join('') ) $('.ys-footer__ad').empty() $('.ys-footer__ad').append(nodes) } else if (field === 'contact_phone') { $('.footer_phone').text(value) } else if (field === 'work_time') { $('.footer_work_time').text(value) } else if (field === 'contact_email') { $('.footer_email').text(value) } else if (field === 'footer_nav') { const nodes = $( value .map( (c) => ` ` ) .join('') ) $('.ys-footer__content .center-part').empty() $('.ys-footer__content .center-part').append(nodes) } else if (field === 'right_part') { const nodes = $( value .map((item) => `${item.alt}`) .join('') ) $('.ys-footer__content .right-part').empty() $('.ys-footer__content .right-part').append(nodes) } else if (field === 'friendly_links') { const nodes = $( value .map( (e) => `
  • ${e.title}
  • ` ) .join('') ) $('.ys-footer__friendly ul').empty() $('.ys-footer__friendly ul').append(nodes) } else if (field === 'copyright') { $('.copyright-wrap span').text(value) } else if (field === 'beian') { $('.copyright-wrap a').text(value) } else if (field === 'footer_logo') { $('.footer-logo').attr('alt', value.alt) $('.footer-logo').attr('src', value.src) } else if (field === 'map_links') { const nodes = $( value .map( (e) => ` ${e.title} ` ) .join('') ) $('.ys-footer__end .end-link').empty() $('.ys-footer__end .end-link').append(nodes) } }) } // 底部导航折叠面板 $('.ys-footer__content .center-part').on('click','.content-link__title',function(){ if($(window).width() > 768) { $('.ys-footer__content .center-part').addClass('is-fold') return } $('.ys-footer__content .center-part').removeClass('is-fold') const item = $(this) item.parent().toggleClass('show') item.next().stop().slideToggle() }) window.addEventListener('openService', openService) // 监听全局客服点击事件 $('#backTop').click(function () { $('html, body').animate({ scrollTop: 0 }, 300) }) $('.ys-rightNav .service').click(function() { openService() }) // 打开客服弹窗 function openService() { if ($('#aff-im-root .embed-icon-pcIcon5').length > 0) { $('#aff-im-root .embed-icon-pcIcon5').click() } else { $('#newBridge .nb-icon-wrap').click() } } // 监听页面滚动 $(window).scroll(function () { $('.ys-rightNav #backTop').css('display', $(document).scrollTop() ? 'block' : 'none') })