排球联赛
This commit is contained in:
@@ -38,6 +38,7 @@ export function MatchCardLeague({
|
||||
setIsFav(match.fav);
|
||||
}, [match.fav]);
|
||||
|
||||
const isTennis = match.sportId === 3;
|
||||
const isDark = theme === "dark";
|
||||
const textColor = isDark ? Colors.dark.text : Colors.light.text;
|
||||
const secondaryText = isDark ? "#8E8E93" : "#6B7280";
|
||||
@@ -86,7 +87,29 @@ export function MatchCardLeague({
|
||||
};
|
||||
|
||||
const scoreParts = React.useMemo(() => {
|
||||
const s = (match.scoreText || "").trim();
|
||||
let s = (match.scoreText || "").trim();
|
||||
|
||||
// 对于网球,如果 scoreText 为空或 -,尝试从 scores 字段获取
|
||||
if (isTennis && (s === "" || s === "-")) {
|
||||
try {
|
||||
const scoresArr = typeof (match as any).scores === 'string'
|
||||
? JSON.parse((match as any).scores || "[]")
|
||||
: (match as any).scores;
|
||||
if (Array.isArray(scoresArr) && scoresArr.length > 0) {
|
||||
const lastSet = scoresArr[scoresArr.length - 1];
|
||||
const h = parseInt(lastSet.score_first, 10);
|
||||
const a = parseInt(lastSet.score_second, 10);
|
||||
return {
|
||||
home: lastSet.score_first || "0",
|
||||
away: lastSet.score_second || "0",
|
||||
hasScore: true,
|
||||
homeLead: Number.isFinite(h) && Number.isFinite(a) && h > a,
|
||||
awayLead: Number.isFinite(h) && Number.isFinite(a) && a > h,
|
||||
};
|
||||
}
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
const m = s.match(/(\d+)\s*[-:]\s*(\d+)/);
|
||||
if (m) {
|
||||
const homeNum = parseInt(m[1], 10);
|
||||
@@ -157,29 +180,37 @@ export function MatchCardLeague({
|
||||
<View style={styles.teamsColumn}>
|
||||
<View style={styles.teamRow}>
|
||||
<Image
|
||||
source={{ uri: (match as any).homeLogo || match.homeTeamLogo || "https://placehold.co/24x24/png" }}
|
||||
source={{
|
||||
uri: isTennis
|
||||
? (match as any).eventFirstPlayerLogo
|
||||
: ((match as any).homeLogo || match.homeTeamLogo || "https://placehold.co/24x24/png")
|
||||
}}
|
||||
style={styles.teamLogo}
|
||||
/>
|
||||
<View style={styles.teamNameContainer}>
|
||||
<ThemedText style={[styles.teamName, { color: textColor }]} numberOfLines={1}>
|
||||
{match.home || match.homeTeamName}
|
||||
{isTennis ? (match as any).eventFirstPlayer : (match.home || match.homeTeamName)}
|
||||
</ThemedText>
|
||||
{showCards && homeYellowCards > 0 && <View style={[styles.cardBadge, styles.yellowCard]} />}
|
||||
{showCards && homeRedCards > 0 && <View style={[styles.cardBadge, styles.redCard]} />}
|
||||
{!isTennis && showCards && homeYellowCards > 0 && <View style={[styles.cardBadge, styles.yellowCard]} />}
|
||||
{!isTennis && showCards && homeRedCards > 0 && <View style={[styles.cardBadge, styles.redCard]} />}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View style={[styles.teamRow, { marginTop: 10 }]}>
|
||||
<Image
|
||||
source={{ uri: (match as any).awayLogo || match.awayTeamLogo || "https://placehold.co/24x24/png" }}
|
||||
source={{
|
||||
uri: isTennis
|
||||
? (match as any).eventSecondPlayerLogo
|
||||
: ((match as any).awayLogo || match.awayTeamLogo || "https://placehold.co/24x24/png")
|
||||
}}
|
||||
style={styles.teamLogo}
|
||||
/>
|
||||
<View style={styles.teamNameContainer}>
|
||||
<ThemedText style={[styles.teamName, { color: textColor }]} numberOfLines={1}>
|
||||
{match.away || match.awayTeamName}
|
||||
{isTennis ? (match as any).eventSecondPlayer : (match.away || match.awayTeamName)}
|
||||
</ThemedText>
|
||||
{showCards && awayYellowCards > 0 && <View style={[styles.cardBadge, styles.yellowCard]} />}
|
||||
{showCards && awayRedCards > 0 && <View style={[styles.cardBadge, styles.redCard]} />}
|
||||
{!isTennis && showCards && awayYellowCards > 0 && <View style={[styles.cardBadge, styles.yellowCard]} />}
|
||||
{!isTennis && showCards && awayRedCards > 0 && <View style={[styles.cardBadge, styles.redCard]} />}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user