$(function () { // wow初始化 new WOW().init(); // 手机导航下拉 phMenu(); mcCheckbox(); pcNav(); ftInit(); xlSearch(); }); // 手机导航下拉 function phMenu() { // ph导航 $(".mc_ph_menu").click(function () { // 11.19 var h = window.innerHeight - 64; $(".xialaph").css("height",h+"px"); // 11.19 $(this).find(".point").toggleClass("active"); $(".xialaph").stop().slideToggle(); $(".phonemeng").toggleClass('active'); $("html").toggleClass("modal-open") // $("body,html").animate({ // scrollTop: 0 // }, 500); }); // ph导航二级 $(".xialaph h4").click(function (e) { if ($(e.target).hasClass("g_phnav1")) { return; } if ($(this).parents("li").hasClass("mc_phnav_hasnosub")) { return; } $(this).siblings(".ul2").stop().slideToggle(); $(this).parent().parent().siblings().find(".ul2").stop().slideUp(); $(this).toggleClass("active"); $(this).parent().parent().siblings().find("h4,h5").removeClass('active'); }); /*ph导航三级*/ $(".xialaph h5").click(function () { $(this).siblings(".ul3").stop().slideToggle(); $(this).parent().siblings().find(".ul3").stop().slideUp(); $(this).toggleClass("active"); $(this).parent().siblings().find("h4,h5").removeClass('active'); }); $(".ul1>li").each(function () { if ($(this).find(".ul2 li").length == 0) { $(this).addClass("mc_phnav_hasnosub"); } }) $(".xialaph h4 a").click(function (e) { e.stopPropagation }); } // checkbox function mcCheckbox() { $(".mc_ly_checkbox").find("input").click(function (e) { e.stopPropagation(); }) $(".mc_ly_checkbox").click(function () { $(this).find("input").click(); }) //2021.1.26 mark $(".mc_ly_yycj .mc_ly_checkbox").click(function() { $(this).siblings().find("input[type=checkbox]").removeAttr("checked"); }) } // 锚点 function yxtop() { $(window).load(function () { var test = (window.location.href).split('tp/'); if (!isNaN(test[1])) { $("html,body").animate({ scrollTop: $('[yxdatop-pag="' + test[1] + '"]').offset().top - 90 }, 700); } }) }; // pc导航相关 function pcNav() { // 导航吸顶 navFixed(); $(window).scroll(function () { navFixed(); }) function navFixed() { if ($(window).scrollTop() > 0) { $(".mc_navbar").addClass("mc_fixed") } else { if ($(".mc_navbar").hasClass("hovernow")) { return; } $(".mc_navbar").removeClass("mc_fixed") } } $(".mc_navbar").hover( function () { $(this).addClass("hovernow"); if ($(window).scrollTop() == 0) { $(this).addClass("mc_fixed mc_nav_hover") } }, function () { $(this).removeClass("hovernow"); if ($(window).scrollTop() == 0) { $(this).removeClass("mc_fixed") } $(this).removeClass("mc_nav_hover") } ) // 9.11 // 二级下拉 $(".mc_nav_li").not(".yxnav_active1").hover( function () { // if ($(window).scrollTop() == 0) { // $(".mc_navbar").addClass("mc_fixed") // } $(this).find(".mc_nav_xl").stop().slideDown().addClass("show"); $(".mc_nav_li.yxnav_active1").find(".mc_nav_xl").addClass("xlhide"); }, function () { // if ($(window).scrollTop() == 0) { // $(".mc_navbar").removeClass("mc_fixed") // } $(this).find(".mc_nav_xl").stop().slideUp().removeClass("show"); $(".mc_nav_li.yxnav_active1").find(".mc_nav_xl").removeClass("xlhide"); } ) // 搜索下拉 var isShow = false; $(".mc_search").click(function (e) { e.stopPropagation(); if (!isShow) { $(this).addClass("isshow"); $(this).find(".mc_search_xl").stop().slideDown().addClass("show"); isShow = true; } else { $(this).removeClass("isshow"); $(this).find(".mc_search_xl").stop().slideUp().removeClass("show"); isShow = false; } }) $(".mc_search_xl").click(function (e) { e.stopPropagation(); }) $(".mc_search_xl").mouseleave(function () { $(this).parents(".mc_search").removeClass("isshow"); $(this).stop().slideUp().removeClass("show"); isShow = false; }) } //底部相关 function ftInit() { // 底部二维码显示 if ($(window).width() > 1200) { $(".mc_ft1_qrbox").hover( function () { $(this).find(".mc_ft1_qrxl").stop().slideDown(); }, function () { $(this).find(".mc_ft1_qrxl").stop().slideUp(); } ) } else { $(".mc_ft1_qrbox").click(function (e) { e.stopPropagation(); $(this).siblings().find(".mc_ft1_qrxl").stop().slideUp(); $(this).find(".mc_ft1_qrxl").stop().slideToggle(); }); $("body").click(function () { $(".mc_ft1_qrxl").stop().slideUp(); }) } } //导航hover效果 $(function () { // navHover(); }); function navHover() { var $line = $('') if ($(".mc_nav_line").length < 1) { $(".mc_nav").append($line); } var linePara = { widthArr: [], leftArr: [], leftAct: 0, widthAct: 0, } getLinePara(); lineInit(); $(window).load(function () { getLinePara(); lineInit(); }) $(window).resize(function () { getLinePara(); lineInit(); }) $(".mc_nav_li").hover( function () { var index = $(this).index(); setLinePara(linePara.leftArr[index], linePara.widthArr[index]); }, function () { lineInit(); } ) // 线初始化 function lineInit() { setLinePara(linePara.leftAct, linePara.widthAct); console.log(linePara); } // 获取线的left和width参数 function getLinePara() { linePara.widthArr = []; linePara.leftArr = []; $(".mc_nav>.mc_nav_li").each(function () { var itemLeft = $(this).position().left linePara.leftArr.push(itemLeft); var itemWidth = $(this).outerWidth(); linePara.widthArr.push(itemWidth); if ($(this).hasClass("yxnav_active1")) { linePara.leftAct = itemLeft; linePara.widthAct = itemWidth; } }) } //设定线的参数 function setLinePara(itemLeft, itemWidth) { $line.css({ left: itemLeft, width: itemWidth, }) } } //前沿技术(研发)往上移动效果 $(function () { dataTable(); }) $(window).load(function () { dataTable(); }) function dataTable() { if ($(".mc_data_td").length > 0) { var dataTopArr = []; getTopArr(); isDataShow(); $(window).resize(function () { getTopArr(); }) $(window).scroll(function () { isDataShow(); }) // 判断是否显示 function isDataShow() { for (var i = 0; i < dataTopArr[length]; i++) { if ($(window).scrollTop() > dataTopArr[i]) { $(".mc_data_td").eq(i).addClass("active"); } else { $(".mc_data_td").eq(i).removeClass("active"); } } } // 获取元素距离顶部的高度 function getTopArr() { $(".mc_data_td").each(function (index) { var itemIndex = index; var itemTop = $(this).offset().top - $(window).height() / 1.5; dataTopArr[itemIndex] = itemTop; }) } } } //前沿技术(研发)往上移动效果 $(function () { g1List(); }) $(window).load(function () { g1List(); }) function g1List() { if ($(".mc_g1_li").length > 0) { var dataTopArr = []; getTopArr(); isDataShow(); $(window).resize(function () { getTopArr(); }) $(window).scroll(function () { isDataShow(); }) // 判断是否显示 function isDataShow() { for (var i = 0; i < dataTopArr[length]; i++) { if ($(window).scrollTop() > dataTopArr[i]) { $(".mc_g1_li").eq(i).addClass("active"); } else { $(".mc_g1_li").eq(i).removeClass("active"); } } } // 获取元素距离顶部的高度 function getTopArr() { $(".mc_g1_li").each(function (index) { var itemIndex = index; var itemTop = $(this).offset().top - $(window).height() / 1.5; dataTopArr[itemIndex] = itemTop; }) } } } // 更多案例 function moreCase() { var tool = '
' + '
' + '' + '更多案例' + '
' + '
' + '' + '
' + '
' $(".mc_btn_list").each(function () { if ($(this).find(".mc_btn_li").length > 4) { $(this).append(tool); } }) $(".mc_btn_list").on("click", ".mc_btn_show", function () { $(this).hide().parent(".mc_btn_toggle").siblings(".mc_btn_li").css("display", "inline-block"); $(this).siblings(".mc_btn_hide").show(); }); $(".mc_btn_list").on("click", ".mc_btn_hide", function () { $(this).hide().parent(".mc_btn_toggle").siblings(".mc_btn_li:gt(3)").hide(); $(this).siblings(".mc_btn_show").show(); }); } // 9.2 function xlSearch() { $("#serachs").click(function () { var keywords = $("#keywords").val(); if (keywords.length == 0) { alert("请输入关键字!"); } else { window.location.href = "/search/?" + keywords } }); $("#keywords").keyup(function (event) { if (event.keyCode == 13) { $("#serachs").trigger("click"); } }); } // searchInit(); function searchInit(){ var keywords = window.location.search; keywords = decodeURI(keywords.replace("?",'')); if(!keywords){ return false; } $("#text").val(keywords); serach(); }