<template>
	<view class="lotteryList">
		<view class="title" :style="{ width: imgstyle.width + 'px', height: imgstyle.height + 'px' }" >
			<swiper class="swiper" v-if="!!adv && adv.length > 0"  indicator-color="rgba(255,255,255,.4)" indicator-active-color="rgba(255,255,255,.85)" :indicator-dots="true" :autoplay="true" :interval="2000" :duration="500">
				<swiper-item v-for="(item, index) in adv" :key="index" @click="goLink(item.link)">
					<image :src="item.thumb" style="width: 100%; height: 100%;" mode="scaleToFill"></image>
				</swiper-item>
			</swiper>
		</view>
		<view class="content">
			<view  v-for="(item,index) in swiperList" :key="index">
				<draw-commodity :goodItem="item"></draw-commodity>
			</view>
		</view>
		<TabBars :tabBarAct="0" />
	</view>
</template>

<script>
	import App from "@/common/js/app.js"
	import drawCommodity from '@/components/template/drawCommodity.vue';
	import TabBars from '@/components/template/tabBar';
	// #ifdef H5
	import wxApi from '@/common/js/wxApi.js';
	//#endif
	export default{
		data(){
			return{
				imgstyle:{},
				page:1,
				swiperList:[],
				adv:[],
				pluginList:[
					{
						type:'rush',
						title:'抢购'
					},
					{
						type:'groupon',
						title:'团购'
					},
					{
						type:'fightgroup',
						title:'拼团'
					},
					{
						type:'coupon',
						title:'卡券'
					},
					{
						type:'bargain',
						title:'砍价'
					},
					{
						type:'activity',
						title:'活动'
					},
					{
						type:'payonline',
						title:'买单'
					},
					{
						type:'citydelivery',
						title:'配送'
					},
					{
						type:'drawvideo',
						title:'视频'
					},
					{
						type:'drawshare',
						title:'分享'
					},
					{
						type:'store',
						title:'商户'
					}
				],
				lat:'',
				lng:''
			}
		},
		components:{
			drawCommodity,
			TabBars
		},
		onLoad(e) {
			let myLocation = uni.getStorageSync('curLoction');
			this.lng = myLocation.longitude || '';
			this.lat = myLocation.latitude || '';
			this.getStore(e.id);
			this.imgstyle = uni.getStorageSync('imgstyle');
		},
		methods:{
			goLink(url) {
				App.navigationTo({
					url: url
				});
			},
			getStore(id,flag){
				let _this = this;
				App._post_form('&p=luckydraw&do=goodsListInfo', {
					id:id,
					page:this.page,
					lat:_this.lat,
					lng:_this.lng
				}, res => {
					if(flag){
						this.swiperList = this.swiperList.concat(res.data.buygoodslist);
					}else{
						this.swiperList = res.data.buygoodslist;
						this.adv = res.data.adv;
					}
					this.swiperList.map((item,index)=>{
						this.pluginList.map((it,i)=>{
							if(item.plugin == it.type){
								item.pluginName = it.title;
							}
						})
					});
					console.log(this.swiperList);
				}, false, () => {
					// _this.loadlogo = false;
				})
			},
		},
		// onReachBottom() {
		// 	this.page++;
		// 	this.getStore(true)
		// },
	}
</script>

<style scoped lang="scss">
	.lotteryList{
		padding-bottom: 120upx;
		.title{
			position: relative;
			.swiper{
				height: 100%;
				width: 100%;
			}
		}
		.content{
			padding: 30upx;
		}
	}
</style>
