$(function () {
$('#header').load('header.html')
$('#footer').load('footer.html')
$('body').css('opacity', 1)
for (let i = 0; i < $('[data-type="wow"]').length; i++) {
if (!$('[data-type="wow"]').eq(i).hasClass('wow')) {
$('[data-type="wow"]').eq(i).addClass('wow fadeInUp')
}
}
var wowList = 0
var wow = new WOW({
boxClass: 'wow', // 需要执行动画的元素的 class
animateClass: 'animated', // animation.css 动画的 class
offset: 0, // 元素的位置露出后距离底部多少像素执行
mobile: true, // 是否在移动设备上执行动画
live: true, // 异步加载的内容是否有效
callback: function (e) {
if ($(e).attr('data-type') === 'wow') {
wowList += 100
$(e).css('animation-delay', wowList + 'ms')
}
}
})
wow.init()
setTimes()
var timeOuts = null
function setTimes() {
timeOuts = setTimeout(function () {
wowList = 0
}, 150)
}
/*****************************手机站导航切换按钮*******************************/
$('body').on('click', '.headerSJ .navbar', function (event) {
$(this).toggleClass('active unactive')
})
$('body').on('click', '.headerSJ .navbar.unactive', function (event) {
$('.headerSJ .navwrap').animate({
'right': '0',
'opacity': '1'
}, 500)
})
$('body').on('click', '.headerSJ .navbar.active', function (event) {
$('.headerSJ .navwrap').animate({
'right': '-100%',
'opacity': '0'
}, 500)
})
$('body').on('click', '.headerSJ .plus', function () { //二级栏目手风琴切换效果
$(this).toggleClass('minus').parent().siblings().find('.minus').removeClass('minus')
$(this).next('.SJbod').stop().slideToggle(300).parent().siblings().find('.SJbod').stop().slideUp(500)
})
var st = $(window).scrollTop()
$('.countup').each(function (index, el) {
var id = $(el).attr('id') || '_countup' + (new Date().getTime()) + $(el).index('.countup')
$(el).attr('id', id)
el.countOnOff = true
el.options = $(el).attr('options') ? JSON.parse($(el).attr('options')) : {
"separator": ""
}
el.num = new CountUp(id, 0, $(el).text(), 0, 5, el.options)
if (st > $(el).offset().top - $(window).height() + $(el).outerHeight() && el.countOnOff) {
el.num.start()
el.countOnOff = false
}
})
setTimeout(function () {
if (st > 0) {
$('.header').addClass('active')
} else {
$('.header').removeClass('active')
}
}, 100)
$(window).scroll(function () {
/*滚动时先清除上一个定时器,然后再设置新的定时器,以免出现多个定时器造成混乱*/
clearTimeout(timeOuts)
setTimes()
st = $(window).scrollTop()
$('.countup').each(function (index, el) {
if (st > $(el).offset().top - $(window).height() + $(el).outerHeight() && el.countOnOff) {
el.num.start()
el.countOnOff = false
}
})
if (st > 0) {
$('.header').addClass('active')
} else {
$('.header').removeClass('active')
}
})
// 优化a标签
$('a').each(function () {
if ($(this).attr('href') == '') {
$(this).attr('href', 'javascript:;')
} else if ($(this).attr('href') == undefined) {
$(this).css('cursor', 'pointer')
}
})
$('body').on('click', '.video_btn', function () {
$('.z_tanchuang').removeClass('out').addClass('one');
var src = $(this).attr('data-src');
$('html').addClass('act');
$(".z_tanchuang video").attr({src: src}).trigger('play');
});
$('.z_tanchuang .out').on('click',function(){
$('.z_tanchuang').addClass('out');
$('html').removeClass('act');
$(".z_tanchuang video").trigger('pause');
});
$('body').on('mouseenter', '.header_nav > li', function () {
$(this).children('.header_nav1, .header_nav2, .header_nav3, .header_nav4').stop().fadeIn(100)
$(this).siblings().children('.header_nav1, .header_nav2, .header_nav3, .header_nav4').hide()
$(this).addClass('on').siblings('.active').addClass('unactive').removeClass('active')
})
$('body').on('mouseleave', '.header_nav > li', function () {
$(this).children('.header_nav1, .header_nav2, .header_nav3, .header_nav4').stop().fadeOut(100)
$(this).removeClass('on').siblings('.unactive').addClass('active').removeClass('unactive')
})
var navI = $('body').data('index')
setTimeout(function () {
$('.header_nav li').eq(navI).addClass('active').siblings().removeClass('active')
}, 100)
$('body').on('click', '.header_search .img', function () {
var keyword = $('#keyword').val()
if (keyword) {
window.location.href = 'result.html?keyword=' + keyword
}
})
$('body').on('keyup', '#keyword', function (e) {
var keyword = $('#keyword').val()
if (e.keyCode === 13 && keyword) {
if (keyword) {
window.location.href = 'result.html?keyword=' + keyword
}
}
})
$('body').on('click', '.header_search_m .img', function () {
var keyword = $('[name="keywordm"]').val()
console.log(keyword)
if (keyword) {
window.location.href = 'result.html?keyword=' + keyword
}
})
$('.item_chat').on('click', function () {
$('#chat').show()
})
$('#chat .close').on('click', function () {
$('#chat').hide()
})
})