 /*
 ** Write by 李露露 lilulu/Lucy Lee QQ/WeChat：984788308  Tel：15264105329
 */

$(window).scroll(function(){
    //获取滚动条滚动的位置
    var top = $(window).scrollTop();
    if(top > 20){
        $('.q_header').addClass("q_header_fixed");
        $('.sp_header').addClass("sp_header_fixed");
    }
    else if(top <= 20){
        $('.q_header').removeClass("q_header_fixed");
        $('.sp_header').removeClass("sp_header_fixed");
    }
})


// q_nav_son start!
$(document).ready(function(){
    $('.q_nav ul>li').mouseover(function(){
      $(this).find('.q_nav_son').stop().slideDown(200);
    }).mouseleave(function(){
      $(this).find('.q_nav_son').stop().slideUp(0);
    });
    $('.q_nav ul>li').each(function(){
        var ishaveli = $(this).find('.q_nav_son>li');
        if(ishaveli.length == 0){
            $(this).find('.q_nav_son').css('padding','0');
        }
    });
});
// q_nav_son end!

// q_banner  start!
$(document).ready(function(){
	// swiper 里面如果添加了视频播放插件 需要去掉 循环效果
	var swiper = new Swiper('.swiper_banner', {
		// effect: 'fade',
		slidesPerView: 1,
		spaceBetween: 0,
		autoplay: {
			delay: 4000,
			stopOnLastSlide: false,
			disableOnInteraction: false,
		},
		speed:400,
		loop: true,
		pagination: {
			el: '.swiper_pagination_banner',
			clickable: true,
		},
		navigation: {
			nextEl: '.swiper_button_banner_next',
			prevEl: '.swiper_button_banner_prev',
		},

		centeredSlides: true, // 当前选中项 居中显示
	});
});
// q_banner  end!

//  sp_header  start!
$(function () {
    var windoww = $(window).width();
    $('.sp_nav').click(function () {
      $('.sp_nav').toggleClass('sp_nav_se');
      $('.sjj_nav').toggleClass('nav_show');
    });

    $('.sjj_nav ul li i').click(function () {
      $(this).parent().children('ul').slideToggle().parent().siblings().children('ul').slideUp();
      $(this).toggleClass('sjj_nav_i_se');
      $(this).parent().siblings().find('i').removeClass('sjj_nav_i_se');
    });

    $('.sp_nav_xjb').html('<svg t="1496193951932" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="995" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"> <path d="M768.468 428.876l-84.723-84.723-170.711 170.711-170.711-170.711-84.723 84.723 170.711 170.711-0.092 0.091 84.723 84.724 0.092-0.092 0.092 0.092 84.723-84.724-0.092-0.091z" p-id="996"></path></svg>');

    $('.sjj_nav>ul>li').each(function(){
        var ishaveli = $(this).find('ul>li');
        if(ishaveli.length == 0){
            $(this).find('.sp_nav_xjb').css('display','none');
        }
    });

});
//  sp_header  end!

//  q_alert  start!
function q_alert(message){
	$('#q_alert .q_form_h_small').html(message);
	$('#q_alert').stop().fadeIn(200);
}
$('#q_alert_button').click(function(){
	$('#q_alert').stop().fadeOut(200);
});

// 立即查询 点击 响应事件
$('#q_button').click(function(){
	$('#q_form').stop().fadeIn(200);
});

// page-index-all
$('.q_form_mask').click(function(){
	$('#q_form').stop().fadeOut(200);
	$('#q_alert').stop().fadeOut(200);
});
$('.q_form_close').click(function(){
	$('#q_form').stop().fadeOut(200);
	$('#q_alert').stop().fadeOut(200);
});
//  q_alert  end!

// q_sample  start!

$(document).ready(function () {
    $('.parts-w .col').hover(function () {
        if (window.innerWidth > 640) {
            $('.parts-w .col').addClass('collapse');
            $(this).removeClass('collapse').addClass('expand')
        } else {
            $('.parts-w .col').removeClass('expand').removeClass('collapse');
        }

    }, function () {
        $('.parts-w .col').removeClass('expand').removeClass('collapse');
    });
});

// q_sample  start!

// q_case  start!
$(document).ready(function(){
    var swiper = new Swiper('.swiper_case', {
        slidesPerView: 2,
        spaceBetween: 15,
        autoplay: {
            delay: 4000,
            stopOnLastSlide: false,
            disableOnInteraction: false,
        },
        speed:400,
        loop: true,
        pagination: {
            el: '.swiper_pagination_case',
            clickable: true,
        },
        navigation: {
            nextEl: '.swiper_button_case_next',
            prevEl: '.swiper_button_case_prev',
        },
        breakpoints: {
            641: {  //当屏幕宽度大于等于640
              slidesPerView: 4,
              spaceBetween: 25
            },
        },

    });
});
// q_case  end!

//  q_number start!
$(document).ready(function(){
    //窗口显示才加载
    var wrapTop = $(".digital").offset().top;
    var istrue = true;
    $(window).on("scroll",
    function() {
        var s = $(window).scrollTop();
        if (s > wrapTop - 650 && istrue) {
            $(".timer").each(count);
            function count(a) {
                var b = $(this);
                a = $.extend({},
                a || {},
                b.data("countToOptions") || {});
                b.countTo(a)
            };
            istrue = false;
        };
    })
    //设置计数
    $.fn.countTo = function (options) {
        options = options || {};
        return $(this).each(function () {
            //当前元素的选项
            var settings = $.extend({}, $.fn.countTo.defaults, {
                from:            $(this).data('from'),
                to:              $(this).data('to'),
                speed:           $(this).data('speed'),
                refreshInterval: $(this).data('refresh-interval'),
                decimals:        $(this).data('decimals')
            }, options);
            //更新值
            var loops = Math.ceil(settings.speed / settings.refreshInterval),
                increment = (settings.to - settings.from) / loops;
            //更改应用和变量
            var self = this,
            $self = $(this),
            loopCount = 0,
            value = settings.from,
            data = $self.data('countTo') || {};
            $self.data('countTo', data);
            //如果有间断，找到并清除
            if (data.interval) {
                clearInterval(data.interval);
            };
            data.interval = setInterval(updateTimer, settings.refreshInterval);
            //初始化起始值
            render(value);
            function updateTimer() {
                value += increment;
                loopCount++;
                render(value);
                if (typeof(settings.onUpdate) == 'function') {
                    settings.onUpdate.call(self, value);
                }
                if (loopCount >= loops) {
                    //移出间隔
                    $self.removeData('countTo');
                    clearInterval(data.interval);
                    value = settings.to;
                    if (typeof(settings.onComplete) == 'function') {
                        settings.onComplete.call(self, value);
                    }
                }
            }
            function render(value) {
                var formattedValue = settings.formatter.call(self, value, settings);
                $self.html(formattedValue);
            }
        });
    };
    $.fn.countTo.defaults={
        from:0,               //数字开始的值
        to:0,                 //数字结束的值
        speed:1000,           //设置步长的时间
        refreshInterval:100,  //隔间值
        decimals:0,           //显示小位数
        formatter: formatter, //渲染之前格式化
        onUpdate:null,        //每次更新前的回调方法
        onComplete:null       //完成更新的回调方法
    };
    function formatter(value, settings){
        return value.toFixed(settings.decimals);
    }
    //自定义格式
    $('#count-number').data('countToOptions',{
        formmatter:function(value, options){
            return value.toFixed(options.decimals).replace(/\B(?=(?:\d{3})+(?!\d))/g, ',');
        }
    });
    //定时器
    $('.timer').each(count);
    function count(options){
        var $this=$(this);
        options=$.extend({}, options||{}, $this.data('countToOptions')||{});
        $this.countTo(options);
    }
});
//  q_number end!

// q_n_honor  start!
$(document).ready(function(){
    var swiper = new Swiper('.swiper_honor', {
        slidesPerView: 2,
        spaceBetween: 10,
        autoplay: {
            delay: 4000,
            stopOnLastSlide: false,
            disableOnInteraction: false,
        },
        speed:400,
        loop: true,
        navigation: {
            nextEl: '.swiper_button_honor_next',
            prevEl: '.swiper_button_honor_prev',
        },
        breakpoints: {
            641: {  //当屏幕宽度大于等于640
              slidesPerView: 4,
              spaceBetween: 30
            },
        },

    });
});
// q_n_honor  end!


// q_n_product  end!
$(document).ready(function(){

    var galleryThumbs = new Swiper('.cont_pic_thumbs', {
        spaceBetween: 10,
        slidesPerView: 2,
        // loop: true,
        freeMode: true,
        // loopedSlides: 1, //looped slides should be the same
        watchSlidesVisibility: true,
        watchSlidesProgress: true,
        breakpoints: {
            641: {  //当屏幕宽度大于等于640
              slidesPerView: 4,
              spaceBetween: 10
            },
        },
    });
    var galleryTop = new Swiper('.cont_pic_top', {
        spaceBetween: 0,
        // loop:true,
        // loopedSlides: 1, //looped slides should be the same
        thumbs: {
            swiper: galleryThumbs,
        },
        navigation: {
            nextEl: '.swiper_button_cont_pic_next',
            prevEl: '.swiper_button_cont_pic_prev',
        },
    });
});
// q_n_product  end!



// q_footer_weixin start!
$(document).ready(function(){
    $('.q_footer_weixin').mouseover(function(){
      $(this).find('.q_footer_wx_div').stop().slideDown(200);
    }).mouseleave(function(){
      $(this).find('.q_footer_wx_div').stop().slideUp(0);
    });
});
// q_footer_weixin end!

$(document).ready(function(){
    $('.q_n_variety_fixed').click(function(){
        $(this).stop().fadeOut(200);
    });
    $('.variety_block_close').click(function(){
        $('.q_n_variety_fixed').stop().fadeOut(200);
    });
    $('.variety_block').click(function(){
        if(window.event){
            // IE下阻止冒泡
            event.cancelBubble = true;
        }else{
            event.stopPropagation();
        }
    });
    $('.variety_li').click(function(){
        $('.variety_block_img img').attr('src','');
        $('.variety_block_txt a').attr('href','');
        $('.variety_block_txt_h').html('');
        $('.variety_block_txt_p').html('');
        var variety_h = $(this).find('.variety_item_h').html();
        var variety_p = $(this).find('.variety_item_p').html();
        var variety_url = $(this).find('.variety_item_p').attr('data-url');
        var variety_src = $(this).find('.img').attr('data-src');
        $('.variety_block_img img').attr('src',variety_src);
        $('.variety_block_txt a').attr('href',variety_url);
        $('.variety_block_txt_h').html(variety_h);
        $('.variety_block_txt_p').html(variety_p);
        $('.q_n_variety_fixed').fadeIn(400);
    });

});

//  #top  start!
$(window).scroll(function(){
    //获取滚动条滚动的位置
    var top = $(window).scrollTop();
    if(top > 200){
        $('.q_aside_item4').fadeIn(500);
    }
    else if(top <= 200){
        $('.q_aside_item4').fadeOut(200);
    }
})
$(document).ready(function(){
    $("#top").click(function(event) {
        $("html,body").animate({scrollTop:'0px'},800);
    });
    $('.q_aside_item2').stop().mouseenter(function(){
        $(this).find('.q_aside_item_main').fadeIn(500);
    }).stop().mouseleave(function(){
        $(this).find('.q_aside_item_main').fadeOut(0);
    });
    $('.q_aside_item3').stop().mouseenter(function(){
        $(this).find('.weixin').fadeIn(500);
    }).stop().mouseleave(function(){
        $(this).find('.weixin').fadeOut(0);
    });
});
//  #top  end!

$(document).ready(function(){

});