This commit is contained in:
张成
2025-12-04 10:40:58 +08:00
parent 797e086431
commit a67383d12c
6 changed files with 331 additions and 188 deletions

View File

@@ -0,0 +1,113 @@
.empty_state_page {
width: 100%;
min-height: 100vh;
background: #3f3f3f;
position: relative;
display: flex;
flex-direction: column;
overflow: hidden;
&__content {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
padding: 0;
position: relative;
min-height: calc(100vh - 98px);
}
// 背景图片
&__bg_image {
position: absolute;
top: 178px;
left: 84px;
width: 221.17px;
height: 200px;
background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjIyIiBoZWlnaHQ9IjIwMCIgdmlld0JveD0iMCAwIDIyMiAyMDAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIyMjIiIGhlaWdodD0iMjAwIiBmaWxsPSIjRkZGRkZGIiBmaWxsLW9wYWNpdHk9IjAuMiIvPgo8L3N2Zz4K');
background-size: contain;
background-repeat: no-repeat;
background-position: center;
opacity: 0.2;
z-index: 0;
}
// 提示文字
&__tip {
position: absolute;
top: 418px;
left: 50%;
transform: translateX(-50%);
z-index: 1;
padding: 8px 16px;
background: rgba(0, 0, 0, 0.5);
border-radius: 4px;
white-space: nowrap;
&_text {
font-family: 'PingFang SC';
font-weight: 400;
font-size: 15px;
line-height: 1.6;
color: #ffffff;
text-align: center;
}
}
// 按钮区域
&__buttons {
position: absolute;
bottom: 110px;
left: 0;
right: 0;
display: flex;
flex-direction: column;
gap: 10px;
padding: 0 20px;
z-index: 1;
align-items: center;
}
// 按钮
&__button {
display: flex;
justify-content: center;
align-items: center;
width: 251px;
height: 52px;
border-radius: 16px;
box-shadow: 0px 8px 64px 0px rgba(0, 0, 0, 0.1),
0px 4px 36px 0px rgba(0, 0, 0, 0.25);
backdrop-filter: blur(32px);
cursor: pointer;
transition: opacity 0.3s;
&:active {
opacity: 0.8;
}
// 主要按钮(去看看其他球局)
&--primary {
background: linear-gradient(154deg, rgba(255, 255, 255, 1) 0%, rgba(234, 234, 234, 1) 100%);
border: 2px solid rgba(0, 0, 0, 0.06);
}
// 次要按钮(返回首页)
&--secondary {
background: linear-gradient(154deg, rgba(255, 255, 255, 1) 0%, rgba(234, 234, 234, 1) 100%);
border: 2px solid rgba(0, 0, 0, 0.06);
}
&_text {
font-family: 'DingTalk JinBuTi';
font-weight: 400;
font-size: 18px;
line-height: 1.11;
letter-spacing: -0.05em;
text-align: center;
color: #000000;
}
}
}

View File

@@ -0,0 +1,95 @@
import React, { useState, useEffect } from 'react';
import { View, Text } from '@tarojs/components';
import Taro from '@tarojs/taro';
import { useGlobalState } from '@/store/global';
import { GeneralNavbar } from '@/components';
import './index.scss';
interface EmptyStateProps {
onGoToOtherGames?: () => void;
onGoToHome?: () => void;
}
const EmptyState: React.FC<EmptyStateProps> = ({ onGoToOtherGames, onGoToHome }) => {
const { statusNavbarHeightInfo } = useGlobalState() || {};
const { totalHeight = 98 } = statusNavbarHeightInfo || {};
const [countdown, setCountdown] = useState(5);
// 倒计时自动返回
useEffect(() => {
if (countdown <= 0) {
handle_go_to_home();
return;
}
const timer = setTimeout(() => {
setCountdown(countdown - 1);
}, 1000);
return () => clearTimeout(timer);
}, [countdown]);
// 跳转到其他球局
const handle_go_to_other_games = () => {
if (onGoToOtherGames) {
onGoToOtherGames();
} else {
Taro.switchTab({
url: '/main_pages/index',
});
}
};
// 返回首页
const handle_go_to_home = () => {
if (onGoToHome) {
onGoToHome();
} else {
const pages = Taro.getCurrentPages();
if (pages.length <= 1) {
Taro.switchTab({
url: '/main_pages/index',
});
} else {
Taro.navigateBack();
}
}
};
return (
<View className="empty_state_page" style={{ paddingTop: `${totalHeight}px` }}>
<GeneralNavbar title="" showBack={true} />
<View className="empty_state_page__content">
{/* 背景图片 */}
<View className="empty_state_page__bg_image" />
{/* 提示文字 */}
<View className="empty_state_page__tip">
<Text className="empty_state_page__tip_text">
{countdown}s
</Text>
</View>
{/* 按钮区域 */}
<View className="empty_state_page__buttons">
<View
className="empty_state_page__button empty_state_page__button--primary"
onClick={handle_go_to_other_games}
>
<Text className="empty_state_page__button_text"></Text>
</View>
<View
className="empty_state_page__button empty_state_page__button--secondary"
onClick={handle_go_to_home}
>
<Text className="empty_state_page__button_text"></Text>
</View>
</View>
</View>
</View>
);
};
export default EmptyState;

View File

@@ -22,6 +22,7 @@ import Participants from "./components/Participants";
import SupplementalNotes from "./components/SupplementalNotes";
import OrganizerInfo from "./components/OrganizerInfo";
import SharePopup from "./components/SharePopup";
import EmptyState from "./components/EmptyState";
import { navto, toast } from "@/utils/helper";
import ArrowLeft from "@/static/detail/icon-arrow-left.svg";
// import Logo from "@/static/detail/icon-logo-go.svg";
@@ -29,6 +30,7 @@ import styles from "./index.module.scss";
function Index() {
const [detail, setDetail] = useState<any>({});
const [showEmptyState, setShowEmptyState] = useState(false);
const { params } = useRouter();
const [currentLocation, setCurrentLocation] = useState<[number, number]>([
0, 0,
@@ -95,10 +97,11 @@ function Index() {
if (res.code === 0) {
setDetail(res.data);
fetchUserInfoById(res.data.publisher_id);
setShowEmptyState(false);
}
} catch (e) {
if (e.message === "球局不存在") {
handleBack();
setShowEmptyState(true);
}
}
Taro.hideLoading();
@@ -172,6 +175,20 @@ function Index() {
setGlass(top > 20);
}, 16);
// 如果显示空状态,渲染空状态页面
if (showEmptyState) {
return (
<EmptyState
onGoToOtherGames={() => {
Taro.switchTab({
url: '/main_pages/index',
});
}}
onGoToHome={handleBack}
/>
);
}
return (
<ScrollView
className={styles["detail-page"]}