feat: refund policy 从订单接口获取、梳理订单操作按钮
This commit is contained in:
@@ -46,8 +46,7 @@ function genRefundNotice(refund_policy) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderCancelContent(checkOrderInfo) {
|
function renderCancelContent(refund_policy = []) {
|
||||||
const { refund_policy = [] } = checkOrderInfo;
|
|
||||||
const current = dayjs();
|
const current = dayjs();
|
||||||
const policyList = [
|
const policyList = [
|
||||||
{
|
{
|
||||||
@@ -65,7 +64,6 @@ function renderCancelContent(checkOrderInfo) {
|
|||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
console.log("policyList", policyList);
|
|
||||||
const targetIndex = policyList.findIndex((item) => item.beforeCurrent);
|
const targetIndex = policyList.findIndex((item) => item.beforeCurrent);
|
||||||
const { notice } = genRefundNotice(refund_policy);
|
const { notice } = genRefundNotice(refund_policy);
|
||||||
return (
|
return (
|
||||||
@@ -107,7 +105,7 @@ export type RefundRef = {
|
|||||||
|
|
||||||
export default forwardRef<RefundRef>(function RefundPopup(_props, ref) {
|
export default forwardRef<RefundRef>(function RefundPopup(_props, ref) {
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const [checkOrderInfo, setCheckOrderInfo] = useState({});
|
const [refundPolicy, setRefundPolicy] = useState([]);
|
||||||
const [orderData, setOrderData] = useState({});
|
const [orderData, setOrderData] = useState({});
|
||||||
const onDown = useRef<((result: boolean) => void) | null>(null);
|
const onDown = useRef<((result: boolean) => void) | null>(null);
|
||||||
|
|
||||||
@@ -116,11 +114,10 @@ export default forwardRef<RefundRef>(function RefundPopup(_props, ref) {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
async function onShow(orderItem, onFinish: (result: boolean) => void) {
|
async function onShow(orderItem, onFinish: (result: boolean) => void) {
|
||||||
const { game_info } = orderItem;
|
const { refund_policy } = orderItem;
|
||||||
onDown.current = onFinish;
|
onDown.current = onFinish;
|
||||||
setOrderData(orderItem);
|
setOrderData(orderItem);
|
||||||
const res = await orderService.getCheckOrderInfo(game_info.id);
|
setRefundPolicy(refund_policy);
|
||||||
setCheckOrderInfo(res.data);
|
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +169,7 @@ export default forwardRef<RefundRef>(function RefundPopup(_props, ref) {
|
|||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
{renderCancelContent(checkOrderInfo)}
|
{renderCancelContent(refundPolicy)}
|
||||||
<Button className={styles.action} onClick={handleConfirmQuit}>
|
<Button className={styles.action} onClick={handleConfirmQuit}>
|
||||||
确认并退出
|
确认并退出
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -380,8 +380,13 @@ function OrderMsg(props) {
|
|||||||
wechat_contact,
|
wechat_contact,
|
||||||
price,
|
price,
|
||||||
} = detail;
|
} = detail;
|
||||||
const { order_no } = orderDetail;
|
const { order_no, registrant_phone: registrant_phone_from_order } =
|
||||||
const { order_info: { registrant_phone } = {} } = checkOrderInfo;
|
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 startTime = dayjs(start_time);
|
||||||
const endTime = dayjs(end_time);
|
const endTime = dayjs(end_time);
|
||||||
const startDate = startTime.format("YYYY年M月D日");
|
const startDate = startTime.format("YYYY年M月D日");
|
||||||
@@ -402,13 +407,11 @@ function OrderMsg(props) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "报名人电话",
|
title: "报名人电话",
|
||||||
// content: registrant_phone,
|
|
||||||
content: registrant_phone ? (
|
content: registrant_phone ? (
|
||||||
<Text
|
<Text
|
||||||
selectable={true} // 支持长按复制
|
selectable={true} // 支持长按复制
|
||||||
style={{
|
style={{
|
||||||
color: "#007AFF",
|
color: "#007AFF",
|
||||||
// textDecoration: "underline",
|
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -427,7 +430,6 @@ function OrderMsg(props) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "组织人电话",
|
title: "组织人电话",
|
||||||
// content: wechat_contact,
|
|
||||||
content:
|
content:
|
||||||
wechat_contact && isPhoneNumber(wechat_contact) ? (
|
wechat_contact && isPhoneNumber(wechat_contact) ? (
|
||||||
<Text
|
<Text
|
||||||
@@ -489,8 +491,7 @@ function OrderMsg(props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function RefundPolicy(props) {
|
function RefundPolicy(props) {
|
||||||
const { checkOrderInfo } = props;
|
const { refund_policy = [] } = props;
|
||||||
const { refund_policy = [] } = checkOrderInfo;
|
|
||||||
const current = dayjs();
|
const current = dayjs();
|
||||||
const policyList = [
|
const policyList = [
|
||||||
{
|
{
|
||||||
@@ -563,7 +564,7 @@ const OrderCheck = () => {
|
|||||||
const [id, gameId] = [Number(stringId), Number(stringGameId)];
|
const [id, gameId] = [Number(stringId), Number(stringGameId)];
|
||||||
const [detail, setDetail] = useState<GameData | {}>({});
|
const [detail, setDetail] = useState<GameData | {}>({});
|
||||||
const [location, setLocation] = useState<number[]>([0, 0]);
|
const [location, setLocation] = useState<number[]>([0, 0]);
|
||||||
const [checkOrderInfo, setCheckOrderInfo] = useState<GameOrderRes | {}>({});
|
const [checkOrderInfo, setCheckOrderInfo] = useState<GameOrderRes>();
|
||||||
const [orderDetail, setOrderDetail] = useState({});
|
const [orderDetail, setOrderDetail] = useState({});
|
||||||
const { paying, setPaying } = useOrder();
|
const { paying, setPaying } = useOrder();
|
||||||
|
|
||||||
@@ -584,11 +585,11 @@ const OrderCheck = () => {
|
|||||||
if (res.code === 0) {
|
if (res.code === 0) {
|
||||||
gameDetail = res.data;
|
gameDetail = res.data;
|
||||||
}
|
}
|
||||||
|
checkOrder(gameId);
|
||||||
}
|
}
|
||||||
if (gameDetail.id) {
|
setDetail(gameDetail);
|
||||||
setDetail(gameDetail);
|
const location = await getCurrentLocation();
|
||||||
onInit(gameDetail.id);
|
setLocation([location.latitude, location.longitude]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkOrder(gid) {
|
async function checkOrder(gid) {
|
||||||
@@ -596,12 +597,6 @@ const OrderCheck = () => {
|
|||||||
setCheckOrderInfo(orderRes.data);
|
setCheckOrderInfo(orderRes.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onInit(gid) {
|
|
||||||
checkOrder(gid);
|
|
||||||
const location = await getCurrentLocation();
|
|
||||||
setLocation([location.latitude, location.longitude]);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getPaymentParams() {
|
async function getPaymentParams() {
|
||||||
// 检查登录状态和手机号(创建订单前检查)
|
// 检查登录状态和手机号(创建订单前检查)
|
||||||
if (!requireLoginWithPhone()) {
|
if (!requireLoginWithPhone()) {
|
||||||
@@ -706,23 +701,27 @@ const OrderCheck = () => {
|
|||||||
checkOrderInfo={checkOrderInfo}
|
checkOrderInfo={checkOrderInfo}
|
||||||
/>
|
/>
|
||||||
{/* Refund policy */}
|
{/* Refund policy */}
|
||||||
<RefundPolicy checkOrderInfo={checkOrderInfo} />
|
<RefundPolicy
|
||||||
|
refund_policy={
|
||||||
|
checkOrderInfo?.refund_policy || orderDetail?.refund_policy || []
|
||||||
|
}
|
||||||
|
/>
|
||||||
{/* Disclaimer */}
|
{/* Disclaimer */}
|
||||||
<Disclaimer />
|
<Disclaimer />
|
||||||
{(!id ||
|
{(!id ||
|
||||||
(order_status === OrderStatus.PENDING &&
|
(order_status === OrderStatus.PENDING &&
|
||||||
cancel_type === CancelType.NONE)) && (
|
cancel_type === CancelType.NONE)) && (
|
||||||
<Button
|
<Button
|
||||||
className={styles.payButton}
|
className={styles.payButton}
|
||||||
disabled={paying}
|
disabled={paying}
|
||||||
onClick={handlePay}
|
onClick={handlePay}
|
||||||
loading={paying}
|
loading={paying}
|
||||||
>
|
>
|
||||||
{paying
|
{paying
|
||||||
? "支付中..."
|
? "支付中..."
|
||||||
: `${order_status === OrderStatus.PENDING ? "继续" : "确认"}支付`}
|
: `${order_status === OrderStatus.PENDING ? "继续" : "确认"}支付`}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,18 +6,28 @@ export function getOrderStatus(orderData) {
|
|||||||
if (!order_no) {
|
if (!order_no) {
|
||||||
return 'none'
|
return 'none'
|
||||||
}
|
}
|
||||||
const { start_time } = game_info
|
const { start_time } = game_info || {}
|
||||||
|
if (!start_time) { console.log('活动开始时间未找到, start_time: ', start_time); }
|
||||||
const unPay = order_status === OrderStatus.PENDING && ([CancelType.NONE].includes(cancel_type));
|
const unPay = order_status === OrderStatus.PENDING && ([CancelType.NONE].includes(cancel_type));
|
||||||
const refund = [RefundStatus.SUCCESS].includes(refund_status);
|
const refund = [RefundStatus.SUCCESS].includes(refund_status);
|
||||||
const refunding = [RefundStatus.PENDING].includes(refund_status);
|
const refunding = [RefundStatus.PENDING].includes(refund_status);
|
||||||
const expired =
|
const expired =
|
||||||
order_status === OrderStatus.FINISHED;
|
order_status === OrderStatus.FINISHED;
|
||||||
|
|
||||||
const frozen = dayjs().add(2, 'h').isAfter(dayjs(start_time))
|
const frozen = dayjs().isAfter(dayjs(start_time))
|
||||||
|
|
||||||
const canceled = [CancelType.TIMEOUT, CancelType.USER].includes(cancel_type);
|
const canceled = [CancelType.TIMEOUT, CancelType.USER].includes(cancel_type);
|
||||||
|
|
||||||
return unPay ? 'unpay' : refund ? 'refund' : canceled ? 'canceled' : expired ? 'expired' : refunding ? 'refunding' : frozen ? 'start' : 'progress'
|
// return unPay ? 'unpay' : refund ? 'refund' : canceled ? 'canceled' : expired ? 'expired' : refunding ? 'refunding' : is_substitute_order ? 'progress' : frozen ? 'start' : 'progress'
|
||||||
|
if (unPay) return 'unpay';
|
||||||
|
if (refund) return 'refund';
|
||||||
|
if (canceled) return 'canceled';
|
||||||
|
if (expired) return 'expired';
|
||||||
|
if (refunding) return 'refunding';
|
||||||
|
if (frozen) return 'start';
|
||||||
|
// if (is_substitute_order) return 'progress';
|
||||||
|
return 'progress';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// scene: list、detail
|
// scene: list、detail
|
||||||
|
|||||||
Reference in New Issue
Block a user