(function ($) { $.extend({ isMobileRequest: function () { let isMobile = false; if (/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))) { if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) { isMobile = true; } else { isMobile = false; } } return isMobile; }, lang: function () { var userArguments = Array.prototype.slice.call(arguments);//强行转换成数组 var tempArr = new Array();//临时数组 tempArr = userArguments;// var first = tempArr[0];//拿到第一个参数 tempArr.shift(); //删除第一个参数 var tempStr = Language[first]; if (Language && tempStr) { if (tempArr.length > 0) { for (var x in tempArr) { tempStr = tempStr.replace('%s', tempArr[x]);//替换掉特殊函数 } } } return tempStr; }, resizeImg: function () { let winWidth = $(window).width(); if ($(".resetImageBox").length > 0) { $(".resetImageBox img").each(function (key, value) { $(value).removeAttr("width").removeAttr("height").removeAttr("height").removeAttr("style"); var imageWidth = $(value).width(); if (imageWidth > winWidth) { $(value).css("width", winWidth); } }); } }, positionNav: function (catId) { let top = $("div[id='" + catId + "']").offset().top; $('html, body').animate({scrollTop: top - (parseInt($(window).height()) / 5)}, 500); return false; }, validateEmail: function (email) { if ($.trim(email).length != 0) { let reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; if (!reg.test(email)) { return false; } } return true; }, validatePhoneNumber: function (str) { if ($.trim(str).length != 0) { let reg = /^[0-9-+ ]+$/; if (!reg.test(str)) { return false; } } return true; }, numberScroll:function (sz,c) { sz=parseInt(sz); $(c).animate({num: sz}, { duration: 2000, // 动画持续时间为2秒 step: function(now) { $(this).text(Math.ceil(now)); // 更新数字显示的值 } }); } }) })(jQuery); $(function () { var windowWidth = $(window).width() if (!$.isMobileRequest()) { $(document).off('click.bs.dropdown.data-api'); //导航自动展开 $('.dropMenu .dropdown').mouseenter(function () { if ($('#productNav').length>0){ $('#productNav').css('z-index',77) } if ($("#aboutNav").length>0){ $('#aboutNav').css('z-index',77) } if(windowWidth>991){ $(this).addClass('open'); } }).mouseleave(function () { if ($('#productNav').length>0){ $('#productNav').css('z-index',99) } if ($("#aboutNav").length>0){ $('#aboutNav').css('z-index',99) } if(windowWidth>991){ $(this).removeClass('open'); } }); } else { //$(document).off('click.bs.dropdown.data-api'); //$(".account .dropdown-toggle").removeAttr('data-toggle'); //监听手机端网站底部菜单 $(document).on('hide.bs.collapse', ".search-form-m", function () { }).on('show.bs.collapse', ".dropdown", function () { }); } //移动端collapse菜单监听导航开关 $(".phone_nav_close").click(function () { $('#header').collapse("toggle"); }); $(window).scroll(function () { if ($('#backTop').length > 0) { if ($(this).scrollTop() >= $(this).height() / 3) { $('#backTop').fadeIn('slow'); } else { $('#backTop').fadeOut('slow'); } } }); var scrollTopTimer = null; $('#backTop').click(function () { clearInterval(scrollTopTimer); scrollTopTimer = setInterval(function () { var top = document.body.scrollTop || document.documentElement.scrollTop; var speed = top / 4; if (document.body.scrollTop != 0) { document.body.scrollTop -= speed; } else { document.documentElement.scrollTop -= speed; } if (top <= 0) { clearInterval(scrollTopTimer); } }, 30); }); })