var livePage = new Vue({
    el: "#livePage",
    data: {
        pageType: 0,
        liveTeachers: [],
        tecPage:1,
        liveArticles: []
    },
    computed: {

    },
    methods: {
        getLiveTeachers: function () {
            var _self = this;
            $.getJSON("/live/teacher").done(function (r) {
                if (r.code === 0 && r.data) {
                    _self.liveTeachers = r.data;
                    _self.tecPage = Math.ceil(r.data.length / 5);
                    setTimeout(function(){
                        if (isPC) {
                            $('#liveTeacher').slide({
                                mainCell:".swiper-wrapper"
                                ,titCell:".swiper-pagination span"
                                ,effect: "leftLoop"
                                ,interTime: 3000
                                ,autoPlay: true
                                ,scroll:5
                                ,vis:5
                                ,trigger: "mouseover"
                            });
                        } else {
                            var swiper = new Swiper('#liveTeacher', {
                                slidesPerView: 3,
                                slidesPerColumn: 2,
                                spaceBetween: 0,
                                slidesPerGroup: 3,
                                pagination: {
                                    el: '.swiper-pagination',
                                    clickable: true,
                                },
                                autoplay: {
                                    delay: 3000,
                                    disableOnInteraction: false
                                },
                            });
                        }
                    },500);
                }
            });
        },
        getLiveArticle: function(){
            var _self = this;
            $.getJSON(spiServer+"/search/query/article/type" ,{
                id: 1,
                pageSize: 4,
                pageNum: 1
            }, function (r) {
                if (r.code === 0 && r.data) {
                    var result = JSON.parse(r.data);
                    result.items.map(function (item) {
                        _self.liveArticles.push({
                            id: item.a_id,
                            title: item.a_title,
                            image: item.a_image,
                            publisher: item.a_publisher,
                            publishDate: item.a_publish_date,
                            intro: item.a_intro,
                            pv: item.a_pv,
                            typeId: item.a_type_id,
                            type: item.a_type_text,
                            labelIds: item.a_label_ids.replace(/[^[\d|\S]]*/g, ',').split(","),
                            labels: item.a_label_text.replace(/[^[\d|\S]]*/g, ',').split(",")
                        });
                    });
                }
            })
        }

    },
    created: function () {
        // 获取列表数据
        this.getLiveArticle();
        this.getLiveTeachers();

    },
    mounted: function () {
        var _self = this;
    }
});
