订单列表对接

This commit is contained in:
2022-05-27 20:34:13 +08:00
parent e73bd1bc25
commit b93b59332b
19 changed files with 236 additions and 111 deletions
+23 -12
View File
@@ -6,38 +6,46 @@ import { useCallback, useRef, memo } from "react"
import styles from './index.module.scss'
type Param = {
status?: number //订单状态
orderId?: number //订单id
status?: number, //订单状态
orderId: number, //订单id
onClick?: (val: number) => void //点击后触发的事件,返回订单状态
}
export default memo(({status = 0, orderId = 0}:Param) => {
export default memo(({status = 0, orderId = 0, onClick}:Param) => {
//订单按钮按订单状态归类
const orderBtnsList = useRef([
{
value: [0, 1, 2, 9, 3], //取消订单按钮对应: 待接单,待配布,已配布, 待付款, 待发货
id: 1,
value: [0, 1, 2, 3, 4], //取消订单按钮对应: 待接单,待配布,已配布, 待付款, 待发货
label: '取消订单'
},
{
value: [3, 9], //去付款按钮对应:待付款, 待发货
id: 2,
value: [3, 4], //去付款按钮对应:待付款, 待发货
label: '去付款'
},
{
value: [3], //取消订单按钮对应: 待发货
id: 3,
value: [4], //取消订单按钮对应: 待发货
label: '申请退款'
},
{
value: [4, 7, 8, 6], //取消订单按钮对应: 待收货, 已收货, 已完成, 已退款
id: 4,
value: [5, 6, 7, 8], //取消订单按钮对应: 待收货, 已收货, 已完成, 已退款
label: '查看物流'
},
{
value: [4, 7, 6], //取消订单按钮对应: 待收货, 已收货, 已退款
id: 5,
value: [5, 6, 8], //取消订单按钮对应: 待收货, 已收货, 已退款
label: '申请退货'
},
{
value: [4], //取消订单按钮对应: 待收货
id: 6,
value: [5], //取消订单按钮对应: 待收货
label: '确认收货'
},
{
value: [4,7,8,6], //取消订单按钮对应: 待收货,已收货,已完成, 已退款
id: 7,
value: [5,6,7,8], //取消订单按钮对应: 待收货,已收货,已完成, 已退款
label: '再次购买'
}
])
@@ -47,7 +55,9 @@ export default memo(({status = 0, orderId = 0}:Param) => {
//点击按钮操作
const submitBtns = (val) => {
if( val == 0 ) cancelOrder()
(val == 1)&&cancelOrder(); //取消订单按钮
(val == 2)&&onClick?.(val); //去付款按钮
}
//取消订单
@@ -60,6 +70,7 @@ export default memo(({status = 0, orderId = 0}:Param) => {
let res = await cancelFetchData({id: orderId})
if(res.success) {
alert.success('取消成功')
onClick?.(1)
} else {
alert.none(res.msg)
}
@@ -73,7 +84,7 @@ export default memo(({status = 0, orderId = 0}:Param) => {
return (
<View className={styles.btns_list}>
{orderBtnsList.current.map((item, index) =>
orderBtnsShow(item, status)&&<View className={styles.btns_item} onClick={() => submitBtns(index)}>{item.label}</View>
orderBtnsShow(item, status)&&<View className={styles.btns_item} onClick={() => submitBtns(item.id)}>{item.label}</View>
)}
</View>
)