Files
shoot-miniprograms/src/components/UserUpgrade.vue

166 lines
4.0 KiB
Vue
Raw Normal View History

2025-07-17 16:14:30 +08:00
<script setup>
2025-07-23 20:47:31 +08:00
import { ref, onMounted, onUnmounted } from "vue";
2025-07-17 16:14:30 +08:00
import useStore from "@/store";
import { storeToRefs } from "pinia";
const store = useStore();
const { user } = storeToRefs(store);
2025-07-23 20:47:31 +08:00
const { updateUser, getLvlName, getLvlImage } = store;
const show = ref(false);
const showRank = ref(false);
const showGrade = ref(false);
const nextRankTitle = ref("");
const nextRankImage = ref("");
const lvl = ref(0);
const timer = ref(null);
onMounted(async () => {
timer.value = setTimeout(() => {
let latestRank = 0;
let latestLvl = 0;
latestRank = parseInt(uni.getStorageSync("latestRank") || 0);
latestLvl = parseInt(uni.getStorageSync("latestLvl") || 0);
let timeout = 0;
if (latestRank > user.value.rankLvl) {
nextRankTitle.value = getLvlName(latestRank);
nextRankImage.value = getLvlImage(latestRank);
show.value = true;
showRank.value = true;
timeout += 2000;
updateUser({ ...user.value, rankLvl: latestRank });
}
if (latestLvl > user.value.lvl) {
lvl.value = latestLvl;
show.value = true;
setTimeout(() => {
showRank.value = false;
showGrade.value = true;
}, timeout);
timeout += 2000;
updateUser({ ...user.value, lvl: latestLvl });
}
setTimeout(() => {
show.value = false;
}, timeout);
}, 1000);
2025-07-17 16:14:30 +08:00
});
2025-07-23 20:47:31 +08:00
onUnmounted(() => {
if (timer.value) clearTimeout(timer.value);
2025-07-17 16:14:30 +08:00
});
</script>
<template>
<view class="content" :style="{ display: show ? 'flex' : 'none' }">
2025-07-23 20:47:31 +08:00
<view v-if="showRank" class="up-rank">
<image :src="user.avatar || '../static/user-icon.png'" mode="widthFix" />
<image :src="nextRankImage" mode="widthFix" />
<image class="bg-effect" src="../static/shining-bg.png" mode="widthFix" />
2025-07-21 16:15:14 +08:00
<image
2025-07-23 20:47:31 +08:00
class="bg-effect"
src="../static/gold-shining.png"
2025-07-21 16:15:14 +08:00
mode="widthFix"
/>
2025-07-23 20:47:31 +08:00
</view>
<view v-if="showGrade" class="up-grade">
2025-07-21 16:15:14 +08:00
<image
2025-07-23 20:47:31 +08:00
class="scale-in"
src="../static/user-upgrade.png"
2025-07-21 16:15:14 +08:00
mode="widthFix"
/>
2025-07-23 20:47:31 +08:00
<image class="bg-effect" src="../static/shining-bg.png" mode="widthFix" />
2025-07-21 16:15:14 +08:00
<image
2025-07-23 20:47:31 +08:00
class="bg-effect"
2025-07-21 16:15:14 +08:00
src="../static/gold-shining.png"
mode="widthFix"
/>
</view>
<view class="text-content">
<image src="../static/update-text-bg.png" />
2025-07-17 16:14:30 +08:00
<text>恭喜你升级到</text>
2025-07-23 20:47:31 +08:00
<text>{{ showRank ? nextRankTitle : `射灵${lvl}` }}</text>
2025-07-22 09:36:38 +08:00
<text>!</text>
2025-07-17 16:14:30 +08:00
</view>
2025-07-23 16:01:16 +08:00
<!-- <button @click="onClose" hover-class="none">关闭</button> -->
2025-07-17 16:14:30 +08:00
</view>
</template>
<style scoped>
.content {
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
background-color: #232323;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 10;
color: red;
}
2025-07-23 20:47:31 +08:00
.up-rank {
2025-07-21 16:15:14 +08:00
position: relative;
2025-07-23 20:47:31 +08:00
height: 50vw;
height: 80vw;
2025-07-21 16:15:14 +08:00
}
2025-07-23 20:47:31 +08:00
.up-rank > image:first-child {
position: absolute;
width: 36vw;
left: calc(50% - 18vw);
top: calc(50% - 18vw);
border-radius: 50%;
}
.up-rank > image:nth-child(2) {
position: absolute;
width: 44vw;
left: calc(50% - 22vw);
top: calc(50% - 22vw);
}
.up-grade {
position: relative;
}
.up-grade > image:first-child {
2025-07-21 16:15:14 +08:00
animation: scaleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
2025-07-23 20:47:31 +08:00
.up-grade > image:first-child {
2025-07-17 16:14:30 +08:00
width: 50vw;
2025-07-23 20:47:31 +08:00
margin: 18vw;
2025-07-17 16:14:30 +08:00
}
2025-07-21 16:15:14 +08:00
.bg-effect {
position: absolute;
2025-07-17 16:14:30 +08:00
width: 80vw;
2025-07-21 16:15:14 +08:00
left: calc(50% - 40vw);
z-index: -1;
2025-07-23 20:47:31 +08:00
/* transform: scale(0); */
/* opacity: 0; */
animation: rotate 10s linear infinite;
2025-07-17 16:14:30 +08:00
}
2025-07-21 16:15:14 +08:00
.text-content {
2025-07-17 16:14:30 +08:00
color: #fff;
display: flex;
font-size: 20px;
font-weight: bold;
2025-07-21 16:15:14 +08:00
position: relative;
line-height: 60px;
2025-07-23 20:47:31 +08:00
margin-bottom: 20vw;
2025-07-21 16:15:14 +08:00
}
.text-content > image:first-child {
position: absolute;
width: 80vw;
left: calc(50% - 40vw);
height: 60px;
2025-07-17 16:14:30 +08:00
}
2025-07-22 09:36:38 +08:00
.text-content > text:nth-child(3) {
2025-07-17 16:14:30 +08:00
color: #fed847;
}
.content > button:last-child {
color: #fff9;
font-size: 20px;
border: 1px solid #fff;
padding: 10px;
width: 50vw;
border-radius: 20px;
margin-top: 10vw;
}
</style>