<template>
	<view class="previewImg">
		<view class="mask">
			<swiper class="my_swiper" @change="swiperChange" :autoplay="false">
				<swiper-item @click="dissmiss" v-for="(x, y) in picList" :key="y"><view class="bg_img" :style="{ backgroundImage: 'url(' + x + ')' }"></view></swiper-item>
			</swiper>
		</view>
		<view class="page" v-if="picList.length > 0">{{ currentPosition }} / {{ picList.length }}</view>
	</view>
</template>

<script>
export default {
	name: 'previewImages',
	props:{
		current:{
			type:Number,
			default:0
		},
		indicatorDots:{	//是否展示推荐菜单
			type: Boolean,
			default: true
		},
		picList: { //图片列表
			type: Array,
			default () {
				return []
			}
		},
	},
	data() {
		return {
			currentPosition: this.current,
			circular: true,
			isShowSwiper: false
		};
	},
	mounted() {
		console.log(this.picList)
	},
	methods: {
		swiperChange(e) {
			this.currentPosition = e.detail.current + 1
		},
		dissmiss() {
			console.log('dissmiss')
			this.$parent.dissmissPreviewImages()
		}
	}
};
</script>

<style lang="scss" scoped>
.page {
	position: fixed;
	z-index: 6;
	color: #fff;
	bottom: 20rpx;
	text-align: center;
	width: 100%;
}
.mask {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	display: flex;
	justify-content: center;
	align-items: center;
	background-color: #000;
	z-index: 5;
	> .my_swiper {
		width: 100%;
		height: 60vh;
		.bg_img {
			background-size: 100% auto;
			background-repeat: no-repeat;
			background-position:center;
			width: 100%;
			height: 100%;
		}
	}
}

.pic_list {
	display: flex;
	flex-flow: row wrap;
	> view {
		flex: 0 0 33.3vw;
		height: 33.3vw;
		padding: 1vw;
		> image {
			width: 100%;
			height: 100%;
		}
	}
}
</style>
