require('swiper/swiper-3.4.2.jquery.min.js')

class NavPage {
    constructor() {
        this.$navItems = $('.J_nav').children()

        this.init()
    }

    init() {
        this.setEvent()
    }
    setEvent() {
        this.$navItems.click(this.showPage)
    }
    showPage() {
        var $this = $(this)
        if ($this.hasClass('.active')) return;

        var index = $this.index()
        var $wrap = $this.closest('.J_wrap')
        var $contents = $wrap.find('.J_content').children()

        $this.addClass('active').siblings().removeClass('active')
        $contents.removeClass('active').eq(index).addClass('active')
    }
}

class Channel {
    constructor() {
        this.tplList = __inline('../../tpl/videoRank.tmpl'),
            this.init()
    }

    init() {
        this.setLookMore()
    }

    setLookMore() {
        var lookMore = $('.common-look-more');
        lookMore.click(function () {
            var _this = $(this),
                href = encodeURI(_this.attr('data-href'))

            if (href != 'undefined') {
                location.href = href;
            }

        })
    }
}
$(() => {
    new NavPage
    new Channel
    var swiperH = new Swiper('.swiper-container-lunbo', {
        autoplay: 4000,
        autoplayDisableOnInteraction: false,
        loop: true,
        pagination: '.swiper-pagination-h',
        paginationClickable: true,
        spaceBetween: 0
    });

    new Swiper('.equip-type', {
        slidesPerView: 'auto',
        freeMode: true
    })
})