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