From 545604d537c0269cc6a598a7d3d900dd5c0723ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=9D=B0?= Date: Thu, 18 Sep 2025 16:35:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=A2=E5=8D=95=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/order_pages/orderDetail/index.module.scss | 28 ++++++++++ src/order_pages/orderDetail/index.tsx | 52 ++++++++++++++----- src/order_pages/orderList/index.module.scss | 19 +++++++ src/order_pages/orderList/index.tsx | 44 ++++++++++------ src/utils/orderActions.ts | 2 +- 5 files changed, 114 insertions(+), 31 deletions(-) diff --git a/src/order_pages/orderDetail/index.module.scss b/src/order_pages/orderDetail/index.module.scss index abe0d98..136ae97 100644 --- a/src/order_pages/orderDetail/index.module.scss +++ b/src/order_pages/orderDetail/index.module.scss @@ -159,6 +159,34 @@ } } } + + .weather { + display: flex; + align-items: flex-end; + flex-direction: column; + gap: 4px; + + .weatherIcon { + width: 20px; + height: 20px; + color: rgba(0, 0, 0, 0.8); + } + + .temperature { + display: flex; + align-items: center; + gap: 12px; + color: rgba(0, 0, 0, 0.8); + font-feature-settings: + "liga" off, + "clig" off; + font-family: "PingFang SC"; + font-size: 12px; + font-style: normal; + font-weight: 400; + line-height: 20px; + } + } } &Place { diff --git a/src/order_pages/orderDetail/index.tsx b/src/order_pages/orderDetail/index.tsx index 6890c8a..716d386 100644 --- a/src/order_pages/orderDetail/index.tsx +++ b/src/order_pages/orderDetail/index.tsx @@ -18,7 +18,6 @@ import { getCurrentLocation, getOrderStatus, generateOrderActions, - reloadPage, } from "@/utils"; import detailService, { GameData } from "@/services/detailService"; import { withAuth, RefundPopup } from "@/components"; @@ -70,12 +69,14 @@ function genGameNotice(order_status, start_time) { } function GameInfo(props) { - const { detail, currentLocation, orderDetail } = props; - console.log(orderDetail, "orderDetail"); + const { detail, currentLocation, orderDetail, init } = props; + // console.log(orderDetail, "orderDetail"); const { order_status, refund_status } = orderDetail; - const { latitude, longitude, location, location_name, start_time, end_time } = + const { latitude, longitude, location, location_name, start_time, end_time, weather } = detail || {}; + const [{ iconDay, tempMax, tempMin }] = weather || [{}]; + const refundRef = useRef(null); const openMap = () => { @@ -116,7 +117,6 @@ function GameInfo(props) { async function handleDeleteOrder(item) { const { order_id } = item; - // TODO:删除订单,刷新这一页,然后后面的全清除掉 const onCancel = () => { Dialog.close("detailCancelOrder"); }; @@ -179,7 +179,7 @@ function GameInfo(props) { if (cancelRes.code !== 0) { throw new Error(cancelRes.message); } - reloadPage(); + init(); Taro.showToast({ title: "取消成功", icon: "none", @@ -219,7 +219,7 @@ function GameInfo(props) { if (refundRef.current) { refundRef.current.show(item, (result) => { if (result) { - reloadPage(); + init(); } }); } @@ -256,6 +256,21 @@ function GameInfo(props) { + + {/* Weather icon */} + + {/**/} + + + {/* Weather text and temperature */} + + {tempMin && tempMax && ( + + {tempMin}℃ - {tempMax}℃ + + )} + + {/* Place */} @@ -478,7 +493,11 @@ const OrderCheck = () => { const [checkOrderInfo, setCheckOrderInfo] = useState({}); const [orderDetail, setOrderDetail] = useState({}); - useDidShow(async () => { + useDidShow(() => { + init() + }); + + async function init() { let gameDetail = {}; if (id) { const res = await orderService.getOrderDetail(id); @@ -496,7 +515,7 @@ const OrderCheck = () => { setDetail(gameDetail); onInit(gameDetail.id); } - }); + } async function checkOrder(gid) { const orderRes = await orderService.getCheckOrderInfo(gid); @@ -528,28 +547,32 @@ const OrderCheck = () => { mask: true, }); + let payment_params = {} try { - const payment_params = await getPaymentParams(); + payment_params = await getPaymentParams(); await payOrder(payment_params); Taro.hideLoading(); Taro.showToast({ title: "支付成功", icon: "success", }); - await delay(1000); - Taro.navigateBack({ - delta: 1, - }); + // Taro.navigateBack({ + // delta: 1, + // }); } catch (error) { Taro.hideLoading(); Taro.showToast({ title: error.message, icon: "none", }); + } finally { + await delay(1000); if (!id) { Taro.redirectTo({ url: `/order_pages/orderDetail/index?id=${payment_params.order_id}`, }); + } else { + init() } } }; @@ -578,6 +601,7 @@ const OrderCheck = () => { detail={detail} orderDetail={orderDetail} currentLocation={location} + init={init} /> {/* Order message */} { async function handlePayNow(item) { try { - const unPaidRes = await orderService.getUnpaidOrder(item.game_info.id); + const unPaidRes = await orderService.getUnpaidOrder(item.game_info?.id); if (unPaidRes.code === 0 && unPaidRes.data.has_unpaid_order) { await payOrder(unPaidRes.data.payment_params); getOrders(item.page, false); @@ -116,6 +117,10 @@ const OrderList = () => { } function handleViewGame(gameId) { + if (!gameId) { + Taro.showToast({ title: "球局未找到", icon: "error" }); + return; + } Taro.navigateTo({ url: `/game_pages/detail/index?id=${gameId}&from=orderList`, }); @@ -253,19 +258,18 @@ const OrderList = () => { const unPay = item.order_status === OrderStatus.PENDING && item.cancel_type === CancelType.NONE; + const { game_info } = item; const { - game_info: { - skill_level_max, - skill_level_min, - play_type, - participants, - location_name, - current_players, - max_players, - court_type, - }, - } = item; + skill_level_max, + skill_level_min, + play_type, + participants, + location_name, + current_players, + max_players, + court_type, + } = game_info || {}; return ( @@ -286,7 +290,7 @@ const OrderList = () => { - {generateTimeMsg(item.game_info)} + {generateTimeMsg(item.game_info || {})} {insertDotInTags([location_name, court_type, "3.5km"]).map( @@ -296,7 +300,7 @@ const OrderList = () => { )} - {participants.length >= 0 ? ( + {participants?.length >= 0 ? ( { /* participants */ [ @@ -382,7 +386,15 @@ const OrderList = () => { ); })} - {end && 已经到底了~} + {list.length > 0 && end && ( + 已经到底了~ + )} + {list.length === 0 && ( + + + 暂时没有订单 + + )} diff --git a/src/utils/orderActions.ts b/src/utils/orderActions.ts index ef4be7f..4cef8e4 100644 --- a/src/utils/orderActions.ts +++ b/src/utils/orderActions.ts @@ -46,7 +46,7 @@ export function generateOrderActions(orderData, actions, scene) { const gameDetail = { text: '球局详情', className: 'gameDetail', - action: handleViewGame.bind(null, orderData.game_info.id), + action: handleViewGame.bind(null, orderData.game_info?.id), } const key = getOrderStatus(orderData)