Files
mp-10550/src/store/orders/index.tsx
赵忠林 dea40268fe refactor(order): 优化订单列表性能并移除冗余推荐人信息
- 移除经销商页面中的推荐人显示信息
- 将订单商品详情从单独接口请求改为直接从分页接口获取,避免N+1查询问题
- 添加normalizeOrderGoodsList函数实现订单商品数据结构标准化
- 统一门店名称文字颜色样式为灰色
- 简化支付工具类中的重复API端点调用
2026-02-01 11:51:28 +08:00

84 lines
2.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import {useEffect, useMemo, useState} from 'react'
import Taro from '@tarojs/taro'
import {Button} from '@nutui/nutui-react-taro'
import {View, Text} from '@tarojs/components'
import OrderList from '@/user/order/components/OrderList'
import {getSelectedStoreFromStorage} from '@/utils/storeSelection'
import {listShopStoreUser} from '@/api/shop/shopStoreUser'
export default function StoreOrders() {
const [boundStoreId, setBoundStoreId] = useState<number | undefined>(undefined)
const isLoggedIn = useMemo(() => {
return !!Taro.getStorageSync('access_token') && !!Taro.getStorageSync('UserId')
}, [])
const selectedStore = useMemo(() => getSelectedStoreFromStorage(), [])
const storeId = boundStoreId || selectedStore?.id
useEffect(() => {
}, [])
useEffect(() => {
// 优先按“店员绑定关系”确定门店归属:门店看到的是自己的订单
const userId = Number(Taro.getStorageSync('UserId'))
if (!Number.isFinite(userId) || userId <= 0) return
listShopStoreUser({userId}).then(list => {
const first = (list || []).find(i => i?.isDelete !== 1 && i?.storeId)
if (first?.storeId) setBoundStoreId(first.storeId)
}).catch(() => {
// fallback to SelectedStore
})
}, [])
if (!isLoggedIn) {
return (
<View className="bg-gray-50 min-h-screen p-4">
<View className="bg-white rounded-lg p-4">
<Text className="text-sm text-gray-700"></Text>
<View className="mt-3">
<Button type="primary" size="small" onClick={() => Taro.navigateTo({url: '/passport/login'})}>
</Button>
</View>
</View>
</View>
)
}
return (
<View className="bg-gray-50 min-h-screen">
<View className="px-3">
<View className="bg-white rounded-lg p-3 mb-3">
<Text className="text-sm text-gray-400"></Text>
<Text className="text-base font-medium">
{boundStoreId
? (selectedStore?.id === boundStoreId ? (selectedStore?.name || `门店ID: ${boundStoreId}`) : `门店ID: ${boundStoreId}`)
: (selectedStore?.name || '未选择门店')}
</Text>
</View>
{!storeId ? (
<View className="bg-white rounded-lg p-4">
<Text className="text-sm text-gray-600">
</Text>
<View className="mt-3">
<Button
type="primary"
size="small"
onClick={() => Taro.switchTab({url: '/pages/index/index'})}
>
</Button>
</View>
</View>
) : (
<OrderList mode="store" baseParams={{storeId}} />
)}
</View>
</View>
)
}