import {useEffect, useState} from "react"; import {Image, Button, Cell, CellGroup, Input, Space} from '@nutui/nutui-react-taro' import {Location, ArrowRight} from '@nutui/icons-react-taro' import Taro from '@tarojs/taro' import {ShopGoods} from "@/api/shop/shopGoods/model"; import {getShopGoods} from "@/api/shop/shopGoods"; import {View} from '@tarojs/components'; import {listShopUserAddress} from "@/api/shop/shopUserAddress"; import {ShopUserAddress} from "@/api/shop/shopUserAddress/model"; import './index.scss' import {useCart} from "@/hooks/useCart"; import Gap from "@/components/Gap"; const OrderConfirm = () => { const [goods, setGoods] = useState(null); const [address, setAddress] = useState() const router = Taro.getCurrentInstance().router; const goodsId = router?.params?.goodsId; const { cartItems } = useCart(); const reload = async () => { const address = await listShopUserAddress({isDefault: true}); if (address.length > 0) { console.log(address, '111') setAddress(address[0]) } } useEffect(() => { if (goodsId) { getShopGoods(Number(goodsId)).then(res => { setGoods(res); }).catch(error => { console.error("Failed to fetch goods detail:", error); }); } reload().then() }, [goodsId]); if (!goods) { return
加载中...
; } return (
{ address && ( Taro.navigateTo({url: '/user/address/index'})}> 送至 {address.province} {address.city} {address.region} {address.address} {address.name} {address.phone} ) } {!address && ( Taro.navigateTo({url: '/user/address/index'})}> 添加收货地址 )} {cartItems.map((goods, _) => ( {goods.name} 80g/袋 ¥{goods.price} x {goods.quantity} ))} {'¥' + goods.price}}/> -¥10.00 )}/> {/**/} )}/>
实付金额: ¥{goods.price}
); }; export default OrderConfirm;