$(function () {
$("p:last-child").addClass("no_margin");
headerJs()
footerJs()
{
$(".navLink").on('click', function () {
var id = $(this).attr('data-id');
var link = $(this).attr('href');
if (id) {
localStorage.setItem('__todom__', id);
}
location.href = link;
return false;
})
window.onload = function () {
var getobj = localStorage.getItem('__todom__');
console.log(getobj);
setTimeout(function () {
if (getobj) {
var obj = $('#' + getobj);
var headheight = $('#header').height();
headheight = Math.max(110, headheight);
var top = obj.offset().top - headheight - 1;
console.log(top);
$('html,body').scrollTop(top);
localStorage.removeItem('__todom__');
}
});
}
}
function headerJs() {
// pc
if ($(".header-pc").length) {
// 导航判断
// var thisHref = true;
// $("#header .nav dt a").each(function () {
// var urlstr = location.href;
// thisHref = $(this).attr('href');
// var nav_name = thisHref.replace(/(.*\/)*([^.]+).*/ig, "$2").replace(/\d+/g, '');
// if (thisHref !== '/' && (urlstr + '/').indexOf(nav_name) > -1 && $(this).attr('href') != '') {
// $(this).addClass('on');
// return false;
// } else {
// thisHref = false;
// }
// });
// 触发白底
$("#header").mouseover(function () {
$(this).addClass("on");
}).mouseleave(function () {
$(this).removeClass("on");
})
// 二级显示
$(".header-pc .nav dl").mouseover(function () {
// var i = $(this).index();
$(".mask-bg").addClass("show");
$(".header-pc .nav dd").stop().slideUp(300);
$(this).find("dd").stop().slideDown(300);
});
$(".header-pc .header-wrap .nav").mouseleave(function () {
$(".header-pc .nav dd").stop().slideUp(300);
});
$(".header-pc .head-right").mouseleave(function () {
$(".mask-bg").removeClass("show");
});
$(".head-right .nav dl:eq(0)").mouseover(function () {
$(".mask-bg").removeClass("show");
});
$(window).scroll(function () {
headInit()
})
headInit()
function headInit() {
var t = $(window).scrollTop();
if (t >= 60) {
$("#header").addClass("onsb")
} else {
$("#header").removeClass("onsb")
}
}
}
// 手机
if ($(".header-mobile").length) {
// 导航判断
var thisHref = true;
$(".header-mobile .nav a").each(function () {
var urlstr = location.href;
thisHref = $(this).attr('href');
var nav_name = thisHref.replace(/(.*\/)*([^.]+).*/ig, "$2").replace(/\d+/g, '');
if (thisHref !== '/' && (urlstr + '/').indexOf(thisHref) > -1 && $(this).attr('href') != '') {
$(this).addClass('on');
if ($(this).parents('dd')) {
$(this).parents('dd').slideDown()
$(this).parents('li').addClass('on')
}
return false;
} else {
thisHref = false;
}
});
if (!thisHref) {
$(".header-mobile .nav a").eq(0).addClass('on');
}
const headNav = $(".header-mobile .navBox");
const header = $('.header-mobile .header');
$('.ham').click(function () {
if ($(this).hasClass('on')) {
$(this).removeClass('on');
headNav.fadeOut();
header.removeClass('active')
} else {
$(this).toggleClass('on');
headNav.fadeToggle();
header.addClass('active');
$('.m-login-menu').removeClass('visible');
}
});
$('.nav > li').click(function () {
$(this).toggleClass('on').siblings().removeClass('on');
$(this).find('dd').stop().slideToggle();
$(this).siblings().find('dd').stop().slideUp();
})
}
}
function footerJs() {
}
// 首页
if ($(".index").length) {
// 顶部轮播
function win_h() {
var win_h = $(window).height();
$('.index-swiper,.index-swiper .swiper-slide').height(win_h);
}
win_h();
$('.index-swiper').each(function () {
var slide = new Swiper('.index-swiper', {
autoplay: {
delay: 4000,
disableOnInteraction: false,
},
effect: 'fade',
fadeEffect: {
crossFade: true,
},
loop: true,
preventLinksPropagation: false, // 阻止点击事件冒泡
navigation: {
nextEl: '.index-swiper .swiper-button-next',
prevEl: '.index-swiper .swiper-button-prev',
},
pagination: {
el: '.index-swiper .swiper-pagination',
// type: 'fraction',
clickable: true,
renderBullet: function (index, className) {
if (index >= 9) {
return '' + (index + 1) + '';
} else {
return '' + '' + '0' + (index + 1) + '' + '';
}
},
},
});
});
var indexslide1 = new Swiper('.index-slide', {
initialSlide: 0,
speed: 1000,
loop: true,
slidesPerView: 'auto',
spaceBetween: 22,
autoHeight: true,
navigation: {
nextEl: '.index-slide .swiper-button-next',
prevEl: '.index-slide .swiper-button-prev',
},
scrollbar: {
el: '.index-slide .swiper-scrollbar',
},
pagination: {
el: '.index-slide .swiper-pagination',
clickable: true,
},
slideToClickedSlide: true,
observer: true, //自动初始化swiper
observeParents: true, //自动初始化swiper
breakpoints: {
780: {
spaceBetween: 20
},
1200: {
spaceBetween: 20
}
},
on: {
slideChangeTransitionStart: function (swiper) {
// console.log(this.activeIndex)
// var d = this.activeIndex;
var d = this.realIndex;
$(".index-box2 .page_nav .list a").stop().removeClass("on").eq(d).addClass("on");
var li_wid = $(".index-box2 .page_nav .list a").eq(0).width();
$(".index-box2 .page_nav").stop().animate({ "scrollLeft": (d) * li_wid });
},
},
});
setTimeout(function () {
var li_wid = $(".index-box2 .page_nav .list a").eq(0).width();
$(".index-box2 .page_nav .list a").click(function () {
var a = $(this).index();
$(".index-box2 .index-slide .swiper-pagination-bullet").eq($(this).index()).click();
$(this).addClass("on").siblings().removeClass("on");
$(".index-box2 .page_nav").stop().animate({ "scrollLeft": (a) * li_wid });
});
var indexslide3 = new Swiper('.index-slide3', {
initialSlide: 0,
speed: 1000,
loop: true,
slidesPerView: 'auto',
spaceBetween: 27,
autoHeight: true,
navigation: {
nextEl: '.index-slide3 .swiper-button-next',
prevEl: '.index-slide3 .swiper-button-prev',
},
scrollbar: {
el: '.index-slide3 .swiper-scrollbar',
},
pagination: {
el: '.index-slide3 .swiper-pagination',
clickable: true,
},
breakpoints: {
780: {
spaceBetween: 20
},
1200: {
spaceBetween: 20
}
},
});
var indexslide5 = new Swiper('.index-slide5', {
initialSlide: 0,
speed: 1000,
loop: true,
slidesPerView: 'auto',
spaceBetween: 27,
autoHeight: true,
navigation: {
nextEl: '.index-slide5 .swiper-button-next',
prevEl: '.index-slide5 .swiper-button-prev',
},
scrollbar: {
el: '.index-slide5 .swiper-scrollbar',
},
pagination: {
el: '.index-slide5 .swiper-pagination',
clickable: true,
},
breakpoints: {
780: {
spaceBetween: 20
},
1200: {
spaceBetween: 20
}
},
});
}, 800);
function indexmonitor() {
};
indexmonitor();
// $(window).resize(function () {
// indexmonitor();
// $(window).scroll(function () {
// indexmonitor();
// });
// });
}
// 产品
if ($(".product").length) {
var productslide = new Swiper('.product-slide', {
initialSlide: 0,
speed: 1000,
// loop: true,
slidesPerView: 'auto',
spaceBetween: 27,
autoHeight: true,
navigation: {
nextEl: '.product-slide .swiper-button-next',
prevEl: '.product-slide .swiper-button-prev',
},
scrollbar: {
el: '.product-slide .swiper-scrollbar',
},
pagination: {
el: '.product-slide .swiper-pagination',
clickable: true,
},
breakpoints: {
780: {
spaceBetween: 20
},
1200: {
spaceBetween: 20
}
},
});
// var li_wid = $(".product-box2 .tab-name a").eq(1).width();
// var detailed = $(".product-box2 .tab-wrap .tab-box");
// $(".product-box2 .tab-name a").click(function () {
// var d = $(this).index();
// $(this).addClass("on").siblings().removeClass("on");
// detailed.eq(d - 1).stop().fadeIn().siblings().stop().hide();
// $(".product-box2 .tabBox").stop().animate({
// "scrollLeft": (d - 1) * li_wid
// });
// });
// $(".product-box2 .tab-name a").eq(0).click();
}
// 新闻
if ($(".news").length) {
var slide = new Swiper('.news-slide', {
autoplay: {
delay: 4000,
disableOnInteraction: false,
},
effect: 'fade',
fadeEffect: {
crossFade: true,
},
loop: true,
preventLinksPropagation: false,
navigation: {
nextEl: '.news-slide .swiper-button-next',
prevEl: '.news-slide .swiper-button-prev',
},
pagination: {
el: '.news-slide .swiper-pagination',
clickable: true,
},
});
$(".news-slide .swiper-slide .text-box").addClass('animated fadeIn');
$(".news-slide .swiper-slide .name").addClass('animated fadeInUp').css({
'animation-delay': '.2s'
});
$(".news-slide .swiper-slide .date").addClass('animated fadeInUp').css({
'animation-delay': '.4s'
});
$(".news-slide .swiper-slide .text").addClass('animated fadeInUp').css({
'animation-delay': '.6s'
});
}
// 人才招聘
if ($(".person5").length) {
$(".tab-ul ul li:eq(0)").addClass("on");
$(".tab-ul ul li:eq(0) .bom").slideToggle();
$(".tab-ul ul").on("click", 'li .top', function () {
var dd = $(this).next();
var li = $(this).parent();
var other = li.siblings();
var otherDd = other.find(".bom");
li.toggleClass("on");
dd.slideToggle();
other.removeClass("on");
otherDd.slideUp();
})
}
//自定义下拉
if ($(".mySelect").length) {
$(".mySelect").each(function () {
var s = $(this);
var z = parseInt(s.css("z-index"));
var dt = $(this).children(".show");
var dd = $(this).children(".drapList");
var _show = function () {
dd.slideDown(300);
s.css("z-index", z + 1);
dt.addClass("on");
dt.parent(".mySelect").addClass("on");
}; //展开效果
var _hide = function () {
dd.slideUp(300);
s.css("z-index", z);
dt.removeClass("on");
dt.parent(".mySelect").removeClass("on");
}; //关闭效果
dt.click(function () {
dd.is(":hidden") ? _show() : _hide();
});
dd.on("click", "li", function () {
dt.children("em").html($(this).text());
var _id = $(this).data("id");
var _par = $(this).parents(".mySelect");
_par.find(".show").attr("data-id", _id);
_hide();
})
$("body").click(function (i) {
!$(i.target).parents(".mySelect").first().is(s) ? _hide() : "";
});
});
}
// wow.js
if ($(".wow").length) {
if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))) {
var wow = new WOW({
boxClass: 'wow',
animateClass: 'animated',
offset: 50,
mobile: true,
live: true
});
wow.init();
};
}
submit("quote")
function submit(name = '*') {
layui.use(['layer', 'form'], function () {
var form = layui.form;
var layer = layui.layer;
form.on("submit(" + name + ")", function (data) {
var index = layer.load();
let params = data.field;
$.post("/addons/cms/diyform/post", params, function (res) {
layer.close(index);
if (res.code == 1) {
layer.alert(res.msg, { title: false, closeBtn: false,skin:"popup-layer" }, function () {
layer.closeAll()
location.href = '/'
});
} else {
layer.msg(res.msg)
$("input[name=__token__").val(res.data.__token__)
}
})
})
})
}
})
// 阻止冒泡
function stopPropagation(e) {
e = window.event || e;
if (document.all) { // IE
e.cancelBubble = true;
} else {
e.stopPropagation();
}
}
if (!!window.ActiveXObject || "ActiveXObject" in window) {
$("html").addClass("body_ie");
// $("script[src='/build/luxy.js']").remove();
// console.log('is IE');
} else {
// luxy.init();
// console.log('is not IE');
}