feat(order): 优化订单列表展示逻辑
- 为 PaymentCountdown 组件添加背景渐变样式- 添加订单支付过期判断和过滤逻辑 - 优化订单列表项的样式和结构 -修复 invite.ts 中的若干问题
This commit is contained in:
@@ -18,19 +18,19 @@
|
|||||||
|
|
||||||
/* 紧急状态(少于1小时) */
|
/* 紧急状态(少于1小时) */
|
||||||
&.urgent {
|
&.urgent {
|
||||||
color: #ff6b6b;
|
background: linear-gradient(135deg, #ff6b6b, #ee5a52);
|
||||||
animation: pulse 2s infinite;
|
animation: pulse 2s infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 非常紧急状态(少于10分钟) */
|
/* 非常紧急状态(少于10分钟) */
|
||||||
&.critical {
|
&.critical {
|
||||||
color: #c44569;
|
background: linear-gradient(135deg, #ff4757, #c44569);
|
||||||
animation: flash 1s infinite;
|
animation: flash 1s infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 过期状态 */
|
/* 过期状态 */
|
||||||
&.expired {
|
&.expired {
|
||||||
color: #95a5a6;
|
background: linear-gradient(135deg, #95a5a6, #7f8c8d);
|
||||||
animation: none;
|
animation: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,15 @@ import {ShopOrderGoods} from "@/api/shop/shopOrderGoods/model";
|
|||||||
import {copyText} from "@/utils/common";
|
import {copyText} from "@/utils/common";
|
||||||
import PaymentCountdown from "@/components/PaymentCountdown";
|
import PaymentCountdown from "@/components/PaymentCountdown";
|
||||||
|
|
||||||
|
// 判断订单是否支付已过期
|
||||||
|
const isPaymentExpired = (createTime: string, timeoutHours: number = 24): boolean => {
|
||||||
|
if (!createTime) return false;
|
||||||
|
const createTimeObj = dayjs(createTime);
|
||||||
|
const expireTime = createTimeObj.add(timeoutHours, 'hour');
|
||||||
|
const now = dayjs();
|
||||||
|
return now.isAfter(expireTime);
|
||||||
|
};
|
||||||
|
|
||||||
const getInfiniteUlStyle = (showSearch: boolean = false): CSSProperties => ({
|
const getInfiniteUlStyle = (showSearch: boolean = false): CSSProperties => ({
|
||||||
marginTop: showSearch ? '0' : '0', // 如果显示搜索框,增加更多的上边距
|
marginTop: showSearch ? '0' : '0', // 如果显示搜索框,增加更多的上边距
|
||||||
height: showSearch ? '75vh' : '84vh', // 相应调整高度
|
height: showSearch ? '75vh' : '84vh', // 相应调整高度
|
||||||
@@ -363,10 +372,10 @@ function OrderList(props: OrderListProps) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
</Tabs>
|
</Tabs>
|
||||||
<div style={getInfiniteUlStyle(props.showSearch)} id="scroll">
|
<View style={getInfiniteUlStyle(props.showSearch)} id="scroll">
|
||||||
{error ? (
|
{error ? (
|
||||||
<div className="flex flex-col items-center justify-center h-64">
|
<View className="flex flex-col items-center justify-center h-64">
|
||||||
<div className="text-gray-500 mb-4">{error}</div>
|
<View className="text-gray-500 mb-4">{error}</View>
|
||||||
<Button
|
<Button
|
||||||
size="small"
|
size="small"
|
||||||
type="primary"
|
type="primary"
|
||||||
@@ -374,7 +383,7 @@ function OrderList(props: OrderListProps) {
|
|||||||
>
|
>
|
||||||
重新加载
|
重新加载
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</View>
|
||||||
) : (
|
) : (
|
||||||
<InfiniteLoading
|
<InfiniteLoading
|
||||||
target="scroll"
|
target="scroll"
|
||||||
@@ -403,21 +412,30 @@ function OrderList(props: OrderListProps) {
|
|||||||
>
|
>
|
||||||
|
|
||||||
{/* 订单列表 */}
|
{/* 订单列表 */}
|
||||||
{list.length > 0 && list?.map((item, index) => {
|
{list.length > 0 && list
|
||||||
|
?.filter((item) => {
|
||||||
|
// 如果是待付款标签页(tapIndex === 0),过滤掉支付已过期的订单
|
||||||
|
if (tapIndex === 0 && !item.payStatus && item.orderStatus !== 2 && item.createTime) {
|
||||||
|
return !isPaymentExpired(item.createTime);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
?.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
<Cell key={index} style={{padding: '16px'}}
|
<Cell key={index} style={{padding: '16px'}}
|
||||||
onClick={() => Taro.navigateTo({url: `/shop/orderDetail/index?orderId=${item.orderId}`})}>
|
onClick={() => Taro.navigateTo({url: `/shop/orderDetail/index?orderId=${item.orderId}`})}>
|
||||||
<Space direction={'vertical'} className={'w-full flex flex-col'}>
|
<Space direction={'vertical'} className={'w-full flex flex-col'}>
|
||||||
<View className={'order-no flex justify-between'}>
|
<View className={'order-no flex justify-between'}>
|
||||||
<View className={'flex items-center'}>
|
<View className={'flex items-center'}>
|
||||||
<View className={'text-gray-600 font-bold text-sm'}
|
<Text className={'text-gray-600 font-bold text-sm'}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
copyText(`${item.orderNo}`)
|
copyText(`${item.orderNo}`)
|
||||||
}}>{item.orderNo}</View>
|
}}>{item.orderNo}</Text>
|
||||||
</View>
|
</View>
|
||||||
|
{/* 右侧显示合并的状态和倒计时 */}
|
||||||
<View className={`${getOrderStatusColor(item)} font-medium`}>
|
<View className={`${getOrderStatusColor(item)} font-medium`}>
|
||||||
{item.orderStatus === 0 && (
|
{!item.payStatus && item.orderStatus !== 2 ? (
|
||||||
<PaymentCountdown
|
<PaymentCountdown
|
||||||
createTime={item.createTime}
|
createTime={item.createTime}
|
||||||
payStatus={item.payStatus}
|
payStatus={item.payStatus}
|
||||||
@@ -425,18 +443,19 @@ function OrderList(props: OrderListProps) {
|
|||||||
showSeconds={false}
|
showSeconds={false}
|
||||||
mode="text"
|
mode="text"
|
||||||
/>
|
/>
|
||||||
|
) : (
|
||||||
|
getOrderStatusText(item)
|
||||||
)}
|
)}
|
||||||
<Text>{getOrderStatusText(item)}</Text>
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<div
|
<View
|
||||||
className={'create-time text-gray-400 text-xs'}>{dayjs(item.createTime).format('YYYY年MM月DD日 HH:mm:ss')}</div>
|
className={'create-time text-gray-400 text-xs'}>{dayjs(item.createTime).format('YYYY年MM月DD日 HH:mm:ss')}</View>
|
||||||
|
|
||||||
{/* 商品信息 */}
|
{/* 商品信息 */}
|
||||||
<div className={'goods-info'}>
|
<View className={'goods-info'}>
|
||||||
{item.orderGoods && item.orderGoods.length > 0 ? (
|
{item.orderGoods && item.orderGoods.length > 0 ? (
|
||||||
item.orderGoods.map((goods, goodsIndex) => (
|
item.orderGoods.map((goods, goodsIndex) => (
|
||||||
<div key={goodsIndex} className={'flex items-center mb-2'}>
|
<View key={goodsIndex} className={'flex items-center mb-2'}>
|
||||||
<Image
|
<Image
|
||||||
src={goods.image || '/default-goods.png'}
|
src={goods.image || '/default-goods.png'}
|
||||||
width="50"
|
width="50"
|
||||||
@@ -444,30 +463,30 @@ function OrderList(props: OrderListProps) {
|
|||||||
lazyLoad={false}
|
lazyLoad={false}
|
||||||
className={'rounded'}
|
className={'rounded'}
|
||||||
/>
|
/>
|
||||||
<div className={'ml-2 flex-1'}>
|
<View className={'ml-2 flex flex-col flex-1'}>
|
||||||
<div className={'text-sm font-bold'}>{goods.goodsName}</div>
|
<Text className={'text-sm font-bold'}>{goods.goodsName}</Text>
|
||||||
{goods.spec && <div className={'text-gray-500 text-xs'}>规格:{goods.spec}</div>}
|
{goods.spec && <Text className={'text-gray-500 text-xs'}>规格:{goods.spec}</Text>}
|
||||||
<div className={'text-gray-500 text-xs'}>数量:{goods.totalNum}</div>
|
<Text className={'text-gray-500 text-xs'}>数量:{goods.totalNum}</Text>
|
||||||
</div>
|
</View>
|
||||||
<div className={'text-sm'}>¥{goods.price}</div>
|
<Text className={'text-sm'}>¥{goods.price}</Text>
|
||||||
</div>
|
</View>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
<div className={'flex items-center'}>
|
<View className={'flex items-center'}>
|
||||||
<Avatar
|
<Avatar
|
||||||
src='/default-goods.png'
|
src='/default-goods.png'
|
||||||
size={'50'}
|
size={'50'}
|
||||||
shape={'square'}
|
shape={'square'}
|
||||||
/>
|
/>
|
||||||
<div className={'ml-2'}>
|
<View className={'ml-2'}>
|
||||||
<div className={'text-sm'}>{item.title || '订单商品'}</div>
|
<Text className={'text-sm'}>{item.title || '订单商品'}</Text>
|
||||||
<div className={'text-gray-400 text-xs'}>{item.totalNum}件商品</div>
|
<Text className={'text-gray-400 text-xs'}>{item.totalNum}件商品</Text>
|
||||||
</div>
|
</View>
|
||||||
</div>
|
</View>
|
||||||
)}
|
)}
|
||||||
</div>
|
</View>
|
||||||
|
|
||||||
<div className={'w-full text-right'}>实付金额:¥{item.payPrice}</div>
|
<Text className={'w-full text-right'}>实付金额:¥{item.payPrice}</Text>
|
||||||
|
|
||||||
{/* 操作按钮 */}
|
{/* 操作按钮 */}
|
||||||
<Space className={'btn flex justify-end'}>
|
<Space className={'btn flex justify-end'}>
|
||||||
@@ -506,7 +525,7 @@ function OrderList(props: OrderListProps) {
|
|||||||
})}
|
})}
|
||||||
</InfiniteLoading>
|
</InfiniteLoading>
|
||||||
)}
|
)}
|
||||||
</div>
|
</View>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,11 @@ export function parseInviteParams(options: any): InviteParams | null {
|
|||||||
try {
|
try {
|
||||||
// 从 scene 参数中解析邀请信息
|
// 从 scene 参数中解析邀请信息
|
||||||
if (options.scene) {
|
if (options.scene) {
|
||||||
|
// 确保 scene 是字符串类型
|
||||||
|
const sceneStr = typeof options.scene === 'string' ? options.scene : String(options.scene)
|
||||||
|
|
||||||
const params: InviteParams = {}
|
const params: InviteParams = {}
|
||||||
const pairs = options.scene.split('&')
|
const pairs = sceneStr.split('&')
|
||||||
|
|
||||||
pairs.forEach((pair: string) => {
|
pairs.forEach((pair: string) => {
|
||||||
const [key, value] = pair.split('=')
|
const [key, value] = pair.split('=')
|
||||||
|
|||||||
Reference in New Issue
Block a user