feat(邀请新用户页面): 新增图片预加载缓冲动画,并修复切换按钮的显示问题

This commit is contained in:
hzj 2025-12-25 18:50:58 +08:00
parent 042de97624
commit bfdd4cdcf0

View File

@ -1,6 +1,14 @@
<!-- src/views/Invitation/InviteToRegister.vue --> <!-- src/views/Invitation/InviteToRegister.vue -->
<template> <template>
<div class="fullPage" :style="{ '--bg-url': `url(${imageUrl('bg')})` }"> <div class="fullPage" :style="{ '--bg-url': `url(${imageUrl('bg')})` }">
<!-- 预加载状态 -->
<div v-if="isLoading" class="loading-container">
<div class="loading-spinner"></div>
<p>{{ $t('loading') }}...</p>
</div>
<!-- 主要内容 -->
<div v-else>
<div style="position: absolute; top: 0; left: 0; width: 100%"> <div style="position: absolute; top: 0; left: 0; width: 100%">
<GeneralHeader <GeneralHeader
:isHomePage="true" :isHomePage="true"
@ -59,7 +67,9 @@
gap: 4px; gap: 4px;
" "
> >
<div style="font-weight: 590; font-size: 1.1em">{{ myInviteInfo.inviteCode || '' }}</div> <div style="font-weight: 590; font-size: 1.1em">
{{ myInviteInfo.inviteCode || '' }}
</div>
<img <img
v-if="myInviteInfo.inviteCode" v-if="myInviteInfo.inviteCode"
v-smart-img v-smart-img
@ -76,7 +86,7 @@
<!-- 奖励按钮 --> <!-- 奖励按钮 -->
<div style="width: 40%; position: relative"> <div style="width: 40%; position: relative">
<img <img
v-smart-img v-smart-img.noFade
:src="imageUrl(getImgName('processBt'))" :src="imageUrl(getImgName('processBt'))"
alt="" alt=""
style="display: block; width: 100%" style="display: block; width: 100%"
@ -84,7 +94,7 @@
@click="showModule = 'process'" @click="showModule = 'process'"
/> />
<img <img
v-smart-img v-smart-img.noFade
:src="imageUrl(getImgName('processBtActive'))" :src="imageUrl(getImgName('processBtActive'))"
alt="" alt=""
style="display: block; width: 100%; position: absolute; top: 0; left: 0" style="display: block; width: 100%; position: absolute; top: 0; left: 0"
@ -96,7 +106,7 @@
<!-- 列表按钮 --> <!-- 列表按钮 -->
<div style="width: 40%; position: relative"> <div style="width: 40%; position: relative">
<img <img
v-smart-img v-smart-img.noFade
:src="imageUrl(getImgName('listBt'))" :src="imageUrl(getImgName('listBt'))"
alt="" alt=""
style="display: block; width: 100%" style="display: block; width: 100%"
@ -104,7 +114,7 @@
@click="showModule = 'list'" @click="showModule = 'list'"
/> />
<img <img
v-smart-img v-smart-img.noFade
:src="imageUrl(getImgName('listBtActive'))" :src="imageUrl(getImgName('listBtActive'))"
alt="" alt=""
style="display: block; width: 100%; position: absolute; top: 0; left: 0" style="display: block; width: 100%; position: absolute; top: 0; left: 0"
@ -164,7 +174,9 @@
padding: 2vw; padding: 2vw;
" "
> >
<div style="font-weight: 700; font-size: 0.9em">{{ t('invitation_total_income') }}</div> <div style="font-weight: 700; font-size: 0.9em">
{{ t('invitation_total_income') }}
</div>
<div style="display: flex; align-items: center"> <div style="display: flex; align-items: center">
<img <img
v-smart-img v-smart-img
@ -484,12 +496,18 @@
style="position: fixed; top: 50vh; display: flex; justify-content: center; width: 100vw" style="position: fixed; top: 50vh; display: flex; justify-content: center; width: 100vw"
> >
<div <div
style="padding: 12px; border-radius: 8px; background: rgba(0, 0, 0, 0.4); font-weight: 600" style="
padding: 12px;
border-radius: 8px;
background: rgba(0, 0, 0, 0.4);
font-weight: 600;
"
> >
{{ t('copied_successfully') }} {{ t('copied_successfully') }}
</div> </div>
</div> </div>
</div> </div>
</div>
</template> </template>
<script setup> <script setup>
@ -536,6 +554,9 @@ const imageUrl = (filename) => getPngUrl('invitation/InviteNewUser/', filename)
const { copy, isSupported } = useClipboard() const { copy, isSupported } = useClipboard()
//
const isLoading = ref(true)
const helpInfoShow = ref(false) // const helpInfoShow = ref(false) //
const enterCodeShow = ref(false) // const enterCodeShow = ref(false) //
const tipShow = ref(false) // const tipShow = ref(false) //
@ -686,9 +707,9 @@ const getBindingUserRewards = async () => {
} }
// //
const preloadCriticalImages = () => { const preloadCriticalImages = async () => {
const criticalImages = [ const criticalImages = [
imageUrl('bg'), // imageUrl('bg'),
imageUrl('enterCode'), imageUrl('enterCode'),
imageUrl('enterCodeBg'), imageUrl('enterCodeBg'),
imageUrl('example'), imageUrl('example'),
@ -704,7 +725,7 @@ const preloadCriticalImages = () => {
] ]
const criticalImages_ar = [ const criticalImages_ar = [
imageUrl('bg'), // imageUrl('bg'),
imageUrl('enterCode_ar'), imageUrl('enterCode_ar'),
imageUrl('enterCodeBg_ar'), imageUrl('enterCodeBg_ar'),
imageUrl('example_ar'), imageUrl('example_ar'),
@ -720,27 +741,41 @@ const preloadCriticalImages = () => {
] ]
if (currentLangType.value == 'en') { if (currentLangType.value == 'en') {
preloadImages(criticalImages) await preloadImages(criticalImages)
} else if (currentLangType.value == 'ar') { } else if (currentLangType.value == 'ar') {
preloadImages(criticalImages_ar) await preloadImages(criticalImages_ar)
} }
} }
// //
const initData = () => { const initData = async () => {
apiGetMyInviteCode() // await Promise.all([
apiGetMyInviter() // apiGetMyInviteCode(), //
apiGetMyInviteIncome() // apiGetMyInviter(), //
apiGetMyInviteUsers() // apiGetMyInviteIncome(), //
getBindingUserRewards() // apiGetMyInviteUsers(), //
getBindingUserRewards(), //
])
}
//
const completePreloading = async () => {
try {
//
await Promise.all([initData(), preloadCriticalImages()])
} catch (error) {
console.error('预加载过程中发生错误:', error)
} finally {
//
isLoading.value = false
}
} }
// 使APP // 使APP
const connectToAppHandler = async () => { const connectToAppHandler = async () => {
await connectToApp(() => { await connectToApp(() => {
// //
initData() completePreloading() //
preloadCriticalImages() //
}) })
} }
@ -794,6 +829,36 @@ onMounted(() => {
justify-content: space-between; justify-content: space-between;
} }
/* 添加加载动画样式 */
.loading-container {
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: #666;
}
.loading-spinner {
width: 32px;
height: 32px;
border: 3px solid #f3f3f3;
border-top: 3px solid #f59e0b;
border-radius: 50%;
animation: spin 1s linear infinite;
margin-bottom: 12px;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@media screen and (max-width: 360px) { @media screen and (max-width: 360px) {
* { * {
font-size: 12px; font-size: 12px;