feat: refund policy 从订单接口获取、梳理订单操作按钮

This commit is contained in:
2025-12-10 20:08:13 +08:00
parent 7b620210a2
commit 46a59ba282
3 changed files with 47 additions and 41 deletions

View File

@@ -380,8 +380,13 @@ function OrderMsg(props) {
wechat_contact,
price,
} = detail;
const { order_no } = orderDetail;
const { order_info: { registrant_phone } = {} } = checkOrderInfo;
const { order_no, registrant_phone: registrant_phone_from_order } =
orderDetail;
const {
order_info: { registrant_phone: registrant_phone_from_check_order } = {},
} = checkOrderInfo || {};
const registrant_phone =
registrant_phone_from_order || registrant_phone_from_check_order;
const startTime = dayjs(start_time);
const endTime = dayjs(end_time);
const startDate = startTime.format("YYYY年M月D日");
@@ -402,13 +407,11 @@ function OrderMsg(props) {
},
{
title: "报名人电话",
// content: registrant_phone,
content: registrant_phone ? (
<Text
selectable={true} // 支持长按复制
style={{
color: "#007AFF",
// textDecoration: "underline",
cursor: "pointer",
}}
onClick={() => {
@@ -427,7 +430,6 @@ function OrderMsg(props) {
},
{
title: "组织人电话",
// content: wechat_contact,
content:
wechat_contact && isPhoneNumber(wechat_contact) ? (
<Text
@@ -489,8 +491,7 @@ function OrderMsg(props) {
}
function RefundPolicy(props) {
const { checkOrderInfo } = props;
const { refund_policy = [] } = checkOrderInfo;
const { refund_policy = [] } = props;
const current = dayjs();
const policyList = [
{
@@ -563,7 +564,7 @@ const OrderCheck = () => {
const [id, gameId] = [Number(stringId), Number(stringGameId)];
const [detail, setDetail] = useState<GameData | {}>({});
const [location, setLocation] = useState<number[]>([0, 0]);
const [checkOrderInfo, setCheckOrderInfo] = useState<GameOrderRes | {}>({});
const [checkOrderInfo, setCheckOrderInfo] = useState<GameOrderRes>();
const [orderDetail, setOrderDetail] = useState({});
const { paying, setPaying } = useOrder();
@@ -584,11 +585,11 @@ const OrderCheck = () => {
if (res.code === 0) {
gameDetail = res.data;
}
checkOrder(gameId);
}
if (gameDetail.id) {
setDetail(gameDetail);
onInit(gameDetail.id);
}
setDetail(gameDetail);
const location = await getCurrentLocation();
setLocation([location.latitude, location.longitude]);
}
async function checkOrder(gid) {
@@ -596,12 +597,6 @@ const OrderCheck = () => {
setCheckOrderInfo(orderRes.data);
}
async function onInit(gid) {
checkOrder(gid);
const location = await getCurrentLocation();
setLocation([location.latitude, location.longitude]);
}
async function getPaymentParams() {
// 检查登录状态和手机号(创建订单前检查)
if (!requireLoginWithPhone()) {
@@ -706,23 +701,27 @@ const OrderCheck = () => {
checkOrderInfo={checkOrderInfo}
/>
{/* Refund policy */}
<RefundPolicy checkOrderInfo={checkOrderInfo} />
<RefundPolicy
refund_policy={
checkOrderInfo?.refund_policy || orderDetail?.refund_policy || []
}
/>
{/* Disclaimer */}
<Disclaimer />
{(!id ||
(order_status === OrderStatus.PENDING &&
cancel_type === CancelType.NONE)) && (
<Button
className={styles.payButton}
disabled={paying}
onClick={handlePay}
loading={paying}
>
{paying
? "支付中..."
: `${order_status === OrderStatus.PENDING ? "继续" : "确认"}支付`}
</Button>
)}
<Button
className={styles.payButton}
disabled={paying}
onClick={handlePay}
loading={paying}
>
{paying
? "支付中..."
: `${order_status === OrderStatus.PENDING ? "继续" : "确认"}支付`}
</Button>
)}
</View>
);
};