diff --git a/src/components/orderBtns/index.tsx b/src/components/orderBtns/index.tsx index 736fd9d..4ae23d6 100644 --- a/src/components/orderBtns/index.tsx +++ b/src/components/orderBtns/index.tsx @@ -6,14 +6,16 @@ import { useCallback, useRef, memo } from "react" import styles from './index.module.scss' type Param = { - status?: number, //订单状态 - orderId: number, //订单id - payModel: number, //支付方式 - realPayPrice: number, //实付金额 - pendingPayPrice: number, //待付金额 + orderInfo: { + status?: number, //订单状态 + orderId: number, //订单id + payModel: number, //支付方式 + realPayPrice: number, //实付金额 + pendingPayPrice: number, //待付金额 + }, onClick?: (val: number) => void //点击后触发的事件,返回订单状态 } -export default memo(({status = 0, orderId = 0, onClick, realPayPrice = 0, pendingPayPrice = 0}:Param) => { +export default memo(({orderInfo, onClick}:Param) => { //订单按钮按订单状态归类 const orderBtnsList = useRef([ { @@ -55,10 +57,10 @@ export default memo(({status = 0, orderId = 0, onClick, realPayPrice = 0, pendin //判断是否显示该按钮 const orderBtnsShow = useCallback((item, status) => { if(item.id == 1) { - return( realPayPrice == 0 && status <= 4) //在代发货之前没有付过款 + return( orderInfo.realPayPrice == 0 && status <= 4) //在代发货之前没有付过款 } if(item.id == 2) { - return( pendingPayPrice != 0 && status <= 4) //在代发货之前没有付完款 + return( orderInfo.pendingPayPrice != 0 && status <= 4) //在代发货之前没有付完款 } return item.value.includes(status) },[]) @@ -76,7 +78,7 @@ export default memo(({status = 0, orderId = 0, onClick, realPayPrice = 0, pendin title: '要取消该订单吗?', success: async function (res) { if (res.confirm) { - let res = await cancelFetchData({id: orderId}) + let res = await cancelFetchData({id: orderInfo.orderId}) if(res.success) { alert.success('取消成功') onClick?.(1) diff --git a/src/pages/order/index.tsx b/src/pages/order/index.tsx index c5043d5..abeee6e 100644 --- a/src/pages/order/index.tsx +++ b/src/pages/order/index.tsx @@ -162,6 +162,17 @@ import styles from './index.module.scss' setPayMentShow(() => false) }, [orderDetail]) + //按钮所需数据 + const orderInfo = useMemo(() => { + return { + status: orderDetail?.status, + orderId: orderDetail?.id, + payModel: orderDetail?.id, //支付方式 + realPayPrice: orderDetail?.id, //实付金额 + pendingPayPrice: orderDetail?.id, //待付金额 + } + }, [orderDetail]) + return ( {/* @@ -196,7 +207,7 @@ import styles from './index.module.scss' - + {/* toPay()}>去支付 */} setShowDesc(false)} >