From 58cf46e93dc19aac3207815f371e56ed30f0be77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=9D=B0?= Date: Fri, 20 Mar 2026 22:56:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E7=90=83=E5=B1=80=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E9=97=AE=E9=A2=98=E3=80=81=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=80=99=E8=A1=A5=E5=88=97=E8=A1=A8NTRP=E6=96=87=E6=A1=88?= =?UTF-8?q?=E7=BC=BA=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../detail/components/Participants/index.tsx | 2 +- src/order_pages/orderDetail/index.tsx | 51 +++++++++++++++++-- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/src/game_pages/detail/components/Participants/index.tsx b/src/game_pages/detail/components/Participants/index.tsx index 9c18c23..7b555cb 100644 --- a/src/game_pages/detail/components/Participants/index.tsx +++ b/src/game_pages/detail/components/Participants/index.tsx @@ -489,7 +489,7 @@ export default function Participants(props) { - {displayNtrp} + NTRP {displayNtrp} {role} diff --git a/src/order_pages/orderDetail/index.tsx b/src/order_pages/orderDetail/index.tsx index cc3c4e8..9f697d0 100644 --- a/src/order_pages/orderDetail/index.tsx +++ b/src/order_pages/orderDetail/index.tsx @@ -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);