优化细节
This commit is contained in:
124
src/user/address/index.tsx
Normal file
124
src/user/address/index.tsx
Normal file
@@ -0,0 +1,124 @@
|
||||
import {useEffect, useState} from "react";
|
||||
import {Button, Cell, CellGroup, Space, Empty, ConfigProvider, Divider} from '@nutui/nutui-react-taro'
|
||||
import {Dongdong, ArrowRight, CheckNormal, Checked} from '@nutui/icons-react-taro'
|
||||
import Taro from '@tarojs/taro'
|
||||
import {View} from '@tarojs/components'
|
||||
import {ShopUserAddress} from "@/api/shop/shopUserAddress/model";
|
||||
import {listShopUserAddress} from "@/api/shop/shopUserAddress";
|
||||
|
||||
const Address = () => {
|
||||
const [list, setList] = useState<ShopUserAddress[]>([{},{},{},{}])
|
||||
|
||||
const reload = () => {
|
||||
listShopUserAddress({userId: Taro.getStorageSync('UserId')}).then(res => {
|
||||
// setList(res)
|
||||
}).catch(error => {
|
||||
console.error("Failed to fetch goods detail:", error);
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
reload()
|
||||
}, []);
|
||||
|
||||
if (list.length == 0) {
|
||||
return (
|
||||
<ConfigProvider>
|
||||
<div className={'h-full flex flex-col justify-center items-center'} style={{
|
||||
height: 'calc(100vh - 300px)',
|
||||
}}>
|
||||
<Empty
|
||||
style={{
|
||||
backgroundColor: 'transparent'
|
||||
}}
|
||||
description="您还没有地址哦"
|
||||
/>
|
||||
<Space>
|
||||
<Button onClick={() => Taro.navigateTo({url: '/user/address/add'})}>新增地址</Button>
|
||||
<Button type="success" fill="dashed">获取微信地址</Button>
|
||||
</Space>
|
||||
</div>
|
||||
</ConfigProvider>
|
||||
)
|
||||
}
|
||||
|
||||
if (list.length == 0) {
|
||||
return (
|
||||
<CellGroup>
|
||||
<Cell className={''}>
|
||||
<Space>
|
||||
<Button>新增地址</Button>
|
||||
<Button>获取微信地址</Button>
|
||||
</Space>
|
||||
</Cell>
|
||||
</CellGroup>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<CellGroup>
|
||||
<Cell
|
||||
onClick={() => Taro.navigateTo({url: '/user/address/wxAddress'})}
|
||||
>
|
||||
<div className={'flex justify-between items-center w-full'}>
|
||||
<div className={'flex items-center gap-3'}>
|
||||
<Dongdong className={'text-green-600'}/>
|
||||
<div>获取微信地址</div>
|
||||
</div>
|
||||
<ArrowRight className={'text-gray-400'}/>
|
||||
</div>
|
||||
</Cell>
|
||||
</CellGroup>
|
||||
{list.map((item,index) => (
|
||||
// <CellGroup key={item.id}>
|
||||
// <Cell title={item.name}
|
||||
// extra={
|
||||
// <Button
|
||||
// type="primary"
|
||||
// size="small"
|
||||
// >
|
||||
// 修改
|
||||
// </Button>
|
||||
// }
|
||||
// >
|
||||
// <div className={'text-sm'}>{item.fullAddress}</div>
|
||||
//
|
||||
// </Cell>
|
||||
// </CellGroup>
|
||||
<Cell.Group>
|
||||
<Cell className={'flex flex-col gap-1'}>
|
||||
<View>
|
||||
<View className={'font-medium text-sm'}>赵四 13800010001</View>
|
||||
</View>
|
||||
<View className={'text-xs'}>
|
||||
广西壮族自治区南宁市青秀区金湖路13号
|
||||
</View>
|
||||
</Cell>
|
||||
<Cell
|
||||
align="center"
|
||||
title={
|
||||
<View className={'flex items-center gap-1'}>
|
||||
{index == 0 ? <Checked className={'text-green-600'} size={16}/> : <CheckNormal size={16} />}
|
||||
<View className={'text-gray-400'}>默认地址</View>
|
||||
</View>
|
||||
}
|
||||
extra={
|
||||
<>
|
||||
<View className={'text-gray-400'}>
|
||||
删除
|
||||
</View>
|
||||
<Divider direction={'vertical'}/>
|
||||
<View className={'text-gray-400'}>
|
||||
修改
|
||||
</View>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
</Cell.Group>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Address;
|
||||
Reference in New Issue
Block a user