fix(order): 优化订单状态判断与收货流程
- 移除货到付款场景下的"确认收款"按钮,统一使用"确认完成"操作设置 payStatus=true - 确认完成时新增设置 deliveryStatus=30(已收货)和 deliveryTime,保持与后台确认收货逻辑一致 - sendEndImg 字段改为 JSON 数组格式,兼容多图保存,避免 OSS URL 中逗号解析错误 - 修复 OrderCard.getCardStatus 判断顺序错误,确保 orderStatus=1(已完成)优先判定,区分已收货和待收货状态显示颜色与文案
This commit is contained in:
@@ -17,15 +17,18 @@ const UserPage: React.FC = () => {
|
||||
const [storeInfo, setStoreInfo] = useState<any>(null)
|
||||
|
||||
// 获取用户卡片统计(余额/积分/优惠券/礼品卡)
|
||||
// 使用 cacheKey 缓存 30s,页面返回时先显示缓存数据再静默刷新
|
||||
const { data: cardStats, run: runCardStats, loading: cardStatsLoading } = useRequest(getUserCardStats, {
|
||||
manual: true,
|
||||
refreshDeps: [isLoggedIn]
|
||||
cacheKey: 'user_card_stats',
|
||||
cacheTime: 30 * 1000,
|
||||
})
|
||||
|
||||
// 获取用户订单统计
|
||||
// 获取用户订单统计(缓存 30s,先缓存后静默刷新)
|
||||
const { data: orderStats, run: runOrderStats, loading: orderStatsLoading } = useRequest(getUserOrderStats, {
|
||||
manual: true,
|
||||
refreshDeps: [isLoggedIn]
|
||||
cacheKey: 'user_order_stats',
|
||||
cacheTime: 30 * 1000,
|
||||
})
|
||||
|
||||
// 登录后加载数据
|
||||
@@ -45,6 +48,7 @@ const UserPage: React.FC = () => {
|
||||
// 先从 storage 快速同步,立即更新 UI(无网络延迟)
|
||||
const hasUser = syncFromStorage()
|
||||
if (hasUser) {
|
||||
// 使用缓存:30s 内重复返回页面直接展示缓存数据,无需重新请求
|
||||
runCardStats()
|
||||
runOrderStats()
|
||||
// 刷新门店关联
|
||||
@@ -77,6 +81,10 @@ const UserPage: React.FC = () => {
|
||||
|
||||
const loading = cardStatsLoading || orderStatsLoading
|
||||
|
||||
// 是否有可用数据(缓存或请求结果),用于判断是否需要骨架屏
|
||||
const hasCardData = !!cardStats
|
||||
const hasOrderData = !!orderStats
|
||||
|
||||
// 下拉刷新状态
|
||||
const [refreshing, setRefreshing] = useState(false)
|
||||
|
||||
@@ -118,8 +126,8 @@ const UserPage: React.FC = () => {
|
||||
{isLoggedIn && (
|
||||
<View className='grid grid-cols-3 gap-2 mt-4 pt-4 border-t border-gray-50'>
|
||||
<View className='text-center' onClick={() => Taro.navigateTo({ url: '/pages/user/wallet' })}>
|
||||
{loading ? (
|
||||
<Text className='text-lg font-bold text-gray-300 block'>...</Text>
|
||||
{!hasCardData ? (
|
||||
<View className='h-7 w-16 mx-auto bg-gray-200 rounded animate-pulse' />
|
||||
) : (
|
||||
<Text className='text-lg font-bold text-gray-800 block'>
|
||||
{cardStats?.balance || '0.00'}
|
||||
@@ -128,8 +136,8 @@ const UserPage: React.FC = () => {
|
||||
<Text className='text-xs text-gray-400'>余额</Text>
|
||||
</View>
|
||||
<View className='text-center' onClick={() => Taro.navigateTo({ url: '/pages/user/points-record' })}>
|
||||
{loading ? (
|
||||
<Text className='text-lg font-bold text-gray-300 block'>...</Text>
|
||||
{!hasCardData ? (
|
||||
<View className='h-7 w-10 mx-auto bg-gray-200 rounded animate-pulse' />
|
||||
) : (
|
||||
<Text className='text-lg font-bold text-gray-800 block'>
|
||||
{cardStats?.points || (user as any)?.points || 0}
|
||||
@@ -138,8 +146,8 @@ const UserPage: React.FC = () => {
|
||||
<Text className='text-xs text-gray-400'>积分</Text>
|
||||
</View>
|
||||
<View className='text-center' onClick={() => Taro.navigateTo({ url: '/pages/user/coupon-list' })}>
|
||||
{loading ? (
|
||||
<Text className='text-lg font-bold text-gray-300 block'>...</Text>
|
||||
{!hasCardData ? (
|
||||
<View className='h-7 w-10 mx-auto bg-gray-200 rounded animate-pulse' />
|
||||
) : (
|
||||
<Text className='text-lg font-bold text-gray-800 block'>
|
||||
{cardStats?.coupons || 0}
|
||||
|
||||
Reference in New Issue
Block a user