Vue.config.devtools = true;
var v = new Vue({
	el:".container",
	data:{
		indexData:{
			integralDetailCount: 0,
			seriesRecommends:{
				children: [],
			}
		},
		isLogin: 0,
		memToken: '',
		memHeadImg: '',
		loading:true,
		integralType:"",
		integralCount:""
	},
	created:function (){
		if($.cookie("memToken")){
			this.memToken = $.cookie("memToken");
			this.isLogin=1;
		}
		if($.cookie("memHeadImg")){
			this.memHeadImg = $.cookie("memHeadImg");
		}
		this.getIndexData();
	},
	mounted: function (){
		setTimeout(() => {
			this.initFn();
		}, 1000);
		setTimeout(() => {
			$(".loading-item").fadeOut(200);
		},500)
	},
	methods:{
		getIndexData () {
			var that = this;
			$.ajax({
				type : 'POST',
				url : serverHttp+"/index/homeData",
				data : {
					memToken:that.memToken
				},
				success : function(data) {
					if (data.code == 200) {
						that.indexData = data.data;
					}
				},
				error : function(data) {
				}
			});
		},
		pointsMall () {
			var that = this;
			window.location.href = serverHttp + "/user/pointsMall?from=H5&memToken="+that.memToken;
		},
		gotoSearch () {
			var that = this;
			window.location.href = serverHttp + "/index/search?from=H5&memToken="+that.memToken;
		},
		initFn(){
			var mySwiper1 = new Swiper('.top .swiper-container', {
				direction: 'horizontal', // 水平切换选项
				loop: true, // 循环模式选项
				observerParents: true,
				observer: true,
				autoplay: {
					disableOnInteraction: false,  //触碰后自动轮播也不会停止
					delay: 2000,
				},
				// 如果需要分页器
				pagination: {
					el: '.swiper-pagination',
				},

				// 如果需要前进后退按钮
				navigation: {
					nextEl: '.swiper-button-next',
					prevEl: '.swiper-button-prev',
				},

				// 如果需要滚动条
				scrollbar: {
					el: '.swiper-scrollbar',
				},
			});

			var mySwiper2 = new Swiper('.gd .swiper-container', {
				direction: 'vertical', // 水平切换选项
				loop: true, //循环
				observer: true,//修改swiper自己或子元素时，自动初始化swiper
				observeParents: true,//修改swiper的父元素时，自动初始化swiper
				autoplay: {
					disableOnInteraction: false,  //触碰后自动轮播也不会停止
					delay: 2000,
				}
			});
			var mySwiper3 = new Swiper('.ad .swiper-container', {
				direction: 'vertical', // 水平切换选项
				loop: true, //循环
				observer: true,//修改swiper自己或子元素时，自动初始化swiper
				observeParents: true,//修改swiper的父元素时，自动初始化swiper
				autoplay: {
					disableOnInteraction: false,  //触碰后自动轮播也不会停止
					delay: 2000,
				}
			});
		},
		closeToast() {
			$(".toast").hide();
		},
		gotoRcmd(obj) {
			gotoRcmdPub(obj.zqFlag,obj.rcmdType,obj.rcmdObjId,obj.rcmdUrl,"H5",obj.artType,obj.artContent);
		},
	}
})
