jQuery(document).ready(function($) {
var PC = $(window).width() > 1024,
mobile = $(window).width() <= 768,
winWidth = $(window).width(),
winHeight = $(window).height();
$('.count').length && $('.count').countUp();
$(window).load(function () {
$('html').addClass('dom-loaded');
})
if(PC){
$(window).scroll(function(){
$(window).scrollTop() > 10 ? $('.header').addClass('down') : $('.header').removeClass('down')
$(window).scrollTop() > 10 ? $('.head-nav').addClass('down') : $('.head-nav').removeClass('down')
})
}else{
$('.header').append(
'
'
);
$('.header .mNavBtn').click(function () {
$(this).toggleClass('active');
$('.m-navbox').toggleClass('active');
});
$('.m-navbox li').each(function () {
if ($(this).find('ul').length) {
$(this).children('.line').append('')
}
})
$('.m-navbox ul li.menu-1-li .line-1 i, .m-navbox ul li.menu-1-li .line-1 a').click(function(){
var _par = $(this).parents('li.menu-1-li');
if (!_par.hasClass('active')) {
_par.addClass('active').siblings().removeClass('active'), _par.siblings().children('ul').slideUp(), _par.children('ul').slideDown();
} else {
_par.removeClass('active').children('ul').slideUp();
}
})
$('.m-navbox ul li.menu-2-li .line-2 i, .m-navbox ul li.menu-2-li .line-2 a').click(function(){
var _par = $(this).parents('li.menu-2-li');
if (!_par.hasClass('active')) {
_par.addClass('active').siblings().removeClass('active'), _par.siblings().children('ul').slideUp(), _par.children('ul').slideDown();
} else {
_par.removeClass('active').children('ul').slideUp();
}
})
$('.m-navbox ul li.menu-3-li .line-3 i, .m-navbox ul li.menu-3-li .line-3 a').click(function(){
var _par = $(this).parents('li.menu-3-li');
if (!_par.hasClass('active')) {
_par.addClass('active').siblings().removeClass('active'), _par.siblings().children('ul').slideUp(), _par.children('ul').slideDown();
} else {
_par.removeClass('active').children('ul').slideUp();
}
})
}
$('.header .nav li').mouseenter(function(){
if($(this).hasClass('menu')){
$(this).addClass('hover').siblings().removeClass('hover')
$('.head-nav').eq($(this).index() - 1).show();
if(($(this).index() - 1)==1){
$('.head-nav').eq(0).hide();
}else{
$('.head-nav').eq(1).hide();
}
}else{
$('.header .nav li').removeClass('hover')
$('.head-nav').hide();
}
})
$('.head-nav .main').mouseleave(function(){
$('.header .nav li').removeClass('hover')
$('.head-nav').hide();
})
$('.head-nav .left-box a').mouseenter(function(){
$(this).addClass('active').siblings().removeClass('active'), $(this).parents('.block').find('.right-box .child').eq($(this).index()).addClass('active').siblings().removeClass('active')
})
$('.header .search').click(function () {
$('.head-search').fadeIn();
})
$('.head-search .close').click(function () {
$('.head-search').fadeOut();
})
$('.head-search button').click(function () {
var _this = $('.head-search input[type="text"]');
var _val = _this.val();
val = $.trim(_val);
if (val == "") {
alert("璇疯緭鍏ュ叧閿瓧");
return false;
}
})
$('.fixed-right-box .top').click(function(){
$('html,body').animate({
scrollTop: 0
}, 500)
})
function indexInit(){
// banner
if(PC){
if($('.home-banner-1 .item ').length){
if ($('.home-banner-1').width() / $('.home-banner-1').height() > 1.78) {
$(".home-banner-1 .item video").css({
'width': '100%',
'height': 'auto '
});
} else {
$(".home-banner-1 .item ").css({
'height': '100%',
'width': 'auto'
});
}
}
}else{
if($('.home-banner-1 .item ').length){
$('.home-banner-1 .item ').parents('.item').remove();
}
}
var bannerSwiper = new Swiper('.home-banner-1 .items', {
speed: 800,
loop: true,
simulateTouch: false,
navigation: {
prevEl: '.home-banner-1 .button-prev',
nextEl: '.home-banner-1 .button-next',
},
autoplay:true,
autoplay: {
delay: 5000,
stopOnLastSlide: false,
disableOnInteraction: true,
},
pagination: {
el: '.home-banner-1 .pagination',
clickable: true,
renderBullet: function (index, className) {
return '';
},
bulletClass : 'default',
bulletActiveClass: 'active',
},
});
}
$('.home-main').length && indexInit();
function newsListInit(){
// section1
var swiper1 = new Swiper('.news-list-s1 .items', {
speed: 800,
simulateTouch: false,
navigation: {
prevEl: '.news-list-s1 .button-prev',
nextEl: '.news-list-s1 .button-next',
},
pagination: {
el: '.news-list-s1 .pagination',
clickable: true,
renderBullet: function (index, className) {
return '';
},
bulletClass : 'default',
bulletActiveClass: 'active',
},
});
}
$('.news-list').length && newsListInit();
function industryPageInit(){
// detail-nav
if(!mobile){
$('.industry-detail-crumbs .left-box a').click(function () {
$('html,body').animate({
scrollTop: $('.detail-direction .section').eq($(this).index()).offset().top - 120
}, 300)
})
$(window).scroll(function () {
$('.detail-direction .section').each(function () {
if ($(window).scrollTop() > $(this).offset().top - $(window).height() / 2) {
$('.industry-detail-crumbs .left-box a').eq($(this).index()).addClass('active').siblings().removeClass('active');
}
})
})
}
if(!mobile){
$('.c-crumbs .right-box a').click(function () {
$('html,body').animate({
scrollTop: $('.page-direction .section').eq($(this).index()).offset().top - 120
}, 300)
})
$(window).scroll(function () {
$('.page-direction .section').each(function () {
if ($(window).scrollTop() > $(this).offset().top - $(window).height() / 2) {
$('.c-crumbs .right-box a').eq($(this).index()).addClass('active').siblings().removeClass('active');
}
})
})
}
}
})