forked from gxwebsoft/mp-10550
feat(order): 添加支付倒计时组件并优化订单相关功能
- 新增 PaymentCountdown 组件用于显示支付倒计时 - 实现 usePaymentCountdown Hook 以支持倒计时逻辑 - 添加 useOrderStats Hook 用于获取订单统计信息 - 在订单列表和详情页面集成支付倒计时功能 - 优化订单状态显示和相关操作逻辑
This commit is contained in:
@@ -9,6 +9,7 @@ import {ShopOrder, ShopOrderParam} from "@/api/shop/shopOrder/model";
|
||||
import {listShopOrderGoods} from "@/api/shop/shopOrderGoods";
|
||||
import {ShopOrderGoods} from "@/api/shop/shopOrderGoods/model";
|
||||
import {copyText} from "@/utils/common";
|
||||
import PaymentCountdown from "@/components/PaymentCountdown";
|
||||
|
||||
const getInfiniteUlStyle = (showSearch: boolean = false): CSSProperties => ({
|
||||
marginTop: showSearch ? '0' : '0', // 如果显示搜索框,增加更多的上边距
|
||||
@@ -188,7 +189,7 @@ function OrderList(props: OrderListProps) {
|
||||
|
||||
try {
|
||||
const res = await pageShopOrder(searchConditions);
|
||||
let newList: OrderWithGoods[] = [];
|
||||
let newList: OrderWithGoods[];
|
||||
|
||||
if (res?.list && res?.list.length > 0) {
|
||||
// 批量获取订单商品信息,限制并发数量
|
||||
@@ -261,7 +262,7 @@ function OrderList(props: OrderListProps) {
|
||||
Taro.showToast({
|
||||
title: '确认收货成功',
|
||||
});
|
||||
reload(true); // 重新加载列表
|
||||
await reload(true); // 重新加载列表
|
||||
props.onReload?.(); // 通知父组件刷新
|
||||
} catch (error) {
|
||||
Taro.showToast({
|
||||
@@ -293,7 +294,7 @@ function OrderList(props: OrderListProps) {
|
||||
title: '订单已取消',
|
||||
icon: 'success'
|
||||
});
|
||||
reload(true).then(); // 重新加载列表
|
||||
void reload(true); // 重新加载列表
|
||||
props.onReload?.(); // 通知父组件刷新
|
||||
} catch (error) {
|
||||
console.error('取消订单失败:', error);
|
||||
@@ -305,7 +306,7 @@ function OrderList(props: OrderListProps) {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
reload(true).then(); // 首次加载或tab切换时重置页码
|
||||
void reload(true); // 首次加载或tab切换时重置页码
|
||||
}, [tapIndex]); // 监听tapIndex变化
|
||||
|
||||
// 监听外部statusFilter变化,同步更新tab索引
|
||||
@@ -332,25 +333,7 @@ function OrderList(props: OrderListProps) {
|
||||
}
|
||||
}, [props.searchParams?.statusFilter]); // 监听statusFilter变化
|
||||
|
||||
useEffect(() => {
|
||||
// 当外部传入的搜索参数变化时(不包括statusFilter,因为上面已经处理)
|
||||
// 只有当搜索关键词等其他条件变化时才重新加载
|
||||
const {statusFilter, ...otherParams} = props.searchParams || {};
|
||||
|
||||
// 检查是否有除statusFilter外的其他搜索条件变化
|
||||
const hasOtherSearchParams = Object.keys(otherParams).some(key =>
|
||||
otherParams[key] !== undefined && otherParams[key] !== ''
|
||||
);
|
||||
|
||||
console.log('searchParams变化 (非statusFilter):', {
|
||||
otherParams,
|
||||
hasOtherSearchParams
|
||||
});
|
||||
|
||||
if (hasOtherSearchParams) {
|
||||
reload(true).then(); // 只有其他搜索条件变化时才重新加载
|
||||
}
|
||||
}, [props.searchParams?.keywords, props.searchParams?.orderNo]); // 只监听具体的搜索字段
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -367,7 +350,6 @@ function OrderList(props: OrderListProps) {
|
||||
}}
|
||||
value={tapIndex}
|
||||
onChange={(paneKey) => {
|
||||
console.log('Tab切换到:', paneKey, '对应状态:', tabs[paneKey]?.title, 'statusFilter:', tabs[paneKey]?.statusFilter);
|
||||
setTapIndex(paneKey)
|
||||
}}
|
||||
>
|
||||
@@ -428,11 +410,23 @@ function OrderList(props: OrderListProps) {
|
||||
onClick={() => Taro.navigateTo({url: `/shop/orderDetail/index?orderId=${item.orderId}`})}>
|
||||
<Space direction={'vertical'} className={'w-full flex flex-col'}>
|
||||
<View className={'order-no flex justify-between'}>
|
||||
<View className={'text-gray-600 font-bold text-sm'}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
copyText(`${item.orderNo}`)
|
||||
}}>{item.orderNo}</View>
|
||||
<View className={'flex items-center'}>
|
||||
<View className={'text-gray-600 font-bold text-sm'}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
copyText(`${item.orderNo}`)
|
||||
}}>{item.orderNo}</View>
|
||||
{/* 添加倒计时显示 - 列表页不实时更新 */}
|
||||
<View className="order-list-countdown">
|
||||
<PaymentCountdown
|
||||
createTime={item.createTime}
|
||||
payStatus={item.payStatus}
|
||||
realTime={false}
|
||||
showSeconds={false}
|
||||
mode="badge"
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<View className={`${getOrderStatusColor(item)} font-medium`}>{getOrderStatusText(item)}</View>
|
||||
</View>
|
||||
<div
|
||||
@@ -482,7 +476,7 @@ function OrderList(props: OrderListProps) {
|
||||
<Space>
|
||||
<Button size={'small'} onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
cancelOrder(item)
|
||||
void cancelOrder(item);
|
||||
}}>取消订单</Button>
|
||||
<Button size={'small'} type="primary" onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
@@ -494,7 +488,7 @@ function OrderList(props: OrderListProps) {
|
||||
{item.deliveryStatus === 20 && (
|
||||
<Button size={'small'} type="primary" onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
confirmReceive(item)
|
||||
void confirmReceive(item);
|
||||
}}>确认收货</Button>
|
||||
)}
|
||||
{/* 已完成状态:显示申请退款 */}
|
||||
|
||||
Reference in New Issue
Block a user