<template>
	<gracePage :customHeader="false">
		<view class="container" slot="gBody">
			<swiper class="swiper" @change="change" :circular="swiper.circular" :current="index">
				<swiper-item v-for="(v, k) in fetch.items"  v-if="v.data" :key="k" >
					<scroll-view scroll-y="true" scroll-x="true" class="scroll-height">
						<dream ref="dream" :index="k" :item="v" :control="control" class="item"></dream>
					</scroll-view>
				</swiper-item>
			</swiper>

		</view>
	</gracePage>
</template>
<script>
import gracePage from "@/lib/graceUI/components/gracePage.vue";
import dream from "@/pages/dream/view/dream.vue";
var graceRichText = require("@/lib/graceUI/jsTools/richText.js");
export default{
	data() {
		return {
			id : 1,
			page_id : 1,
			index : 0,
			swiper : {
				index : 0,
				circular : false,
			},
			fetch: {
				items : []
			},
			control : {}
		}
	},
	onLoad(option) {
		this.id = option.id;
		this.page_id = option.page_id;
		this.index = option.index;
		this.getData();
	},
	// 下拉刷新
	onPullDownRefresh: function() {
		this.getData();
	},
	// 重新加载
	onPullDownRefresh: function() {
		this.getData();
	},
	methods:{
		change : function(e) {
			this.swiper.index = e.detail.current;
			if (this.control) {
				var i = 0;
				for (i in this.control) {
					if (this.control[i].load) {
						console.info(i);
						if (this.swiper.index == i) {
							console.info('start');
							this.control[i].start();
						} else {
							this.control[i].stop();
						}
					}
				}
			}
			if (this.swiper.index == this.fetch.items.length - 1) {
				this.$refs.dream[this.swiper.index].setSelectShow(true);
			}
		},
		view : function() {
			this.Dever.location('dream/view?id=1');
		},
		getData : function() {
			this.Dever.get(this, 'app/collection/?l=api.getContent', {id:this.id, page_id:this.page_id});
		}
	},
	components:{
		gracePage,dream
	}
}
</script>
<style>
.container {
  position: absolute;
  height: 100%;
  width: 100%;
  left: 0;
  top: 0;
}
.swiper {
	width: 750rpx;
	height: 100%;
}
swiper-item>view{
  height: 100%;
}
swiper-item image{
  width: 750rpx;
  height: 100%;
}
.scroll-height {
	height:100%;
}
</style>