import {useEffect, useState} from "react"; import {Image, Button, Cell, CellGroup, Input, TextArea, Space} from '@nutui/nutui-react-taro' import {Location} 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' const OrderConfirm = () => { const [goods, setGoods] = useState(null); const [address, setAddress] = useState() const router = Taro.getCurrentInstance().router; const goodsId = router?.params?.goodsId; const reload = async () => { const address = await listShopUserAddress({isDefault: true}); if(address.length > 0){ 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 && ( 送至 {address.fullAddress} ) } {!address && ( Taro.navigateTo({url: '/user/address/index'})}> 添加收货地址 )}
{goods.name}
¥{goods.price}