fix: 修复订单详情页球局时间展示问题、修复候补列表NTRP文案缺失的问题
This commit is contained in:
@@ -489,7 +489,7 @@ export default function Participants(props) {
|
||||
<Text
|
||||
className={styles["participants-list-item-level"]}
|
||||
>
|
||||
{displayNtrp}
|
||||
NTRP {displayNtrp}
|
||||
</Text>
|
||||
<Text className={styles["participants-list-item-role"]}>
|
||||
{role}
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { useState, useRef } from "react";
|
||||
import { View, Text, Button, Image } from "@tarojs/components";
|
||||
import { Dialog } from "@nutui/nutui-react-taro";
|
||||
import Taro, { useDidShow, useRouter } from "@tarojs/taro";
|
||||
import dayjs from "dayjs";
|
||||
import dayjs, { Dayjs } from "dayjs";
|
||||
import "dayjs/locale/zh-cn";
|
||||
import classnames from "classnames";
|
||||
import orderService, {
|
||||
@@ -75,6 +75,45 @@ function genGameNotice(order_status, start_time) {
|
||||
return gameNoticeMap.get(key) || {};
|
||||
}
|
||||
|
||||
function genGameLength(startTime: Dayjs, endTime: Dayjs) {
|
||||
if (!startTime || !endTime) {
|
||||
return "";
|
||||
}
|
||||
const totalMinutes = endTime.diff(startTime, "minute");
|
||||
const totalHours = totalMinutes / 60;
|
||||
|
||||
if (totalHours >= 24) {
|
||||
const days = Math.floor(totalHours / 24);
|
||||
const remainingHours = totalHours % 24;
|
||||
|
||||
if (remainingHours === 0) {
|
||||
return `${days}天`;
|
||||
}
|
||||
|
||||
// 保留一位小数
|
||||
const displayHours = parseFloat(remainingHours.toFixed(1));
|
||||
return `${days}天${displayHours}小时`;
|
||||
}
|
||||
|
||||
// 如果是整数小时,不显示小数点
|
||||
if (Number.isInteger(totalHours)) {
|
||||
return `${totalHours}小时`;
|
||||
}
|
||||
// 保留一位小数,去除末尾的0
|
||||
return `${parseFloat(totalHours.toFixed(1))}小时`;
|
||||
}
|
||||
|
||||
function genGameRange(startTime: Dayjs, endTime: Dayjs) {
|
||||
if (!startTime || !endTime) {
|
||||
return "";
|
||||
}
|
||||
// 如果跨天(自然日)
|
||||
if (!startTime.isSame(endTime, "day")) {
|
||||
return `${startTime.format("HH:mm")} - ${endTime.format("MM月DD日 HH:mm")}`;
|
||||
}
|
||||
return `${startTime.format("HH:mm")} - ${endTime.format("HH:mm")}`;
|
||||
}
|
||||
|
||||
function GameInfo(props) {
|
||||
const { detail, currentLocation, orderDetail, init } = props;
|
||||
const { order_status, refund_status, amount, refund_amount } = orderDetail;
|
||||
@@ -111,15 +150,17 @@ function GameInfo(props) {
|
||||
|
||||
const startTime = dayjs(start_time);
|
||||
const endTime = dayjs(end_time);
|
||||
const game_length = Number(
|
||||
(endTime.diff(startTime, "minutes") / 60).toFixed(),
|
||||
);
|
||||
// const game_length = Number(
|
||||
// (endTime.diff(startTime, "minutes") / 60).toFixed(),
|
||||
// );
|
||||
const game_length = genGameLength(startTime, endTime);
|
||||
|
||||
const startMonth = startTime.format("M");
|
||||
const startDay = startTime.format("D");
|
||||
const theDayOfWeek = startTime.format("dddd");
|
||||
const startDate = `${startMonth}月${startDay}日 ${theDayOfWeek}`;
|
||||
const gameRange = `${startTime.format("HH:mm")} - ${endTime.format("HH:mm")}`;
|
||||
// const gameRange = `${startTime.format("HH:mm")} - ${endTime.format("HH:mm")}`;
|
||||
const gameRange = genGameRange(startTime, endTime);
|
||||
|
||||
const orderStatus = getOrderStatus(orderDetail);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user