<template>
    <div class="alert-wrapper" v-if="showAlert">
        <div class="alert">
            <i class="alert-close iconfont EC7 icon-icon_close" @click.self=" showAlert = false "/>
            <div class="alert-title EC5 ET1" v-html="alert_title" v-if="alert_title"></div>
            <div class="alert-sub-title EC5 ET3" v-html="alert_sub_title" v-if="alert_sub_title"></div>
            <div class="alert-content">
                <img :src="qr_code_url" alt="公众号二维码">
                <p class="ET5 EC6" v-html="alert_tip" v-if="alert_tip"></p>
            </div>
        </div>
    </div>
</template>

<script>
import EventBus from '../../libs/eventbus';

export default {
    data () {
        return {
            showAlert: false,
            qr_code_url: '', // 二维码地址
            alert_title: '', // 标题
            alert_sub_title: '', // 二级标题
            alert_tip: '' // 底部提示
        };
    },
    created() {
        EventBus.$on('qrCodeAlert', (obj) => {
            this.showAlert = true;
            this.qr_code_url = obj.url;
            this.alert_title = obj.title;
            this.alert_sub_title = obj.sub_title;
            this.alert_tip = obj.tip;
        });
    },
};
</script>

<style scoped>
    .alert-wrapper {
        width: 100%;
        height: 100%;
        position: fixed;
        top: 0;
        left: 0;
        background-color: rgba(0,0,0,0.5);
        z-index: 10;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .alert {
        position: relative;
        width: 6.1rem;
        height: 6.28rem;
        padding: .8rem 0;
        background: #fff;
        border-radius: .08rem;
        box-sizing: border-box;
        text-align: center;
    }
    .alert-close {
        position: absolute;
        top: .24rem;
        right: .28rem;
        font-size: .5rem;
    }
    .alert-content img {
        display: inline-block;
        margin-top: 0.16rem;
        width: 3rem;
        height: 3rem;
    }
    .alert-content p {
        margin-top: -0.1rem;
    }
</style>
