<template>
    <div class="overlay" v-if="visible">
        <div class="content">
            <!-- 头部 -->
            <div class="head">
                <div class="left">
                    <!-- 关闭按钮 -->
                    <div class="close-btn" @click="close">
                        <img  class="icon-close"
                            :src="require('@/assets/svg/icon-close.svg')"/>
                    </div>
                    <!-- 标题 -->
                    <div class="title">
                        DeNet
                    </div>
                </div>
            </div>
            <div class="body">
                <div v-for="(item, index) in list"
                    :key="index"
                    class="item"
                    @click="clickItem(item, index)">
                    <img :src="item.icon" alt="">
                    {{item.txt}}
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref, watch, reactive, defineProps, onMounted } from "vue";
let list = reactive([
    {
        icon: require('@/assets/svg/img-select-giveaway.svg'),
        type: 'REDPACKET',
        txt: 'Giveaway'
    },
    {
        icon: require('@/assets/svg/img-select-tool-box.svg'),
        type: 'TOOL_BOX',
        txt: 'Tool Box'
    }
])

const props = defineProps({
    visible: {
        type: Boolean,
        default: false
    },
});


const emits = defineEmits(["close", "select"]);

const close = () => {
    emits('close', {});
}

const clickItem = (params, index) => {
    emits('select', params);
}

</script>

<style lang="scss" scoped>
.overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: auto;

    .content {
        width: 580px;
        height: 400px;
        background: #ffffff;
        border-radius: 20px;
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        box-sizing: border-box;
        z-index: 2000;

        .head {
            border-bottom: 1px solid #ececec;
            height: 48px;
            box-sizing: border-box;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 14px;

            .left {
                display: flex;
                align-items: center;
                .title {
                    font-size: 16px;
                    font-weight: 500;
                }

                .close-btn {
                    display: flex;
                    align-items: center;
                    width: max-content;
                    margin-right: 12px;
                    cursor: pointer;
                }
            }
        }

        .body {
            display: flex;
            justify-content: space-between;
            height: calc(100% - 48px);
            width: 350px;
            margin: 0 auto;

            .item {
                display: flex;
                flex-direction: column;
                align-items: center;
                font-weight: 500;
                font-size: 18px;
                margin-top: 70px;
                cursor: pointer;

                img {
                    margin-bottom: 20px;
                }
            }
        }
    }
}
</style>
