$(function() {
wowInt()
findTel()
phoneTargetSelf()
nav()
pro_slide()
plat_slide()
tc_box()
//页面滚动
$(window).scroll(function() {
if ($(window).scrollTop() > 0) {
$('body').addClass('scroll-header')
} else {
$('body').removeClass('scroll-header')
}
})
$('.product-part .b_box .txt .inner').mCustomScrollbar()
$('.plat-part03 .txt p').mCustomScrollbar()
$('.changs-part01 dd .c').mCustomScrollbar()
//首页banner可以带视频效果
$(window).resize();
var mySwiper = new Swiper('.banner .swiper-container',{
pagination : '.banner .swiper-pagination',
//grabCursor: true,
paginationClickable: true,
autoplay:5000,
speed:1000,
loop: true,
autoplayDisableOnInteraction : false,
onInit: function(swiper){
swiperAnimateCache(swiper);
swiperAnimate(swiper);
},
onSlideChangeEnd: function(swiper){
swiperAnimate(swiper);
var _this = $('.banner .swiper-slide').eq(swiper.activeIndex);
if($(window).width()>767){
videoSelect(_this);
}
}
})
if($(window).width()>767){
videoSelect($('.banner .swiper-slide.swiper-slide-active'));
}
function videoSelect(_this){
var flag = true;
var cc = _this.hasClass('ban_video');
if(cc){
mySwiper.stopAutoplay();
var videos =
'';
_this.append(videos);
var aaa = setInterval(function(){
if(!isNaN($(".vv").get(0).duration)&&flag){
clearInterval(aaa);
flag=false;
setTimeout(function(){
_this.find('video').css("display","block");
},500)
}
},10);
_this.find('video').bind('ended',function () {
mySwiper.slideNext();
mySwiper.startAutoplay();
});
}else{
$('.vv').remove();
}
}
//首页banner end
//--------------tab-box
$('.tab-box .tab-a').each(function() {
$(this).click(function() {
if (!$(this).hasClass('off')) {
$(this)
.addClass('on')
.siblings()
.removeClass('on')
var ii = $(this).index()
$.getScript('../js/ratio-img.js')
$(this)
.parents('.tab-box')
.find('.tab-b')
.eq(ii)
.show()
.siblings()
.hide()
}
})
})
$('.tab-box').each(function(i) {
$(this)
.find('.tab-a:eq(0)')
.click()
})
//end
//微信
$('.wechat').click(function() {
var url = $(this).data('img')
var title = ''
title += "
"
title += "
x"
title += '
微信二维码
'
title +=
"
"
title += '
扫一扫
'
title += '
'
$('body').remove('.weixin')
$('body').append(title)
//var op="http://service.weibo.com/share/share.php?url='"+ url +"'&title='"+ title +"'&searchPic=false"
//window.open(op)
})
$(document).on('click', '.weixin-box .c', function() {
$('.weixin-box').remove()
})
//end
//七条生产线切换
var slide_boxSwiper = new Swiper('.slide_box .swiper-container', {
slidesPerView: 4,
spaceBetween: 0,
prevButton: '.slide_box .swiper-button-prev',
nextButton: '.slide_box .swiper-button-next',
breakpoints: {
1023: {
slidesPerView: 3
},
767: {
slidesPerView: 1
}
}
})
//产品页左边图片切换
var slide_proSwiper = new Swiper('.product-part .swiper-container', {
pagination: '.product-part .swiper-pagination',
paginationClickable: true,
speed: 1000
})
if ($('.product-part .swiper-slide').size() <= 1) {
$('.product-part .swiper-pagination').hide()
}
//公司生产辅助配套设施齐全--手机端
if ($(window).width() < 767) {
var slide_boxSwiper = new Swiper('.company-part04 .swiper-container', {
slidesPerView: 1,
spaceBetween: 0,
prevButton: '.company-part04 .swiper-button-prev',
nextButton: '.company-part04 .swiper-button-next'
})
}
//招贤纳士
$('.join li')
.eq(0)
.addClass('on')
$('.join li .tit').click(function() {
if (
$(this)
.parent('li')
.hasClass('on')
) {
$(this)
.parent('li')
.removeClass('on')
} else {
$(this)
.parent('li')
.addClass('on')
}
})
if ($(window).width() < 768) {
$(document).on('click', '.infoBox>img', function() {
console
log(1)
$('.infoBox').hide()
})
}
})
function tc_box() {
$('.proj-part02 .btn').click(function() {
$('.layer_bg,.layer_wrap').show()
})
$('.layer_wrap .bon_box a.btn_01').click(function() {
$('.layer_bg,.layer_wrap').hide()
})
}
function pro_slide() {
var _ind = 0
var _len = $('.s_box .img .swiper-slide').length
var proSwiper = new Swiper('.s_box .img .swiper-container', {
slidesPerView: 5,
spaceBetween: 0,
prevButton: '.s_box .img .swiper-button-prev',
nextButton: '.s_box .img .swiper-button-next',
observer: true, //修改swiper自己或子元素时,自动初始化swiper
observeParents: true, //修改swiper的父元素时,自动初始化swiper
breakpoints: {
1024: {
slidesPerView: 4
},
768: {
slidesPerView: 3
}
}
})
$('.s_box .img .swiper-button-prev').addClass('disabled')
$('.s_box .img .swiper-button-prev').click(function() {
_ind--
$('.s_box .img .swiper-button-next').removeClass('disabled')
if (_ind <= 0) {
$(this).addClass('disabled')
_ind = 0
} else {
$(this).removeClass('disabled')
}
$('.s_box .img .swiper-slide')
.eq(_ind)
.addClass('on')
.siblings()
.removeClass('on')
$('.b_box .img ul li')
.eq(_ind)
.show()
.siblings()
.hide()
$('.b_box .txt ul li')
.eq(_ind)
.show()
.siblings()
.hide()
$('.s_box .txt ul li')
.eq(_ind == 0 ? 1 : _ind)
.show()
.siblings()
.hide()
})
$('.s_box .img .swiper-button-next').click(function() {
_ind++
$('.s_box .img .swiper-button-prev').removeClass('disabled')
if (_ind >= _len - 1) {
$(this).addClass('disabled')
_ind = _len - 1
} else {
$(this).removeClass('disabled')
}
$('.s_box .img .swiper-slide')
.eq(_ind)
.addClass('on')
.siblings()
.removeClass('on')
$('.b_box .img ul li')
.eq(_ind)
.show()
.siblings()
.hide()
$('.b_box .txt ul li')
.eq(_ind)
.show()
.siblings()
.hide()
$('.s_box .txt ul li')
.eq(_ind == _len - 1 ? 0:_ind + 1)
.show()
.siblings()
.hide()
console.log(333,_ind)
})
$('.s_box .img .swiper-slide:eq(0)').click()
$('.s_box .img .swiper-slide').click(function() {
$(this)
.addClass('on')
.siblings()
.removeClass('on')
_ind = $(this).index()
$('.b_box .img ul li')
.eq(_ind)
.show()
.siblings()
.hide()
$('.b_box .txt ul li')
.eq(_ind)
.show()
.siblings()
.hide()
$('.s_box .txt ul li')
.eq(_ind == _len - 1 ? 0:_ind + 1)
.show()
.siblings()
.hide()
})
}
function plat_slide() {
if ($('.slider_plat').length > 0) {
if ($(window).width() > 767) {
var mySwiper_hum_p01 = new Swiper('.slider_plat .swiper-container', {
loop: true,
loopAdditionalSlides: 1,
autoplay: false,
effect: 'coverflow',
slidesPerView: 2,
centeredSlides: true,
prevButton: '.slider_plat .swiper-button-prev',
nextButton: '.slider_plat .swiper-button-next',
autoplayDisableOnInteraction: false,
coverflow: {
rotate: 0,
stretch: 0,
depth: 0,
modifier: 2,
slideShadows: true
},
breakpoints: {
767: {
slidesPerView: 1
}
}
})
} else {
var mySwiper_hum_p01 = new Swiper('.slider_plat .swiper-container', {
loop: true,
pagination: '.swiper-pagination',
paginationClickable: true,
autoplayDisableOnInteraction: false,
slidesPerView: 1,
prevButton: '.slider_plat .swiper-button-prev',
nextButton: '.slider_plat .swiper-button-next'
})
}
}
}
function textReplace(){
}
//主导航
function nav() {
if ($(window).width() > 1024) {
search()
$(document).click(function() {
$('.search_wrap').slideUp(200)
$('.head_search').removeClass('on')
})
$('.nav>ul>li').hover(
function() {
$(this)
.find('.navlist')
.stop()
.slideDown()
},
function() {
$(this)
.find('.navlist')
.stop()
.slideUp()
}
)
} else {
$('.navlist')
.siblings('span')
.addClass('cur')
$(document).on('click', '.nav_phone_btn', function() {
$('.nav_phone_btn').toggleClass('visible_nav')
$('body').toggleClass('body_nav_phone')
})
$('.nav>ul>li>span').click(function() {
$(this)
.parent('li')
.siblings()
.find('span')
.removeClass('on')
$(this)
.parent('li')
.siblings()
.find('.navlist')
.slideUp()
$(this).toggleClass('on')
$(this)
.siblings('.navlist')
.slideToggle()
})
}
}
function search() {
$('.head_search').click(function(e) {
e.preventDefault()
e.stopPropagation()
$(this).toggleClass('on')
$('.search_wrap').slideToggle(200)
})
$('.search_box_text').click(function(e) {
e.preventDefault()
e.stopPropagation()
})
}
//数字滚动
function digitInt(targetId, speed, trigger) {
if ($(targetId).length > 0) {
var count_add = 0
var addTimer = null
var count = $(targetId)
if ($(window).width() > 1023) {
if (trigger == null) {
trigger = true
}
if (trigger == true) {
if (!count.get(0).getAttribute('digitTriggle')) {
addTimer = setInterval(function() {
count_add += Math.floor(Math.random() * speed)
if (count_add >= Number(count.attr('rel'))) {
count.text(addCommas(Number(count.attr('rel'))))
clearInterval(addTimer)
} else {
count.text(addCommas(count_add))
}
}, 10)
}
count.get(0).setAttribute('digitTriggle', true)
}
} else {
count.text(Number(count.attr('rel')))
}
}
}
function addCommas(nStr) {
nStr += ''
var x = nStr.split('.')
var x1 = x[0]
var x2 = x.length > 1 ? '.' + x[1] : ''
var rgx = /(\d+)(\d{3})/
// while (rgx.test(x1)) {
// x1 = x1.replace(rgx, '$1' + ',' + '$2');
// }
return x1 + x2
}
$(window).scroll(function() {
digitInt('#in-count-1', 2, $('.digitbox dd').hasClass('animated'))
digitInt('#in-count-2', 800, $('.digitbox dd:eq(1)').hasClass('animated'))
digitInt('#in-count-3', 2, $('.digitbox dd:eq(2)').hasClass('animated'))
digitInt('#in-count-4', 2, $('.digitbox dd:eq(3)').hasClass('animated'))
digitInt('#in-count-5', 2, $('.digitbox dd:eq(4)').hasClass('animated'))
})
//ajax
/*function ProAjax(str,url){
$.ajax({
url:url,
success:function(msg){
$(str).html("");
$(str).append(msg)
}
});
}*/
//wow入场
function wowInt() {
if (!/msie [6|7|8|9]/i.test(navigator.userAgent)) {
var wow = new WOW({
boxClass: 'wow',
animateClass: 'animated',
offset: -100,
mobile: false,
live: true
})
wow.init()
}
}
/*手机端链接改为本窗口打开*/
function phoneTargetSelf(context) {
if ($(window).width() < 1024) {
if (context == undefined) {
context = $(document)
}
$('a', context).each(function() {
var target = $(this)
var link = target.attr('target')
target.attr('target', '_self')
})
}
}
/*电话链接取消默认事件并添加样式*/
function findTel(context) {
if ($(window).width() > 1024) {
var condition = /^tel\:([0-9\-]+)|tel\:\+([0-9\-]+)$/
if (context == undefined) {
context = $(document)
}
$('a', context).each(function(index, el) {
var target = $(this)
var href = target.attr('href')
if (condition.test(href)) {
target.addClass('tel_link')
target.on('click', function(event) {
event.preventDefault()
})
}
})
}
}