优化下单流程
This commit is contained in:
@@ -3,20 +3,14 @@ import {Cell, CellGroup, Image, Space, Button} from '@nutui/nutui-react-taro'
|
||||
import Taro from '@tarojs/taro'
|
||||
import {ShopOrder} from "@/api/shop/shopOrder/model";
|
||||
import {getShopOrder} from "@/api/shop/shopOrder";
|
||||
import {listOrderGoods} from "@/api/system/orderGoods";
|
||||
import {OrderGoods} from "@/api/system/orderGoods/model";
|
||||
import {getShopGoods} from "@/api/shop/shopGoods";
|
||||
import {listShopOrderGoods} from "@/api/shop/shopOrderGoods";
|
||||
import {ShopOrderGoods} from "@/api/shop/shopOrderGoods/model";
|
||||
import dayjs from "dayjs";
|
||||
import './index.scss'
|
||||
|
||||
interface OrderGoodsDetail extends OrderGoods {
|
||||
goodsName?: string;
|
||||
goodsImage?: string;
|
||||
}
|
||||
|
||||
const OrderDetail = () => {
|
||||
const [order, setOrder] = useState<ShopOrder | null>(null);
|
||||
const [orderGoodsList, setOrderGoodsList] = useState<OrderGoodsDetail[]>([]);
|
||||
const [orderGoodsList, setOrderGoodsList] = useState<ShopOrderGoods[]>([]);
|
||||
const router = Taro.getCurrentInstance().router;
|
||||
const orderId = router?.params?.orderId;
|
||||
|
||||
@@ -55,19 +49,9 @@ const OrderDetail = () => {
|
||||
setOrder(res);
|
||||
|
||||
// 获取订单商品列表
|
||||
const goodsRes = await listOrderGoods({ orderId: Number(orderId) });
|
||||
const goodsRes = await listShopOrderGoods({ orderId: Number(orderId) });
|
||||
if (goodsRes && goodsRes.length > 0) {
|
||||
const goodsDetailsPromises = goodsRes.map(async (item) => {
|
||||
console.log(item,'item.>>>')
|
||||
const shopGoods = await getShopGoods(Number(item.goodsId));
|
||||
return {
|
||||
...item,
|
||||
goodsName: shopGoods?.name,
|
||||
goodsImage: shopGoods?.image,
|
||||
};
|
||||
});
|
||||
const detailedGoodsList = await Promise.all(goodsDetailsPromises);
|
||||
setOrderGoodsList(detailedGoodsList);
|
||||
setOrderGoodsList(goodsRes);
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error("Failed to fetch order detail:", error);
|
||||
@@ -91,11 +75,12 @@ const OrderDetail = () => {
|
||||
{orderGoodsList.map((item, index) => (
|
||||
<Cell key={index}>
|
||||
<div className={'flex items-center'}>
|
||||
<Image src={item.goodsImage} width="80" height="80" lazyLoad={false} />
|
||||
<Image src={item.image || '/default-goods.png'} width="80" height="80" lazyLoad={false} />
|
||||
<div className={'ml-2'}>
|
||||
<div className={'text-sm font-bold'}>{item.goodsName}</div>
|
||||
{item.spec && <div className={'text-gray-500 text-xs'}>规格:{item.spec}</div>}
|
||||
<div className={'text-gray-500 text-xs'}>数量:{item.totalNum}</div>
|
||||
<div className={'text-red-500 text-lg'}>¥{item.payPrice}</div>
|
||||
<div className={'text-red-500 text-lg'}>¥{item.price}</div>
|
||||
</div>
|
||||
</div>
|
||||
</Cell>
|
||||
|
||||
Reference in New Issue
Block a user