<template>
	<view class="normal-popup-view-container">
		<view class="normal-popup-view-mask" @touchmove.prevent="handleMaskMove" @mousemove.prevent="handleMaskMove" @click.stop="handleMaskClick"></view>
		<view class="normal-popup-view" :style="{ 'z-index': zIndex }" >
			<view class="normal-popup-content">
				<view class="popup-content-view" @click.stop="handleContentClick" :style="{ 'background-color': themeStore.theme.popup.bgColor }">
					<slot></slot>
				</view>
				<theme-image class="popup-close-btn" src="@/static/icon-popup-close.png" mode="aspectFit" @click.stop="handleCloseBtnClick"/>
			</view>
		</view>
	</view>
</template>

<script setup>
	import { useThemeStore } from '@/store/useThemeStore'
	
	const themeStore = useThemeStore()
	const emit = defineEmits(['onMaskClick, close'])
	const props = defineProps({
		zIndex: {
			type: Number,
			default: 1002
		}
	})
	
	const handleMaskClick = () => {
		emit('onMaskClick')
	}
	
	const handleMaskMove = () => {
		console.log('mask movie')
	}
	
	const handleContentClick = () => {
		
	}
	
	const handleCloseBtnClick = () => {
		emit('close')
	}
</script>

<style lang="scss" scoped>
	.normal-popup-view-container {
		position: relative;
		
		.normal-popup-view-mask {
			position: fixed;
			top: 0;
			left: 0;
			right: 0;
			bottom: 0;
			z-index: 1000;
			background-color: #00000090;
		}
	}
	
	.normal-popup-view {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	
	.normal-popup-content {
		position: relative;
		padding-bottom: 80rpx;
	}
	
	.popup-close-btn {
		width: 60rpx;
		height: 60rpx;
		position: absolute;
		right: -20rpx;
		top: -20rpx;
	}
	
	.popup-content-view {
		border-radius: 20rpx;
		width: 650rpx;
		max-height: 70vh;
		padding: 30rpx;
	}
</style>