Vue.config.devtools = true;
var v = new Vue({
    el:".container",
    data:{
        artId: '',
        artInfo:{
            sysRecommendDTOs: [],
        },
        isLogin: 0,
        memToken: '',
        memHeadImg: '',
        userJf:-1,
        integralType:"",
        integralCount:""
    },
    created:function (){
        if(!checkLogin()){
            // goLogin();
            return false;
        }
        var that = this;
        if($.cookie("memToken")){
            that.memToken = $.cookie("memToken");
            that.isLogin=1;
        }
        if($.cookie("memHeadImg")){
            that.memHeadImg = $.cookie("memHeadImg");
        }
        that.artId = $("#artId").val();
        that.getDetailData();
        this.findUserIntegral();
    },
    mounted: function (){
        setTimeout(() => {
            this.initFn();
        }, 1000);
        setTimeout(() => {
            $(".loading-item").fadeOut(200);
        },500)
        saveUserDorec(1, 1, this.artId, window.location.href, 1);
    },
    methods:{
        findUserIntegral (){
            var that = this;
            $.ajax({
                type : 'POST',
                url : serverHttp+"/user/findUserIntegral",
                data : {
                    memToken:that.memToken
                },
                success : function(data) {
                    if (data.code == 200) {
                        that.userJf = data.data;
                    }
                },
                error : function(data) {
                }
            });
        },
        initFn(){
            var mySwiper = new Swiper('.swiper-container', {
                direction: 'horizontal', // 水平切换选项
                loop: true, // 循环模式选项
                observerParents: true,
                observer: true,
                autoplay: {
                    disableOnInteraction: false,  //触碰后自动轮播也不会停止
                    delay: 2000,
                },autoplay: true,
                // 如果需要分页器
                pagination: {
                    el: '.swiper-pagination',
                },
                // 如果需要前进后退按钮
                navigation: {
                    nextEl: '.swiper-button-next',
                    prevEl: '.swiper-button-prev',
                },
                // 如果需要滚动条
                scrollbar: {
                    el: '.swiper-scrollbar',
                },

            })
        },
        getDetailData(){
            var that = this;
            $.ajax({
                type : 'POST',
                url : serverHttp+"/view/getDetailData",
                data : {
                    memToken:that.memToken,
                    artId: that.artId
                },
                success : function(data) {
                    if (data.code == 200) {
                        that.artInfo = data.data;
                        $("meta[name='sharetitle']").attr("content",that.artInfo.shareTitle);
                        $("meta[name='sharedesc']").attr("content",that.artInfo.shareDesc);
                        $("meta[name='sharepic']").attr("content",that.artInfo.sharePic);
                        // $("meta[name='shareurl']").attr("content",that.artInfo.shareUrl);
                        document.title = that.artInfo.info.title;
                    }
                },
                error : function(data) {
                }
            });
        },
        gotoRcmd(obj) {
            gotoRcmdPub(obj.zqFlag,obj.rcmdType,obj.rcmdObjId,obj.rcmdUrl,"H5",obj.artType,obj.artContent);
        },
    }
})
