// 动画初始化
if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))) {
AOS.init({
offset: 0,
duration: 700,
easing: 'ease-in-sine',
// delay: 100,
once:true
});
};
let samt = 0;
window.addEventListener('scroll', function() {
samt <= 10 ? samt++ : AOS.refresh();
});
$(document).ready(function ($) {
var _winw = $(window).width();
// 手机导航
$('.menuBtn').append('');
$('.menuBtn').click(function (event) {
$(this).toggleClass('open');
$('.hd-r').stop().slideToggle();
});
if (_winw > 1200) {
$('.nav li').hover(function () {
$(this).addClass('ok');
if ($(this).find('.sub').length) {
$(this).find('.sub').stop().slideDown();
}
if ($(this).find('.sub2').length) {
$(this).find('.sub2').stop().slideDown();
}
}, function () {
$(this).removeClass('ok');
$(this).find('.sub').stop().slideUp();
$(this).find('.sub2').stop().slideUp();
});
} else {
$('.nav li').unbind('mouseenter mouseleave')
$('.nav .v1').click(function () {
if ($(this).siblings('.sub').length) {
$(this).attr('href', 'javascript:;');
$(this).siblings('.sub').stop().slideToggle().parents('li').toggleClass('on').siblings('li').removeClass('on').find('.sub').stop().slideUp();
}
if ($(this).siblings('.sub2').length) {
$(this).attr('href', 'javascript:;');
$(this).siblings('.sub2').stop().slideToggle().parents('li').toggleClass('on').siblings('li').removeClass('on').find('.sub2').stop().slideUp();
}
});
}
$('.main .col-l .name i').click(function(event) {
$('.ul-snav').slideToggle();
});
$('.ul-snav li i').click(function() {
$(this).parents('li').toggleClass('hover').siblings('li').stop().removeClass('hover');
$(this).toggleClass('on');
if ($(this).siblings('.sub').length) {
$(this).parents('li').siblings('li').find('.sub').stop().slideUp();
$(this).parents('li').siblings('li').find('i').stop().removeClass('on')
$(this).siblings('.sub').stop().slideToggle();
return false;
}
});
// 全屏底部
function positionFooter () {
var footer = $(".footer");
if ((($(document.body).height() + footer.outerHeight()) < $(window).height() && footer.css("position") == "fixed") || ($(document.body).height() < $(window).height() && footer.css("position") != "fixed")) {
footer.css({
position: "fixed",
bottom: "0",
width: '100%'
});
} else {
footer.css({
position: "static"
});
}
}
function stickFooter () {
$(window).scroll(positionFooter).load(positionFooter).resize(positionFooter);
}
// stickFooter();
// 选项卡 鼠标点击
$(".TAB_CLICK li").click(function () {
var tab = $(this).parent(".TAB_CLICK");
var con = tab.attr("id");
var on = tab.find("li").index(this);
$(this).addClass('on').siblings(tab.find("li")).removeClass('on');
$(con).eq(on).show().siblings(con).hide();
});
$('.TAB_CLICK').each(function (index, el) {
if ($(this).find('li.on').length) {
$(this).find("li.on").trigger('click');
} else {
$(this).find("li").filter(':first').trigger('click');
}
});
$(".TAB_CLICK1 li").click(function () {
var tab = $(this).parent(".TAB_CLICK1");
var con = tab.attr("id");
var on = tab.find("li").index(this);
$(this).addClass('on').siblings(tab.find("li")).removeClass('on');
$(con).eq(on).addClass('show').siblings(con).removeClass('show')
});
$('.TAB_CLICK1').each(function (index, el) {
if ($(this).find('li.on').length) {
$(this).find("li.on").trigger('click');
} else {
$(this).find("li").filter(':first').trigger('click');
}
});
// 选项卡 鼠标经过
$(".TAB_HOVER li").mouseenter(function () {
var tab = $(this).parent(".TAB_HOVER");
var con = tab.attr("id");
var on = tab.find("li").index(this);
$(this).addClass('on').siblings(tab.find("li")).removeClass('on');
$(con).eq(on).show().siblings(con).hide();
});
$('.TAB_HOVER').each(function (index, el) {
if ($(this).find('li.on').length) {
$(this).find("li.on").trigger('mouseenter');
} else {
$(this).find("li").filter(':first').trigger('mouseenter');
}
});
/**单选多选 */
$('[role=radio]').each(function () {
var input = $(this).find('input[type="radio"]'),
label = $(this).find('label');
input.each(function () {
if ($(this).attr('checked')) {
$(this).parents('label').addClass('checked');
$(this).prop("checked", true)
}
})
input.change(function () {
label.removeClass('checked');
$(this).parents('label').addClass('checked');
input.removeAttr('checked');
$(this).prop("checked", true)
})
});
$('[role=checkbox]').each(function () {
var input = $(this).find('input[type="checkbox"]');
input.each(function () {
if ($(this).attr('checked')) {
$(this).parents('label').addClass('checked');
$(this).prop("checked", true);
}
});
input.change(function () {
$(this).parents('label').toggleClass('checked');
});
});
/**单选多选end */
// 返回顶部
$('.g-backtop').click(function (e) {
e.stopPropagation();
$("body,html").animate({
scrollTop: 0
},
500);
});
// 头部动态加类
var header = $('.header'),
headerH = header.height(),
initScrh = $(window).scrollTop();
function changeHeader (scrH) {
if (_winw > 1200) {
if (scrH > headerH) {
header.addClass('fixed');
} else {
header.removeClass('fixed');
}
}
}
changeHeader(initScrh);
$(window).on('scroll', function () {
var _scrH = $(window).scrollTop();
changeHeader(_scrH);
});
// 点击展开某子元素
/* var subLi = $('.m-zpinfo li');
subLi.click(function (e) {
subLi.not(this).removeClass('on').find('.con').stop().slideUp();
$(this).toggleClass('on').find('.con').stop().slideToggle();
e.stopPropagation();
}); */
// subLi.filter(':first').trigger('click');
// 弹窗
$('.myfancy').click(function (e) {
e.stopPropagation();
var _win = $(this).attr('href');
$(_win).fadeIn();
});
$('.pop-bg,.m-pop .close').click(function (e) {
e.stopPropagation();
$('.m-pop').fadeOut();
});
// 头部下拉
$('.hd-link .sel').click(function () {
$(this).toggleClass('on').find('.sub').stop().slideToggle();
$(this).siblings('.sel').removeClass('on').find('.sub').stop().slideUp();
});
// pc
var scrollFunc = function (e) {
e = e || window.event;
var _hh = $('.header').height()
if (e.wheelDelta) { //判断浏览器IE,谷歌滑轮事件
if (e.wheelDelta > 0) { //当滑轮向上滚动时showNav();
$('.header').removeClass('hide');
$('.ul-tipsl.fixed').css('top', _hh);
}
if (e.wheelDelta < 0) {
//当滑轮向下滚动时
$('.header').addClass('hide')
$('.ul-tipsl.fixed').css('top', '0');
}
} else if (e.detail) { //Firefox滑轮事件 在火狐中e.detail为负值时是向上滚动,正值是向下滚动
if (e.detail < 0) { //当滑轮向上滚动时
$('.header').removeClass('hide')
$('.ul-tipsl.fixed').css('top', _hh);
}
if (e.detail > 0) { //当滑轮向下滚动时
$('.header').addClass('hide')
$('.ul-tipsl.fixed').css('top', '0');
}
}
}
var _winw = $(window).width();
if (_winw > 1200) {
//给页面绑定滑轮滚动事件
if (document.addEventListener) { //firefox
document.addEventListener('DOMMouseScroll', scrollFunc, false);
} //滚动滑轮触发scrollFunc方法 //ie 谷歌
window.onmousewheel = document.onmousewheel = scrollFunc;
}
// 头部二级导航切换
$(".hd-tablist .tab").mouseenter(function () {
var tab = $(this).parent(".hd-tablist");
var con = tab.attr("id");
var on = tab.find(".tab").index(this);
$(this).addClass('on').siblings(tab.find(".tab")).removeClass('on');
$(con).eq(on).show().siblings(con).hide();
});
$('.hd-tablist').each(function (index, el) {
if ($(this).find('.tab.on').length) {
var on=$(this).find('.tab.on').index();
var con = $(this).attr("id");
$(con).eq(on).show().siblings(con).hide();
} else {
var on=$(this).find(".tab").filter(':first').index();
var con = $(this).attr("id");
$(con).eq(on).show().siblings(con).hide();
}
});
// 页面锚点
function GetQueryString (name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return decodeURIComponent(r[2]);
return null;
}
// 调用方式
var model = GetQueryString("model")
if (model) {
var scrt = $('#model').offset().top;
$("body,html").animate({
scrollTop: scrt
},
200);
}
// 新闻详情是否有右侧
if($('.m-news-detailsl').length>0){
var isR = $('.m-news-detailsl .wp>.col-r').length
if(isR){
}else{
$('.m-news-detailsl').addClass('sty1')
}
}
});