格式化日期

This commit is contained in:
2025-10-20 16:32:48 +08:00
parent 9297263dbb
commit 801dfb2963
4 changed files with 227 additions and 196 deletions

View File

@@ -8,6 +8,7 @@ import "./index.scss";
const ListCard: React.FC<ListCardProps> = ({
id,
title,
original_start_time,
start_time,
end_time,
location,
@@ -25,15 +26,14 @@ const ListCard: React.FC<ListCardProps> = ({
venue_description,
game_type, // 球局类型
}) => {
// 参与者要前三个数据
const participantsImageList = participants?.slice(0, 3) || [];
// 场地 要第一个数据
// const venueImageList = venue_image_list?.slice(0, 1) || [];
const venueImage = venue_image_list?.[0]?.url || '';
const venueImage = venue_image_list?.[0]?.url || "";
// 是否显示畅打球局
const isShowSmoothPlayingGame = game_type === '畅打球局';
const isShowSmoothPlayingGame = game_type === "畅打球局";
const renderItemImage = (src: string) => {
return (
@@ -114,10 +114,13 @@ const ListCard: React.FC<ListCardProps> = ({
{/* 时间信息 */}
<View className="date-time">
<Text>{formatGameTime(start_time)}</Text>
<Text>{formatGameTime(original_start_time || start_time)}</Text>
{/* 时长 如 2小时 */}
{end_time && (
<Text> {calculateDuration(start_time, end_time)}</Text>
<Text>
{" "}
{calculateDuration(original_start_time || start_time, end_time)}
</Text>
)}
</View>
@@ -176,24 +179,23 @@ const ListCard: React.FC<ListCardProps> = ({
<View className="image-section">{renderImages()}</View>
</View>
{/* 畅打球局 */}
{isShowSmoothPlayingGame && <View className="smoothPlayingGame">
<View className="smoothWrapper">
<Image
src={img.ICON_LIST_PLAYING_GAME}
className="iconListPlayingGame"
/>
<Text className="smoothTitle">{game_type}</Text>
{isShowSmoothPlayingGame && (
<View className="smoothPlayingGame">
<View className="smoothWrapper">
<Image
src={img.ICON_LIST_PLAYING_GAME}
className="iconListPlayingGame"
/>
<Text className="smoothTitle">{game_type}</Text>
</View>
<View className="line" />
<View className="localAreaTitle">:</View>
<View className="localAreaWrapper">
<Image className="localArea" src={venueImage} />
<Text className="localAreaText">{venue_description}</Text>
</View>
</View>
<View className="line" />
<View className="localAreaTitle">:</View>
<View className="localAreaWrapper">
<Image
className="localArea"
src={venueImage}
/>
<Text className="localAreaText">{venue_description}</Text>
</View>
</View>}
)}
</View>
);
};