<template>
    <van-popup
        class="widget-popup-confirm"
        v-model="show"
        :lock-scroll="false"
        :overlay="overlay"
        :position="position"
        round
        :style="{ height: height }"
        :close-on-click-overlay="closeOnClickOverlay"
        @click-overlay="clickOverlay"
        @closed="closed"
    >
        <div class="popup_main">
            <div class="popup_header">
                <template v-if="title">
                    {{title}}
                </template>
                <slot v-else name="body" />
            </div>
            <div class="popup_body">
                <template v-if="text">
                    {{text}}
                </template>
                <slot v-else name="body" />
            </div>

            <div class="widget-footer">
                <slot name="footer" />
            </div>
        </div>
    </van-popup>
</template>

<script>
export default {
    name: 'L1WidgetPopupConfirm',

    data() {
        return {
            show: false
        }
    },
    
    props: {
        overlay: {
            type: Boolean,
            default: true
        },
        title: {
            type: String,
            default: ""
        },
        text: {
            type: String,
            default: ""
        },
        height: {
            type: String,
            default: 'auto'
        },
        position: {
            type: String,
            default: 'bottom'
        },
        closeOnClickOverlay:{
            type: Boolean,
            default: true
        }
    },

    methods: {
        // 显示组件
        open() {
            this.show = true;
        },
        // 关闭组件
        close() {
            this.show = false;
        },
        // 关闭后事件回调
        clickOverlay() {
            this.$emit('clickOverlay');
            return;
        },
        // 关闭后事件回调
        closed() {
            this.$emit('closed');
        }
    },
};
</script>

<style lang="less">
.widget-popup-confirm {
    padding: 10px;
    background-color: unset;
    // border-top-left-radius: 16px;
    // border-top-right-radius: 16px;

    .popup_main {
        // background-color: #f1f1f1;
        background-color: #ffffff;
        position: relative;
        height: 100%;
        border-radius: 16px;
        // padding-bottom: 60px;
        // padding-top: 44px;
        display: flex;
        flex-direction: column;
        box-shadow: 0px 4px 4px 0px rgba(0,0,0,0.04), 0px 0px 6px 0px rgba(0,0,0,0.12);
    }

    .popup_header {
        // position: absolute;
        // top: 0;
        // left: 0;
        // width: 100%;
        flex-shrink: 0;
        height: 44px;
        font-size: 16px;
        font-weight: 700;
        line-height: 44px;
        padding-left: 15px;
        padding-right: 15px;
        text-align: center;
        
        // .title-cell {
        //     padding: 5px 15px;
        //     background-color: #eeeeee;

        //     .van-cell__title {
        //         font-size: 16px;
        //         font-weight: 700;
        //         line-height: 33px;
        //     }
        // }
    }

    .popup_body {
        // padding-bottom: 60px;
        flex: 1;
        overflow: auto;
        // line-height: px;
        padding: 0 15px;
        font-size: 14px;
        text-align: center;
        // font-weight: 600;
    }

    .widget-footer {
        // position: fixed;
        // left: 0;
        // right: 0;
        // bottom: 0;
        padding: 10px;
        width: 100%;
        display: flex;
        // z-index: 9999;


        .separate {
            width: 10px;
        }
        .footer_btn {
            // display: flex;
            // align-items: center;
            // justify-content: center;
            flex: 1;
            // max-width: 50%;
            // min-width: 20%;
            // height: auto;
            border-radius: 8px;
            box-shadow: 0px 12px 48px 16px rgba(0, 0, 0, 0.03), 0px 6px 16px -8px rgba(0, 0, 0, 0.08);

            &.scan-btn {
                color: #2196f3
            }
            .footer-text {
                display: flex;
                align-items: center;
                justify-content: center;

                .iconfont {
                    margin-right: 5px;
                }
            }
        }
    }
}
.van-overlay {
    background-color: rgba(0,0,0,0.3);
}
</style>