<template>
	<view @touchmove.prevent  >
		<view class="uni-mask" v-show="show" :style="{top:offsetTop + 'px'}" @click="hide" @touchmove.prevent></view>
		<view :class="['uni-popup','uni-popup-'+type,round?'round':'' ]" v-show="show">
			<view class="header-top" v-if="msg!=''">{{msg}}</view>
			<slot></slot>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			show: {
				type: Boolean,
				default: false
			},
			type: {
				type: String,
				//top - 顶部， middle - 居中, bottom - 底部
				default: 'middle'
			},
			msg: {
				type: String,
				default: ""
			},
			round: {
				type: Boolean,
				default: false
			}
		},
		data() {
			let offsetTop = 0;
			
			return {
				offsetTop: offsetTop
			}
		},
		methods: {
			hide: function() {
				this.$emit('hidePopup');
			},
			
			doNotMove: function () {
			    console.log('stop user scroll it!');
			    return;
			}
		}
	}
</script>
<style>
	.uni-mask {
		position: fixed;
		z-index: 998;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		background-color: rgba(0, 0, 0, .6);
		height: 100%;
	}
	.round {
		border-radius: 24rpx 24rpx 0 0;
	}
	.uni-popup {
		position: fixed;
		z-index: 999;
		background-color: #ffffff;
		box-shadow: 0 0 30upx rgba(0, 0, 0, .1);
	}
	.header-top {
		background-color: #5393F7;
		color: #fff;
		width: 100%;
		/* margin-bottom: 20upx; */
		text-align: center;
		padding: 20upx 30upx;
	}
	.uni-popup-middle {
		/* overflow: hidden; */
		display: flex;
		flex-direction: column;
		align-items: center;
		min-width: 400upx;
		min-height: 100upx;
		border-radius: 16upx;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -60%);
		justify-content: center;
		padding: 0 30upx 30upx 30upx;
	}

	.uni-popup-top {
		top: 0;
		left: 0;
		width: 100%;
		min-height: 390upx;
		line-height: 100upx;
		text-align: center;
		height: auto;
	}

	.uni-popup-bottom {
		left: 0;
		bottom: 0;
		width: 100%;
		min-height: 400upx;
		line-height: 100upx;
		text-align: center;
	}
</style>
