$(function () {
    /*手机头部展开/关闭*/
    $('#navToggle').click(function () {
        $(this).toggleClass('active');
        if ($('.mobileMenu').hasClass('h-show')) {
            $('.mobileMenu').removeClass('h-show');
            $('.mobileMenu').fadeOut(function () { });
            $("body,html").removeClass("ovh-f");
        } else {
            $('.mobileMenu').fadeIn(function () {
                $('.mobileMenu').addClass('h-show');
                $("body,html").addClass("ovh-f");
            });
        }
        $(".menu li").each(function () {
            if ($(this).children().hasClass("menu_dl")) {
                $(this).addClass("menu_li");
            }
        })
    });
    $(".menu li").click(function () {
        $(this).toggleClass('on');
        $(this).find(".menu_dl").stop().slideToggle(500);
        $(this).siblings('li').removeClass("on");
        $(this).siblings().find(".menu_dl").stop().slideUp();
    });
    //二级导航
    $(".nav ul li").hover(function () {
        if ($(this).children().hasClass("nav-sub")) {
            $(this).find(".nav-sub").stop(true, false).slideDown();
        }
    }, function () {
        if ($(this).children().hasClass("nav-sub")) {
            $(this).find(".nav-sub").stop(true, false).slideUp();
        }
    })


    //大图
    var bannerSwiper = new Swiper('.banner-swiper', {
        loop: true,
        autoplay: {
            delay: 3500,
            disableOnInteraction: false,
        },
        pagination: {
            el: '.swiper-pagination',
            clickable: true,
        },
    });

    var hproSwiper = new Swiper('.hpro-swiper', {
        slidesPerView: 1,
        loop: true,
        navigation: {
            nextEl: '.hpro-next',
            prevEl: '.hpro-prev',
        },
    });

    hproSwiper.on('slideChange', function () {
        var index = this.realIndex;
        console.log(index);
        $(".hpro-imgs").find('.hpro-imgitem').eq(index).addClass("hpro-imgon").siblings().removeClass("hpro-imgon");
    });

    $(".adv-list li").hover(function () {
        $(this).addClass('on').siblings().removeClass('on');
        $(".adv-imgs").find('li').eq($(this).index()).addClass('active').siblings().removeClass('active');
    })
    $(".adv-list li").click(function () {
        $(this).addClass('on').siblings().removeClass('on');
        $(".adv-imgs").find('li').eq($(this).index()).addClass('active').siblings().removeClass('active');
    })


    //关于我们js
    var swiperHonor = new Swiper('.honor-swiper', {
        slidesPerView: 4,
        loop: true,
        autoplay: {
            delay: 3000,
            disableOnInteraction: false,
        },
        breakpoints: {
            221: {
                slidesPerView: 1,
            },
            599: {
                slidesPerView: 2,
                spaceBetween: 12,
            },
            768: {
                slidesPerView: 3,
                spaceBetween: 12,
            },
            1024: {
                slidesPerView: 4,
                spaceBetween: 13,
            },
        }
    });

    var swiperhnews = new Swiper('.hnews-swiper', {
        slidesPerView: 4,
        loop: true,
        autoplay: {
            delay: 3000,
            disableOnInteraction: false,
        },
        breakpoints: {
            221: {
                slidesPerView: 1,
            },
            599: {
                slidesPerView: 2,
                spaceBetween: 26,
            },
            768: {
                slidesPerView: 2,
                spaceBetween: 26,
            },
            991: {
                slidesPerView: 4,
                spaceBetween: 26,
            },
        }
    });
    // 内页导航
    var inavSwiper = new Swiper('.inav-swiper', {
        slidesPerView: 5,
        loop: true,
        breakpoints: {
            221: {
                slidesPerView: 2,
            },
            599: {
                slidesPerView: 2,
            },
            768: {
                slidesPerView: 3,
            },
            991: {
                slidesPerView: 3,
            },
            1200: {
                slidesPerView: 5,
            }
        }
    });

    // 右侧浮层
    $('.right-itemhover').hover(function () {
        $('.right-item-right').stop().fadeIn('slow');
    }, function () {
        $('.right-item-right').stop().hide();
    })
    $('.right-wechat').hover(function () {
        $('.wx-img').stop().fadeIn('slow');
    }, function () {
        $('.wx-img').stop().hide();
    })
    //回到顶部
    $(".back").click(function () {
        if (scroll == "off") return;
        $('html ,body').animate({ scrollTop: 0 }, 300);
        return false;
    })

    // 分享
    $(".mshare-weixin").hover(function () {
        $(".modal-code").show();
    })
    $(".mshare-weixin").click(function () {
        $(".modal-code").show();
    })
    $('.modal-cha').click(function () {
        $(".modal-code").hide();
    })

    $(".inav-ul li").click(function () {
        let name = $(this).attr("name");
        if (name == 'qyjs') {
            scrollTo("#qyjs", 600);
        } else if (name == 'honor') {
            scrollTo("#honor", 600);
        } else if (name == 'vedio') {
            scrollTo("#vedio", 600);
        }
    })
});


// 点击页面滑动
function scrollTo(ele, speed) {
    if (!speed) speed = 300;
    if (!ele) {
        $("html,body").animate({ scrollTop: 0 }, speed);
    } else {
        if (ele.length > 0) $("html,body").animate({ scrollTop: $(ele).offset().top }, speed);
    }
    return false;
}

//函数
function LoadData(WloadList, Wloadul) {
    var _content = []; //临时存储li循环内容
    var lanren = {
        // _default:9, //默认显示图片个数
        // _loading:3,  //每次点击按钮后加载的个数
        init: function (_default, _loading) {
            var lis = Wloadul.find("li");
            WloadList.html("");
            for (var n = 0; n < _default; n++) {
                lis.eq(n).appendTo(WloadList);
            }
            WloadList.find("img").each(function () {
                $(this).attr('src', $(this).attr('realSrc'));
                $(this).attr('layer-src', $(this).attr('realSrc'));
            })
            for (var i = _default; i < lis.length; i++) {
                _content.push(lis.eq(i));
            }
            Wloadul.html("");
        },
        loadMore: function (_default, _loading) {
            var mLis = WloadList.find("li").length;
            var mLen = _content.length;
            if (mLen == 0) {
                layer.msg('已经没有更多数据啦！')
                return;
            }
            for (var i = 0; i < _loading; i++) {
                var target = _content.shift();
                WloadList.append(target);
                WloadList.find("img").eq(mLis + i).each(function () {
                    $(this).attr('src', $(this).attr('realSrc'));
                    $(this).attr('layer-src', $(this).attr('realSrc'));
                });
            }
        }
    }
    return lanren;
}


