v3.5.16小程序首页动画
This commit is contained in:
@@ -0,0 +1,272 @@
|
||||
/* 首页开场:半透明底 + 酒瓶 + 分流光 + 文字渐显 */
|
||||
|
||||
.home-splash {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 10010;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.home-splash--out {
|
||||
animation: home-splash-out 0.8s ease-in forwards;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.home-splash-veil {
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
background-color: rgba(20, 8, 8, 0.58);
|
||||
background-image: radial-gradient(
|
||||
ellipse at 50% 48%,
|
||||
rgba(166, 29, 36, 0.42) 0%,
|
||||
rgba(20, 8, 8, 0.62) 62%,
|
||||
rgba(10, 4, 4, 0.72) 100%
|
||||
);
|
||||
opacity: 0;
|
||||
animation: home-splash-fade 0.7s ease-out forwards;
|
||||
}
|
||||
|
||||
.home-splash-copy {
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.home-splash-title {
|
||||
font-family: 'Songti SC', 'STSong', 'Noto Serif SC', 'PingFang SC', serif;
|
||||
font-size: 40px;
|
||||
font-weight: 700;
|
||||
line-height: 1.2;
|
||||
letter-spacing: 0.22em;
|
||||
color: #f5d76e;
|
||||
text-shadow: 0 0 14px rgba(255, 191, 0, 0.55), 0 2px 10px rgba(20, 8, 8, 0.45);
|
||||
opacity: 0;
|
||||
animation: home-splash-fade 1.1s 0.65s ease-out forwards;
|
||||
}
|
||||
|
||||
.home-splash-sub {
|
||||
margin-top: 10px;
|
||||
font-size: 13px;
|
||||
letter-spacing: 0.16em;
|
||||
color: rgba(255, 248, 210, 0.88);
|
||||
opacity: 0;
|
||||
animation: home-splash-fade 1.1s 1.35s ease-out forwards;
|
||||
}
|
||||
|
||||
.home-splash-stage {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
width: 220px;
|
||||
height: 420px;
|
||||
overflow: hidden;
|
||||
opacity: 0;
|
||||
animation: home-splash-fade 1s 0.2s ease-out forwards;
|
||||
}
|
||||
|
||||
.home-splash-glow {
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
left: 18px;
|
||||
right: 18px;
|
||||
top: 18%;
|
||||
bottom: 8%;
|
||||
border-radius: 50%;
|
||||
background: radial-gradient(ellipse at 50% 50%, rgba(255, 191, 0, 0.34) 0%, rgba(255, 191, 0, 0) 72%);
|
||||
opacity: 0;
|
||||
animation: home-splash-glow 2.6s 0.8s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.home-splash-beam {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
width: 46px;
|
||||
margin-left: -23px;
|
||||
background: linear-gradient(
|
||||
180deg,
|
||||
rgba(255, 248, 210, 0) 0%,
|
||||
rgba(255, 248, 210, 0.16) 28%,
|
||||
rgba(255, 191, 0, 0.22) 50%,
|
||||
rgba(255, 248, 210, 0.1) 78%,
|
||||
rgba(255, 248, 210, 0) 100%
|
||||
);
|
||||
opacity: 0;
|
||||
animation: home-splash-beam 3.2s 1.1s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.home-splash-bottle {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
display: block;
|
||||
width: 220px;
|
||||
height: 420px;
|
||||
}
|
||||
|
||||
.home-splash-bottle img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.home-splash-lights {
|
||||
position: absolute;
|
||||
z-index: 3;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 220px;
|
||||
height: 420px;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
-webkit-mask-size: contain;
|
||||
mask-size: contain;
|
||||
-webkit-mask-repeat: no-repeat;
|
||||
mask-repeat: no-repeat;
|
||||
-webkit-mask-position: center;
|
||||
mask-mode: alpha;
|
||||
}
|
||||
|
||||
.home-splash-sheen {
|
||||
position: absolute;
|
||||
z-index: 3;
|
||||
top: -12%;
|
||||
bottom: -12%;
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.home-splash-sheen--a {
|
||||
width: 48px;
|
||||
left: 0;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
rgba(255, 255, 255, 0) 0%,
|
||||
rgba(255, 248, 210, 0.08) 28%,
|
||||
rgba(255, 248, 210, 0.55) 50%,
|
||||
rgba(255, 191, 0, 0.18) 72%,
|
||||
rgba(255, 255, 255, 0) 100%
|
||||
);
|
||||
transform: translateX(-70px) skewX(-22deg);
|
||||
animation: home-splash-sheen-a 2.8s 1.4s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.home-splash-sheen--b {
|
||||
width: 22px;
|
||||
left: 0;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
rgba(255, 255, 255, 0) 0%,
|
||||
rgba(255, 255, 255, 0.42) 50%,
|
||||
rgba(255, 255, 255, 0) 100%
|
||||
);
|
||||
transform: translateX(-50px) skewX(-18deg);
|
||||
animation: home-splash-sheen-b 3.6s 2.3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.home-splash-skip {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
right: 16px;
|
||||
z-index: 4;
|
||||
padding: 6px 14px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid rgba(245, 215, 110, 0.45);
|
||||
background: rgba(20, 8, 8, 0.35);
|
||||
opacity: 0;
|
||||
animation: home-splash-fade 0.6s 0.35s ease-out forwards;
|
||||
}
|
||||
|
||||
.home-splash-skip-text {
|
||||
color: rgba(255, 248, 210, 0.92);
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
letter-spacing: 0.08em;
|
||||
}
|
||||
|
||||
@keyframes home-splash-fade {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes home-splash-out {
|
||||
from {
|
||||
opacity: 1;
|
||||
}
|
||||
to {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes home-splash-glow {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 0.35;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.85;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes home-splash-beam {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 0;
|
||||
}
|
||||
40% {
|
||||
opacity: 0.7;
|
||||
}
|
||||
70% {
|
||||
opacity: 0.15;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes home-splash-sheen-a {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateX(-70px) skewX(-22deg);
|
||||
}
|
||||
18% {
|
||||
opacity: 1;
|
||||
}
|
||||
82% {
|
||||
opacity: 0.7;
|
||||
}
|
||||
100% {
|
||||
opacity: 0;
|
||||
transform: translateX(250px) skewX(-22deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes home-splash-sheen-b {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateX(-40px) skewX(-18deg);
|
||||
}
|
||||
22% {
|
||||
opacity: 0.9;
|
||||
}
|
||||
100% {
|
||||
opacity: 0;
|
||||
transform: translateX(240px) skewX(-18deg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { Image, Text, View } from '@tarojs/components';
|
||||
import Taro from '@tarojs/taro';
|
||||
import { HOME_SPLASH_BOTTLE_URL } from '@dukang/shared-types';
|
||||
import { markHomeSplashPlayed } from '../lib/home-splash';
|
||||
|
||||
const SPLASH_NAV_BG = '#140808';
|
||||
const HOME_NAV_BG = '#FAF9F7';
|
||||
const FADE_AT_MS = 4800;
|
||||
const FADE_MS = 800;
|
||||
|
||||
type HomeSplashProps = {
|
||||
onDone: () => void;
|
||||
};
|
||||
|
||||
function applySplashChrome() {
|
||||
try {
|
||||
void Taro.hideTabBar({ animation: false });
|
||||
} catch {
|
||||
/* H5 无原生 TabBar */
|
||||
}
|
||||
void Taro.setNavigationBarColor({
|
||||
frontColor: '#ffffff',
|
||||
backgroundColor: SPLASH_NAV_BG,
|
||||
animation: { duration: 200, timingFunc: 'easeIn' },
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
||||
function restoreChrome() {
|
||||
try {
|
||||
void Taro.showTabBar({ animation: false });
|
||||
} catch {
|
||||
/* H5 无原生 TabBar */
|
||||
}
|
||||
void Taro.setNavigationBarColor({
|
||||
frontColor: '#000000',
|
||||
backgroundColor: HOME_NAV_BG,
|
||||
animation: { duration: 200, timingFunc: 'easeOut' },
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
||||
export default function HomeSplash({ onDone }: HomeSplashProps) {
|
||||
const finishedRef = useRef(false);
|
||||
const fadingRef = useRef(false);
|
||||
const onDoneRef = useRef(onDone);
|
||||
onDoneRef.current = onDone;
|
||||
const [leaving, setLeaving] = useState(false);
|
||||
|
||||
const finish = useCallback(() => {
|
||||
if (finishedRef.current) return;
|
||||
finishedRef.current = true;
|
||||
restoreChrome();
|
||||
onDoneRef.current();
|
||||
}, []);
|
||||
|
||||
const beginExit = useCallback(() => {
|
||||
if (fadingRef.current || finishedRef.current) return;
|
||||
fadingRef.current = true;
|
||||
setLeaving(true);
|
||||
setTimeout(finish, FADE_MS);
|
||||
}, [finish]);
|
||||
|
||||
useEffect(() => {
|
||||
markHomeSplashPlayed();
|
||||
applySplashChrome();
|
||||
const timer = setTimeout(beginExit, FADE_AT_MS);
|
||||
return () => {
|
||||
clearTimeout(timer);
|
||||
if (!finishedRef.current) restoreChrome();
|
||||
};
|
||||
}, [beginExit]);
|
||||
|
||||
return (
|
||||
<View
|
||||
className={`home-splash${leaving ? ' home-splash--out' : ''}`}
|
||||
catchMove
|
||||
onTouchMove={(e) => {
|
||||
e.stopPropagation?.();
|
||||
}}
|
||||
>
|
||||
<View className="home-splash-veil" />
|
||||
|
||||
<View className="home-splash-copy">
|
||||
<Text className="home-splash-title">杜康好客</Text>
|
||||
<Text className="home-splash-sub">购杜康好酒,赠好客权益</Text>
|
||||
</View>
|
||||
|
||||
<View className="home-splash-stage">
|
||||
<View className="home-splash-glow" />
|
||||
<Image
|
||||
className="home-splash-bottle"
|
||||
src={HOME_SPLASH_BOTTLE_URL}
|
||||
mode="aspectFit"
|
||||
style={{ width: '220px', height: '420px' }}
|
||||
/>
|
||||
<View
|
||||
className="home-splash-lights"
|
||||
style={{
|
||||
width: '220px',
|
||||
height: '420px',
|
||||
WebkitMaskImage: `url(${HOME_SPLASH_BOTTLE_URL})`,
|
||||
maskImage: `url(${HOME_SPLASH_BOTTLE_URL})`,
|
||||
WebkitMaskSize: 'contain',
|
||||
maskSize: 'contain',
|
||||
WebkitMaskRepeat: 'no-repeat',
|
||||
maskRepeat: 'no-repeat',
|
||||
WebkitMaskPosition: 'center',
|
||||
}}
|
||||
>
|
||||
<View className="home-splash-beam" />
|
||||
<View className="home-splash-sheen home-splash-sheen--a" />
|
||||
<View className="home-splash-sheen home-splash-sheen--b" />
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className="home-splash-skip" onClick={finish}>
|
||||
<Text className="home-splash-skip-text">跳过</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,266 +0,0 @@
|
||||
/* 酒祖杜康开场:黑红底 → GIF 播完消失 → 四字上移 → 副标题跟上 */
|
||||
|
||||
.jiuzu-splash {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 10010;
|
||||
overflow: hidden;
|
||||
background-color: #140808;
|
||||
background-image: radial-gradient(ellipse at 50% 42%, #5a1014 0%, #2a080a 48%, #140808 100%);
|
||||
animation: jiuzu-bg-in 0.35s ease-out both;
|
||||
}
|
||||
|
||||
.jiuzu-splash--out {
|
||||
animation: jiuzu-bg-out 0.8s ease-in forwards;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.jiuzu-splash-mist {
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
border-radius: 50%;
|
||||
pointer-events: none;
|
||||
filter: blur(48px);
|
||||
}
|
||||
|
||||
.jiuzu-splash-mist--a {
|
||||
width: 280px;
|
||||
height: 280px;
|
||||
left: -72px;
|
||||
top: 12%;
|
||||
background: rgba(166, 29, 36, 0.38);
|
||||
}
|
||||
|
||||
.jiuzu-splash-mist--b {
|
||||
width: 240px;
|
||||
height: 240px;
|
||||
right: -56px;
|
||||
bottom: 16%;
|
||||
background: rgba(90, 16, 20, 0.5);
|
||||
}
|
||||
|
||||
.jiuzu-splash-gif {
|
||||
position: absolute;
|
||||
z-index: 5;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.jiuzu-splash-gif--out {
|
||||
animation: jiuzu-bg-out 0.35s ease-in forwards;
|
||||
}
|
||||
|
||||
.jiuzu-splash-gif img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.jiuzu-splash-copy {
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 26%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.jiuzu-splash-lockup {
|
||||
position: relative;
|
||||
width: 320px;
|
||||
height: 180px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.jiuzu-splash-title {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
opacity: 0;
|
||||
transform: translateY(48vh);
|
||||
}
|
||||
|
||||
.jiuzu-splash--after-gif .jiuzu-splash-title {
|
||||
animation: jiuzu-title-rise 2.4s cubic-bezier(0.22, 1, 0.32, 1) forwards;
|
||||
}
|
||||
|
||||
.jiuzu-splash-mark {
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 320px;
|
||||
height: 180px;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.jiuzu-splash--after-gif .jiuzu-splash-mark {
|
||||
animation: fadeInTo4 1s ease-out both;
|
||||
}
|
||||
|
||||
.jiuzu-splash-mark img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.jiuzu-splash-chars {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
padding: 8px 4px;
|
||||
}
|
||||
|
||||
.jiuzu-splash-char {
|
||||
width: 52px;
|
||||
}
|
||||
|
||||
.jiuzu-splash-char-text {
|
||||
display: block;
|
||||
width: 100%;
|
||||
font-family: 'Songti SC', 'STSong', 'Noto Serif SC', 'PingFang SC', serif;
|
||||
font-size: 46px;
|
||||
font-weight: 700;
|
||||
line-height: 1.15;
|
||||
text-align: center;
|
||||
color: #f5d76e;
|
||||
text-shadow: 0 0 12px rgba(255, 191, 0, 0.85), 0 0 28px rgba(20, 8, 8, 0.65);
|
||||
}
|
||||
|
||||
.jiuzu-splash-shimmer {
|
||||
position: absolute;
|
||||
top: -10%;
|
||||
bottom: -10%;
|
||||
width: 36px;
|
||||
z-index: 3;
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
rgba(255, 255, 255, 0) 0%,
|
||||
rgba(255, 248, 210, 0.55) 50%,
|
||||
rgba(255, 255, 255, 0) 100%
|
||||
);
|
||||
transform: translateX(-80px) skewX(-18deg);
|
||||
}
|
||||
|
||||
.jiuzu-splash--after-gif .jiuzu-splash-shimmer {
|
||||
animation: jiuzu-shimmer 0.7s 2.2s ease-out both;
|
||||
}
|
||||
|
||||
.jiuzu-splash-sub {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
margin-top: 4px;
|
||||
opacity: 0;
|
||||
transform: translateY(36vh);
|
||||
}
|
||||
|
||||
.jiuzu-splash--after-gif .jiuzu-splash-sub {
|
||||
animation: jiuzu-sub-rise 0.4s 1.3s cubic-bezier(0.22, 1, 0.32, 1) forwards;
|
||||
}
|
||||
|
||||
.jiuzu-splash-sub-text {
|
||||
font-size: 13px;
|
||||
letter-spacing: 0.28em;
|
||||
color: rgba(245, 215, 110, 0.88);
|
||||
}
|
||||
|
||||
.jiuzu-splash-skip {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
right: 16px;
|
||||
z-index: 6;
|
||||
padding: 6px 14px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid rgba(245, 215, 110, 0.45);
|
||||
background: rgba(20, 8, 8, 0.35);
|
||||
}
|
||||
|
||||
.jiuzu-splash-skip-text {
|
||||
color: rgba(255, 248, 210, 0.92);
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
letter-spacing: 0.08em;
|
||||
}
|
||||
|
||||
@keyframes fadeInTo4 {
|
||||
0% { opacity: 0; }
|
||||
100% { opacity: 0.4; }
|
||||
}
|
||||
|
||||
@keyframes jiuzu-bg-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes jiuzu-bg-out {
|
||||
from {
|
||||
opacity: 1;
|
||||
}
|
||||
to {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes jiuzu-title-rise {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(48vh);
|
||||
}
|
||||
14% {
|
||||
opacity: 1;
|
||||
transform: translateY(48vh);
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes jiuzu-sub-rise {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(36vh);
|
||||
}
|
||||
18% {
|
||||
opacity: 1;
|
||||
transform: translateY(36vh);
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes jiuzu-shimmer {
|
||||
from {
|
||||
transform: translateX(-80px) skewX(-18deg);
|
||||
opacity: 0.2;
|
||||
}
|
||||
to {
|
||||
transform: translateX(280px) skewX(-18deg);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { Image, Text, View } from '@tarojs/components';
|
||||
import Taro from '@tarojs/taro';
|
||||
import { JIUZU_SPLASH_GIF_URL, JIUZU_SPLASH_MARK_URL } from '@dukang/shared-types';
|
||||
import { markJiuzuSplashPlayed } from '../lib/jiuzu-splash';
|
||||
|
||||
const CHARS = ['酒', '祖', '杜', '康'] as const;
|
||||
|
||||
const SPLASH_NAV_BG = '#140808';
|
||||
const HOME_NAV_BG = '#FAF9F7';
|
||||
/** GIF 21 帧 × 80ms,略提前淡出避免循环 */
|
||||
const GIF_MS = 1650;
|
||||
const GIF_FADE_MS = 350;
|
||||
/** 四字显现并升到偏上位置 */
|
||||
const TITLE_MS = 2400;
|
||||
/** 副标题在四字到位后再升起 */
|
||||
const SUB_DELAY_MS = 2300;
|
||||
const SUB_MS = 1400;
|
||||
const HOLD_MS = 900;
|
||||
const FADE_MS = 800;
|
||||
const FADE_AT_MS = GIF_MS + SUB_DELAY_MS + SUB_MS + HOLD_MS;
|
||||
|
||||
type JiuzuSplashProps = {
|
||||
onDone: () => void;
|
||||
};
|
||||
|
||||
function applySplashChrome() {
|
||||
try {
|
||||
void Taro.hideTabBar({ animation: false });
|
||||
} catch {
|
||||
/* H5 无原生 TabBar */
|
||||
}
|
||||
void Taro.setNavigationBarColor({
|
||||
frontColor: '#ffffff',
|
||||
backgroundColor: SPLASH_NAV_BG,
|
||||
animation: { duration: 200, timingFunc: 'easeIn' },
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
||||
function restoreChrome() {
|
||||
try {
|
||||
void Taro.showTabBar({ animation: false });
|
||||
} catch {
|
||||
/* H5 无原生 TabBar */
|
||||
}
|
||||
void Taro.setNavigationBarColor({
|
||||
frontColor: '#000000',
|
||||
backgroundColor: HOME_NAV_BG,
|
||||
animation: { duration: 200, timingFunc: 'easeOut' },
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
||||
export default function JiuzuSplash({ onDone }: JiuzuSplashProps) {
|
||||
const finishedRef = useRef(false);
|
||||
const fadingRef = useRef(false);
|
||||
const onDoneRef = useRef(onDone);
|
||||
onDoneRef.current = onDone;
|
||||
const [leaving, setLeaving] = useState(false);
|
||||
const [gifDone, setGifDone] = useState(false);
|
||||
const [gifGone, setGifGone] = useState(false);
|
||||
|
||||
const finish = useCallback(() => {
|
||||
if (finishedRef.current) return;
|
||||
finishedRef.current = true;
|
||||
restoreChrome();
|
||||
onDoneRef.current();
|
||||
}, []);
|
||||
|
||||
const beginExit = useCallback(() => {
|
||||
if (fadingRef.current || finishedRef.current) return;
|
||||
fadingRef.current = true;
|
||||
setLeaving(true);
|
||||
setTimeout(finish, FADE_MS);
|
||||
}, [finish]);
|
||||
|
||||
useEffect(() => {
|
||||
markJiuzuSplashPlayed();
|
||||
applySplashChrome();
|
||||
const gifTimer = setTimeout(() => setGifDone(true), GIF_MS);
|
||||
const gifGoneTimer = setTimeout(() => setGifGone(true), GIF_MS + GIF_FADE_MS);
|
||||
const exitTimer = setTimeout(beginExit, FADE_AT_MS);
|
||||
return () => {
|
||||
clearTimeout(gifTimer);
|
||||
clearTimeout(gifGoneTimer);
|
||||
clearTimeout(exitTimer);
|
||||
if (!finishedRef.current) restoreChrome();
|
||||
};
|
||||
}, [beginExit]);
|
||||
|
||||
return (
|
||||
<View
|
||||
className={`jiuzu-splash${gifDone ? ' jiuzu-splash--after-gif' : ''}${leaving ? ' jiuzu-splash--out' : ''}`}
|
||||
catchMove
|
||||
onTouchMove={(e) => {
|
||||
e.stopPropagation?.();
|
||||
}}
|
||||
>
|
||||
<View className="jiuzu-splash-mist jiuzu-splash-mist--a" />
|
||||
<View className="jiuzu-splash-mist jiuzu-splash-mist--b" />
|
||||
|
||||
{gifGone ? null : (
|
||||
<Image
|
||||
className={`jiuzu-splash-gif${gifDone ? ' jiuzu-splash-gif--out' : ''}`}
|
||||
src={JIUZU_SPLASH_GIF_URL}
|
||||
mode="aspectFill"
|
||||
style={{ width: '100%', height: '100%' }}
|
||||
/>
|
||||
)}
|
||||
|
||||
<View className="jiuzu-splash-copy">
|
||||
<View className="jiuzu-splash-lockup">
|
||||
<Image
|
||||
className="jiuzu-splash-mark"
|
||||
src={JIUZU_SPLASH_MARK_URL}
|
||||
mode="aspectFit"
|
||||
style={{ width: '320px', height: '180px' }}
|
||||
/>
|
||||
<View className="jiuzu-splash-title">
|
||||
<View className="jiuzu-splash-chars">
|
||||
<View className="jiuzu-splash-shimmer" />
|
||||
{CHARS.map((ch) => (
|
||||
<View key={ch} className="jiuzu-splash-char">
|
||||
<Text className="jiuzu-splash-char-text">{ch}</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className="jiuzu-splash-sub">
|
||||
<Text className="jiuzu-splash-sub-text">千年酒祖 · 杜康好客</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className="jiuzu-splash-skip" onClick={finish}>
|
||||
<Text className="jiuzu-splash-skip-text">跳过</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user