<template>
    <div
        v-if="isLogin && !show && levelInfo.icon"
        ref="medal"
        class="medal-info"
        @click.stop="$router.push(`/${$route.params.companyId}/mineLevel`)"
    >
        <div class="medal-icon">
            <van-image :src="levelInfo.icon" width="28" height="28" />
            <div class="text1" :style="{ color: levelInfo.color1 || levelInfo.color }">{{ levelInfo.level }}</div>
        </div>
        <div class="medal-text">
            <div
                class="text1"
                :style="{
                    color: levelInfo.color1 || levelInfo.color,
                    backgroundColor: (levelInfo.color1 || levelInfo.color) + '33'
                }"
            >
                {{ levelInfo.title }}
            </div>
        </div>
    </div>
</template>

<script>
import level from '../../mixins/level';
export default {
    data() {
        return {
            show: false
        };
    },
    mixins: [level],
    mounted() {
        // this.$nextTick(() => {
        //     document.getElementById('app').appendChild(this.$refs.overLay);
        // });
    },
    methods: {
        changeLevel(level) {
            if (level >= 10) {
                this.$emit('showOverlay', true);
            }
            this.$http.post('/user/update', {
                ...this.$store.state.userInfo,
                level: level
            });
        },
        close() {
            this.addClass('box', 'zoomOutUp', false, 200).then(() => {
                this.$emit('showOverlay', false);
                this.$nextTick(() => {
                    this.$refs.medal.className += ' flipInX';
                });
            });
        }
    }
};
</script>

<style lang="less" scoped>
.box {
    background-color: @bg;
    border-radius: 16px;
    overflow: hidden;
    top: 50%;
    left: 50%;
    width: 260px;
    height: 338px;
    position: absolute;
    margin-top: -169px;
    margin-left: -130px;
    .box-content {
        padding: 16px 23px 20px;
        .text1 {
            font-size: 12px;
            line-height: 17px;
            text-align: center;
            span {
                font-weight: bold;
            }
        }
    }

    .btn {
        padding: 16px 40px 0;
    }
}

.box-top {
    position: absolute;
    width: 260px;
    height: 220px;
    top: 0;
    left: 0;
    .flex-col();
    align-items: center;
    justify-content: center;

    .text3 {
        border-radius: 2px;
        padding: 0 9px;
        margin-top: 6px;
        font-size: 12px;
        line-height: 20px;
    }
    .text1 {
        font-size: 12px;
        line-height: 17px;
        margin-top: 2px;
    }
}

.box-title {
    font-size: 14px;
    font-weight: bold;
    line-height: 24px;
    vertical-align: middle;
    &::after,
    &::before {
        display: inline-block;
        width: 30px;
        content: '';
        border-top: 1px solid;
        vertical-align: middle;
        margin: 10px;
    }
}

.icon {
    position: relative;
    margin-top: 9px;
    .text2 {
        font-size: 34px;
        font-weight: bold;
        font-family: AlibabaPuHuiTi-Bold, AlibabaPuHuiTi;
        line-height: 34px;
        position: absolute;
        left: 52px;
        top: 38px;
    }
}
.medal-info {
    .flex();
    .medal-icon {
        flex-shrink: 0;
        position: relative;
        z-index: 1;
        transform: translateY(2px);

        .van-image {
            display: block;
        }

        .text1 {
            position: absolute;
            left: 10px;
            top: 8px;
            font-size: 12px;
            transform: scale(0.8);
            line-height: 12px;
            font-weight: bold;
            text-align: center;
            display: block;
            min-width: 14px;
            // min-height: 12px;
            font-weight: bold;
            letter-spacing: -1px;
        }
    }
    .medal-text {
        .flex-col();
        align-items: center;
        justify-content: center;
        transform: scale(0.8) translateX(-18px);
        z-index: 0;
        .text1 {
            font-size: 12px;
            border-radius: 2px;
            line-height: 16px;
            padding: 0 4px 0 6px;
            border-radius: 2px;
            text-align: center;
            position: relative;
            display: block;
            overflow: hidden;
            &::after {
                content: '';
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                z-index: -1;
                background-color: #fff;
            }
        }
    }
}
.van-overlay {
    top: -103px;
    width: 100vw;
    height: 100vh;
    left: -16px;
    width: 100vw;
    height: 100vh;
}
</style>
