<template>
	<view class="video-preview-shadow" v-if="visible">
		<div class="preview-box">
			<view class="title">预览</view>
			<video :src="url" class="video" :autoplay="autoplay"></video>
			<view class="btn" @click="visible=false">关闭</view>
		</div>
	</view>
</template>

<script>
	export default {
		name: "VideoPreview",
		data() {
			return {
				visible: false,
				url: '',
				autoplay:false
			};
		},
		methods: {
			openModal(url) {
				this.visible = true
				this.$nextTick(() => {
					this.url = url;
					this.autoplay = true
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.video-preview-shadow {
		width: 100vw;
		height: 100vh;
		background-color: rgba(0, 0, 0, 0.3);
		z-index: 999;
		position: fixed;
		top: 0;
		left: 0;
		display: flex;
		align-items: center;
		justify-content: center;

		.preview-box {
			width: 90vw;
			height: 1200rpx;
			background-color: white;
			border-radius: 20rpx;
			.title{
				height: 100rpx;
				line-height: 100rpx;
				text-align: center;
				font-size: 32rpx;
				font-weight: bold;
			}
			.video{
				width: 100%;
				height:calc(100% - 220rpx);
				display: flex;
				align-items: center;
				justify-content: center;
			}
			
			.btn{
				height: 120rpx;
				line-height: 120rpx;
				text-align: center;
				font-weight: bold;
			}
		}
	}
</style>