球局日期优化
This commit is contained in:
@@ -108,11 +108,12 @@ const OtherUserPage: React.FC = () => {
|
||||
const classifyGameRecords = (
|
||||
game_records: GameRecord[]
|
||||
): { notEndGames: GameRecord[]; finishedGames: GameRecord[] } => {
|
||||
const timestamp = new Date().getTime();
|
||||
const now = new Date().getTime();
|
||||
return game_records.reduce(
|
||||
(result, cur) => {
|
||||
const { end_time } = cur;
|
||||
timestamp > new Date(end_time).getTime()
|
||||
let { end_time } = cur;
|
||||
end_time = end_time.replace(/\s/, "T");
|
||||
new Date(end_time).getTime() > now
|
||||
? result.notEndGames.push(cur)
|
||||
: result.finishedGames.push(cur);
|
||||
return result;
|
||||
@@ -131,7 +132,11 @@ const OtherUserPage: React.FC = () => {
|
||||
user_id || "",
|
||||
active_tab
|
||||
);
|
||||
const { notEndGames, finishedGames } = classifyGameRecords(games_data);
|
||||
const sorted_games = games_data.sort((a, b) => {
|
||||
return new Date(b.start_time.replace(/\s/, 'T')).getTime() - new Date(a.start_time.replace(/\s/, 'T')).getTime();
|
||||
});
|
||||
console.log('xxxxxxxxxxxxxxxxxx', sorted_games)
|
||||
const { notEndGames, finishedGames } = classifyGameRecords(sorted_games);
|
||||
setGameRecords(notEndGames);
|
||||
setEndedGameRecords(finishedGames);
|
||||
} catch (error) {
|
||||
@@ -225,14 +230,14 @@ const OtherUserPage: React.FC = () => {
|
||||
|
||||
{/* 球局列表 */}
|
||||
<View className="game_list_section">
|
||||
<View className="date_header">
|
||||
{/* <View className="date_header">
|
||||
<Text className="date_text">5月29日</Text>
|
||||
<Text className="separator">/</Text>
|
||||
<Text className="weekday_text">星期六</Text>
|
||||
</View>
|
||||
</View> */}
|
||||
|
||||
{/* 球局列表 */}
|
||||
<View className="game_list_section">
|
||||
{/* <View className="game_list_section"> */}
|
||||
<ScrollView scrollY>
|
||||
<ListContainer
|
||||
data={game_records}
|
||||
@@ -243,7 +248,7 @@ const OtherUserPage: React.FC = () => {
|
||||
loadMoreMatches={() => {}}
|
||||
/>
|
||||
</ScrollView>
|
||||
</View>
|
||||
{/* </View> */}
|
||||
|
||||
{/* 球局卡片 */}
|
||||
{/* <View className="game_cards">
|
||||
@@ -260,14 +265,14 @@ const OtherUserPage: React.FC = () => {
|
||||
{/* 往期球局 */}
|
||||
<View className="ended_game_text">往期球局</View>
|
||||
<View className="game_list_section">
|
||||
<View className="date_header">
|
||||
{/* <View className="date_header">
|
||||
<Text className="date_text">5月29日</Text>
|
||||
<Text className="separator">/</Text>
|
||||
<Text className="weekday_text">星期六</Text>
|
||||
</View>
|
||||
</View> */}
|
||||
|
||||
{/* 球局列表 */}
|
||||
<View className="game_list_section">
|
||||
{/* <View className="game_list_section"> */}
|
||||
<ScrollView scrollY>
|
||||
<ListContainer
|
||||
data={ended_game_records}
|
||||
@@ -278,7 +283,7 @@ const OtherUserPage: React.FC = () => {
|
||||
loadMoreMatches={() => {}}
|
||||
/>
|
||||
</ScrollView>
|
||||
</View>
|
||||
{/* </View> */}
|
||||
|
||||
{/* 球局卡片 */}
|
||||
{/* <View className="game_cards">
|
||||
|
||||
Reference in New Issue
Block a user