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

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

    init() {
        // this.initRankList()
        this.setLookMore()
    }

    initRankList() {
        var channel = 'all';
        var tag = 'all';
        this.getRank(tag, "week", channel);
    }
    setLookMore() {
        var lookMore = $('.common-look-more');
        lookMore.click(function () {
            var _this = $(this),
                href = encodeURI(_this.data('href'))

            location.href = href;
        })
    }
    getRank(tag, sortBy, channel) {
        var self = this;
        tag = (tag == "all") ? "" : tag;
        channel = (channel == "all") ? "" : channel;

        var url = "http://video.duowan.com/?r=jsapi/getRankByTag&tag=" + tag + "&sortBy=" + sortBy + "&channel=" + channel + "&limit=10";

        $(".video-list-container .video-main-content").html("");

        $.ajax({
            url: url,
            dataType: 'jsonp',
            success: function (ret) {
                var dom = self.tplList({ data: ret });
                $(".video-main-content").html(dom);
            }
        })
    }
}

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