<script setup lang="ts">
import { $getWechat } from '@/commons/utils.ts'
import { onMounted, ref } from 'vue';

defineProps<{
    imageUrls: Record<string, string>
    tick: number
    level: number
}>()

defineEmits<{
    replay: []
    back: []
}>()

const nickname = ref('');
const avatar = ref('');
onMounted(() => {
    const wechat = $getWechat();
    nickname.value = wechat.nickname;
    avatar.value = wechat.avatar;
});
</script>

<template>
    <div class="h5-page game-stage">
        <div class="img-logo"></div>
        <!-- <div class="bg-bottom"></div> -->
        <div class="img-score">
            <div class="score-avatar" :style="`background: url(${avatar}) center/cover;border-radius:66px;width:78px;height:78px;`"></div>
            <div class="score-content">
                <div>{{ nickname }}</div>
                <div>您的成绩</div>
                <div></div>
                <div>{{ tick }}</div>
                <div>最终排名</div>
                <div>第<label>{{ level }}</label>名</div>
            </div>
        </div>
        <!-- <div class="btn-group">
            <div class="btn-replay" @click="$emit('replay')"></div>
            <div class="btn-back" @click="$emit('back')"></div>
        </div> -->
    </div>
</template>

<style scoped>
.game-stage {
    position: absolute;
    width: 750px;
    height: 1624px;
    padding: 0;
}

.bg-bottom {
    position: absolute;
    bottom: 0;
    left: var(--stage-viewport-left, 0);
    width: var(--stage-viewport-width, 750px);
    height: 479px;
    background: v-bind('imageUrls.bg') center/cover no-repeat;
    opacity: 0.6;
}

.img-logo {
    position: absolute;
    top: 66px;
    left: 50%;
    width: 428px;
    height: 77px;
    background: v-bind('imageUrls.logo') center/cover;
    transform: translateX(-50%);
}

.img-score {
    position: absolute;
    top: 500px;
    left: 50%;
    width: 465px;
    height: 731px;
    background: v-bind('imageUrls.scoreBg') center/cover;
    transform: translateX(-50%) scale(1.2);
}

.score-avatar {
    position: absolute;
    top: -35px;
    left: 50%;
    /* width: 60px;
    height: 60px; */
    background: v-bind('imageUrls.avatar') center/cover;
    transform: translateX(-50%) scale(2);
}

.score-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(100% - 100px);
    font-size: 28pt;
    text-align: center;
}

.score-content > div:nth-child(1) {
    color: #E00000;
    font-size: 32pt;
    font-weight: bold;
}

.score-content > div:nth-child(2) {
    margin-top: 20px;
    font-size: 32pt;
}

.score-content > div:nth-child(3) {
    margin-top: 40px;
}

.score-content > div:nth-child(4) {
    margin-top: 30px;
    color: #A00000;
    font-size: 32pt;
    font-weight: bold;
    transform: scale(2.4);
}

.score-content > div:nth-child(5) {
    margin-top: 40px;
}

.score-content > div:nth-child(6) {
    margin-top: 20px;
    color: #A00000;
    font-size: 32pt;
    font-weight: bold;
}

.score-content > div:nth-child(6) label {
    color: #A00000;
    font-size: 42pt;
    margin: 0 10px;
}

.btn-group {
    position: absolute;
    top: 1354px;
    left: 50%;
    display: flex;
    gap: 40px;
    transform: translateX(-50%);
}

.btn-replay,
.btn-back {
    width: 315px;
    height: 100px;
}

.btn-replay {
    background: v-bind('imageUrls.replay') center/cover;
}

.btn-back {
    background: v-bind('imageUrls.back') center/cover;
}
</style>
