function getStyle(ele, attr){//获取样式 return window.getComputedStyle ? window.getComputedStyle(ele, null)[attr] : ele.currentStyle[attr]; } function signClassChange(){//标签类选择器变更 let string = typeof(arguments[1]) == "undefined" ? "" : arguments[1]; for(let i = 0; i < arguments[0].length; i++){ arguments[0][i].className = string; } } function leftChange(arr, num){//偏移切换 for(let i = 0; i < arr.length; i++){ arr[i].style.left = num + "px"; } } function getActiveIndex(arr){//获取数组活动项下标 let i = 0; for(i; i < arr.length; i++){ if(arr[i].className == "active"){ return i; } } return 0; } function getBodyWH(){//获取页面宽高 return [ document.body.clientWidth, document.body.clientHeight ] } function replaceStr(str, tge){//将字符串中所有换行符替换为tga return str.replace(/\n/g, tge); } setTimeout(function(){//内页导航选定 let position_link = document.querySelectorAll(".position a"); let channel_lis = document.querySelectorAll(".channel ul li"); channel_lis.forEach(function(item, index){ item.index = index; if(item.querySelector("a").innerHTML == position_link[position_link.length - 1].innerHTML){ item.className = "active"; return; } }); }, 300); if($('.swiper')[0]){ let swiper = new Swiper('.swiper', { spaceBetween:0, centeredSlides:true, loop:true, autoplay:{ delay:5000, disableOnInteraction:false, }, pagination:{ el:'.swiper-pagination', clickable:true, }, }); } let droplist = false; $('.header-box .menu-btn button').click(function(){ droplist = ! droplist; if(droplist){ $('.layer').css({ 'z-index':'100', 'opacity':'1' }); $('.mask').css('display','block'); } }); $('.layer .close-icon img').click(function(){ droplist = false; $('.mask').css('display','none'); $('.layer').css({ 'z-index':'-1', 'opacity':'0' }); }); $('.mask').click(function(){ droplist = false; $(this).css('display','none'); $('.layer').css({ 'z-index':'-1', 'opacity':'0' }); });