28 changed files with 2545 additions and 301 deletions
File diff suppressed because it is too large
@ -0,0 +1,101 @@ |
|||
import request from '@/utils/request'; |
|||
import type { ApiResult, PageResult } from '@/api/index'; |
|||
import type { ShopUserAddress, ShopUserAddressParam } from './model'; |
|||
|
|||
/** |
|||
* 分页查询收货地址 |
|||
*/ |
|||
export async function pageShopUserAddress(params: ShopUserAddressParam) { |
|||
const res = await request.get<ApiResult<PageResult<ShopUserAddress>>>( |
|||
'/shop/shop-user-address/page', |
|||
params |
|||
); |
|||
if (res.code === 0) { |
|||
return res.data; |
|||
} |
|||
return Promise.reject(new Error(res.message)); |
|||
} |
|||
|
|||
/** |
|||
* 查询收货地址列表 |
|||
*/ |
|||
export async function listShopUserAddress(params?: ShopUserAddressParam) { |
|||
const res = await request.get<ApiResult<ShopUserAddress[]>>( |
|||
'/shop/shop-user-address', |
|||
params |
|||
); |
|||
if (res.code === 0 && res.data) { |
|||
return res.data; |
|||
} |
|||
return Promise.reject(new Error(res.message)); |
|||
} |
|||
|
|||
/** |
|||
* 添加收货地址 |
|||
*/ |
|||
export async function addShopUserAddress(data: ShopUserAddress) { |
|||
const res = await request.post<ApiResult<unknown>>( |
|||
'/shop/shop-user-address', |
|||
data |
|||
); |
|||
if (res.code === 0) { |
|||
return res.message; |
|||
} |
|||
return Promise.reject(new Error(res.message)); |
|||
} |
|||
|
|||
/** |
|||
* 修改收货地址 |
|||
*/ |
|||
export async function updateShopUserAddress(data: ShopUserAddress) { |
|||
const res = await request.put<ApiResult<unknown>>( |
|||
'/shop/shop-user-address', |
|||
data |
|||
); |
|||
if (res.code === 0) { |
|||
return res.message; |
|||
} |
|||
return Promise.reject(new Error(res.message)); |
|||
} |
|||
|
|||
/** |
|||
* 删除收货地址 |
|||
*/ |
|||
export async function removeShopUserAddress(id?: number) { |
|||
const res = await request.del<ApiResult<unknown>>( |
|||
'/shop/shop-user-address/' + id |
|||
); |
|||
if (res.code === 0) { |
|||
return res.message; |
|||
} |
|||
return Promise.reject(new Error(res.message)); |
|||
} |
|||
|
|||
/** |
|||
* 批量删除收货地址 |
|||
*/ |
|||
export async function removeBatchShopUserAddress(data: (number | undefined)[]) { |
|||
const res = await request.del<ApiResult<unknown>>( |
|||
'/shop/shop-user-address/batch', |
|||
{ |
|||
data |
|||
} |
|||
); |
|||
if (res.code === 0) { |
|||
return res.message; |
|||
} |
|||
return Promise.reject(new Error(res.message)); |
|||
} |
|||
|
|||
/** |
|||
* 根据id查询收货地址 |
|||
*/ |
|||
export async function getShopUserAddress(id: number) { |
|||
const res = await request.get<ApiResult<ShopUserAddress>>( |
|||
'/shop/shop-user-address/' + id |
|||
); |
|||
if (res.code === 0 && res.data) { |
|||
return res.data; |
|||
} |
|||
return Promise.reject(new Error(res.message)); |
|||
} |
@ -0,0 +1,51 @@ |
|||
import type { PageParam } from '@/api/index'; |
|||
|
|||
/** |
|||
* 收货地址 |
|||
*/ |
|||
export interface ShopUserAddress { |
|||
// 主键ID
|
|||
id?: number; |
|||
// 姓名
|
|||
name?: string; |
|||
// 手机号码
|
|||
phone?: string; |
|||
// 所在国家
|
|||
country?: string; |
|||
// 所在省份
|
|||
province?: string; |
|||
// 所在城市
|
|||
city?: string; |
|||
// 所在辖区
|
|||
region?: string; |
|||
// 收货地址
|
|||
address?: string; |
|||
// 收货地址
|
|||
fullAddress?: string; |
|||
//
|
|||
lat?: string; |
|||
//
|
|||
lng?: string; |
|||
// 1先生 2女士
|
|||
gender?: number; |
|||
// 家、公司、学校
|
|||
type?: string; |
|||
// 默认收货地址
|
|||
isDefault?: boolean; |
|||
// 用户ID
|
|||
userId?: number; |
|||
// 租户id
|
|||
tenantId?: number; |
|||
// 注册时间
|
|||
createTime?: string; |
|||
} |
|||
|
|||
/** |
|||
* 收货地址搜索条件 |
|||
*/ |
|||
export interface ShopUserAddressParam extends PageParam { |
|||
id?: number; |
|||
userId?: number; |
|||
isDefault?: boolean; |
|||
keywords?: string; |
|||
} |
@ -0,0 +1,4 @@ |
|||
export default definePageConfig({ |
|||
navigationBarTitleText: '常见问题', |
|||
navigationBarTextStyle: 'black' |
|||
}) |
@ -0,0 +1,3 @@ |
|||
:root { |
|||
|
|||
} |
@ -0,0 +1,43 @@ |
|||
import {useEffect, useState} from "react"; |
|||
import {CmsArticle} from "@/api/cms/cmsArticle/model"; |
|||
import {listCmsArticle} from "@/api/cms/cmsArticle"; |
|||
import {Collapse} from '@nutui/nutui-react-taro' |
|||
import {ArrowDown} from '@nutui/icons-react-taro' |
|||
|
|||
|
|||
const Helper = () => { |
|||
const [list, setList] = useState<CmsArticle[]>([]) |
|||
|
|||
const reload = () => { |
|||
listCmsArticle({model: 'help'}).then(res => { |
|||
setList(res) |
|||
}).catch(error => { |
|||
console.error("Failed to fetch goods detail:", error); |
|||
}) |
|||
} |
|||
|
|||
useEffect(() => { |
|||
reload() |
|||
}, []); |
|||
|
|||
return ( |
|||
<div className={'p-3'}> |
|||
{list.map((item, index) => ( |
|||
<Collapse defaultActiveName={['1', '2']} expandIcon={<ArrowDown/>}> |
|||
<Collapse.Item |
|||
title={ |
|||
<div className={'flex items-center'}> |
|||
<div className={'text-sm'}>{item.title}</div> |
|||
</div> |
|||
} |
|||
name={`${index}`} |
|||
> |
|||
<div className={'text-sm'}>{item.comments}</div> |
|||
</Collapse.Item> |
|||
</Collapse> |
|||
))} |
|||
</div> |
|||
); |
|||
}; |
|||
|
|||
export default Helper; |
@ -0,0 +1,4 @@ |
|||
export default definePageConfig({ |
|||
navigationBarTitleText: '新增收货地址', |
|||
navigationBarTextStyle: 'black' |
|||
}) |
@ -0,0 +1,194 @@ |
|||
import {useEffect, useState} from "react"; |
|||
import {Button, Cell, CellGroup, Input, TextArea, Form, Picker, Cascader} from '@nutui/nutui-react-taro' |
|||
import {Scan, ArrowRight} 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"; |
|||
import {updateUserInfo} from "@/api/layout"; |
|||
import {getBszxClassForTree} from "@/api/bszx/bszxClass"; |
|||
|
|||
const pickerOptions = [ |
|||
{value: 4, text: 'BeiJing'}, |
|||
{value: 1, text: 'NanJing'}, |
|||
{value: 2, text: 'WuXi'}, |
|||
{value: 8, text: 'DaQing'}, |
|||
{value: 9, text: 'SuiHua'}, |
|||
{value: 10, text: 'WeiFang'}, |
|||
{value: 12, text: 'ShiJiaZhuang'}, |
|||
] |
|||
|
|||
const OrderConfirm = () => { |
|||
const [list, setList] = useState<ShopUserAddress[]>([]) |
|||
const [classList, setClassList] = useState<any[]>() |
|||
const [FormData, setFormData] = useState<ShopUserAddress>( |
|||
{ |
|||
userId: undefined, |
|||
name: undefined, |
|||
phone: undefined, |
|||
country: undefined, |
|||
province: undefined, |
|||
city: undefined, |
|||
region: undefined, |
|||
address: undefined, |
|||
fullAddress: undefined, |
|||
lat: undefined, |
|||
lng: undefined, |
|||
gender: undefined, |
|||
type: undefined, |
|||
isDefault: undefined, |
|||
} |
|||
) |
|||
|
|||
const [navBarState, setNavBarState] = useState({ |
|||
visible: false |
|||
}) |
|||
const changeNarBar = (visible) => { |
|||
setNavBarState({ |
|||
visible |
|||
}) |
|||
} |
|||
|
|||
// 获取班级数据树
|
|||
getBszxClassForTree().then(res => { |
|||
setClassList(res); |
|||
}) |
|||
|
|||
const change6 = (value: any, path: any) => { |
|||
const branch = path[0]; |
|||
changeNarBar(false) |
|||
} |
|||
|
|||
const reload = () => { |
|||
listShopUserAddress({userId: Taro.getStorageSync('UserId')}).then(res => { |
|||
setList(res) |
|||
}).catch(error => { |
|||
console.error("Failed to fetch goods detail:", error); |
|||
}) |
|||
} |
|||
|
|||
// 提交表单
|
|||
const submitSucceed = (values: any) => { |
|||
console.log(values, 'values') |
|||
updateUserInfo(values).then(() => { |
|||
Taro.showToast({title: `保存成功`, icon: 'success'}) |
|||
setTimeout(() => { |
|||
return Taro.navigateBack() |
|||
}, 1000) |
|||
}).catch(() => { |
|||
Taro.showToast({ |
|||
title: '保存失败', |
|||
icon: 'error' |
|||
}); |
|||
}) |
|||
} |
|||
const submitFailed = (error: any) => { |
|||
console.log(error, 'err...') |
|||
} |
|||
|
|||
useEffect(() => { |
|||
reload() |
|||
}, []); |
|||
|
|||
return ( |
|||
<> |
|||
<Form |
|||
divider |
|||
initialValues={FormData} |
|||
labelPosition="left" |
|||
onFinish={(values) => submitSucceed(values)} |
|||
onFinishFailed={(errors) => submitFailed(errors)} |
|||
footer={ |
|||
<div |
|||
style={{ |
|||
display: 'flex', |
|||
justifyContent: 'center', |
|||
width: '100%' |
|||
}} |
|||
> |
|||
<Button nativeType="submit" block type="info"> |
|||
保存并使用 |
|||
</Button> |
|||
</div> |
|||
} |
|||
> |
|||
<CellGroup className={'px-3'}> |
|||
<div |
|||
style={{ |
|||
border: '1px dashed #22c55e', |
|||
display: 'flex', |
|||
alignItems: 'flex-end', |
|||
justifyContent: 'space-between', |
|||
padding: '4px', |
|||
position: 'relative' |
|||
}}> |
|||
|
|||
<TextArea style={{height: '100px'}} |
|||
placeholder={'请粘贴或输入文本,点击"识别"自动识别收货人姓名、地址、电话'}/> |
|||
<Button icon={<Scan/>} style={{position: 'absolute', right: '10px', bottom: '10px'}} type="success" |
|||
size={'small'} |
|||
fill="dashed">识别</Button> |
|||
</div> |
|||
</CellGroup> |
|||
<View className={'bg-gray-100 h-3'}></View> |
|||
<CellGroup style={{padding: '4px 0'}}> |
|||
<Form.Item name="name" label="收货人" required> |
|||
<Input placeholder="请输入收货人姓名"/> |
|||
</Form.Item> |
|||
<Form.Item name="phone" label="手机号" required> |
|||
<Input placeholder="请输入手机号"/> |
|||
</Form.Item> |
|||
<Form.Item |
|||
label="所在地区" |
|||
name="region" |
|||
required |
|||
rules={[{message: '请输入您的所在地区'}]} |
|||
> |
|||
<div className={'flex justify-between items-center'} onClick={() => changeNarBar(true)}> |
|||
<Input placeholder="选择所在地区" disabled/> |
|||
<ArrowRight className={'text-gray-400'}/> |
|||
</div> |
|||
</Form.Item> |
|||
<Form.Item name="address" label="收货地址" required> |
|||
<Input placeholder="请输入详细收货地址"/> |
|||
</Form.Item> |
|||
</CellGroup> |
|||
</Form> |
|||
<Cascader |
|||
popupProps={{ |
|||
className: 'cascader-popup', |
|||
}} |
|||
visible={navBarState.visible} |
|||
optionKey={{valueKey: 'name', textKey: 'name', childrenKey: 'children'}} |
|||
title="选择所在地区" |
|||
options={classList} |
|||
closeable |
|||
onChange={change6} |
|||
onClose={() => { |
|||
changeNarBar(false) |
|||
}} |
|||
/> |
|||
|
|||
{/*<CellGroup>*/} |
|||
{/* <Cell>*/} |
|||
{/* <div className={'flex items-center'}>*/} |
|||
{/* <Image src={goods.image} width="80" height="80"/>*/} |
|||
{/* <div className={'ml-2'}>*/} |
|||
{/* <div className={'text-sm font-bold'}>{goods.name}</div>*/} |
|||
{/* <div className={'text-red-500 text-lg'}>¥{goods.price}</div>*/} |
|||
{/* </div>*/} |
|||
{/* </div>*/} |
|||
{/* </Cell>*/} |
|||
{/*</CellGroup>*/} |
|||
|
|||
{/*<div className={'fixed-bottom'}>*/} |
|||
{/* <div className={'total-price'}>*/} |
|||
{/* 合计:<span className={'text-red-500 text-xl font-bold'}>¥{goods.price}</span>*/} |
|||
{/* </div>*/} |
|||
{/* <Button type="primary" size="large" className={'submit-btn'}>提交订单</Button>*/} |
|||
{/*</div>*/} |
|||
</> |
|||
); |
|||
}; |
|||
|
|||
export default OrderConfirm; |
@ -0,0 +1,4 @@ |
|||
export default definePageConfig({ |
|||
navigationBarTitleText: '地址管理', |
|||
navigationBarTextStyle: 'black' |
|||
}) |
@ -0,0 +1,3 @@ |
|||
:root { |
|||
|
|||
} |
@ -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; |
@ -0,0 +1,4 @@ |
|||
export default definePageConfig({ |
|||
navigationBarTitleText: '我的地址', |
|||
navigationBarTextStyle: 'black' |
|||
}) |
@ -0,0 +1,92 @@ |
|||
import {useEffect, useState} from "react"; |
|||
import {Button, Cell, CellGroup, Space, Empty, ConfigProvider} from '@nutui/nutui-react-taro' |
|||
import {Dongdong} from '@nutui/icons-react-taro' |
|||
import Taro from '@tarojs/taro' |
|||
import {ShopUserAddress} from "@/api/shop/shopUserAddress/model"; |
|||
import {listShopUserAddress} from "@/api/shop/shopUserAddress"; |
|||
|
|||
const Address = () => { |
|||
const [list, setList] = useState<ShopUserAddress[]>([{ |
|||
id: 1, |
|||
name: '张三', |
|||
phone: '13800138000', |
|||
country: '中国', |
|||
province: '广东省', |
|||
city: '广州市', |
|||
region: '天河区', |
|||
address: '黄埔大道西10号', |
|||
fullAddress: '广东省广州市天河区黄埔大道西10号', |
|||
lat: '23.129163', |
|||
lng: '113.382391', |
|||
gender: 1, |
|||
type: 'home', |
|||
isDefault: true, |
|||
userId: 1, |
|||
tenantId: 1, |
|||
createTime: '2021-09-01 10:10:10', |
|||
}, |
|||
{ |
|||
id: 2, |
|||
name: '李四', |
|||
phone: '13800138000', |
|||
country: '中国', |
|||
province: '广西壮族自治区', |
|||
city: '南宁市', |
|||
region: '青秀区', |
|||
address: '青秀区民族大道100号', |
|||
fullAddress: '广西壮族自治区南宁市青秀区民族大道100号', |
|||
lat: '23.129163', |
|||
lng: '113.382391', |
|||
gender: 1, |
|||
type: 'home', |
|||
isDefault: true, |
|||
userId: 1, |
|||
tenantId: 1, |
|||
createTime: '2021-09-01 10:10:10', |
|||
}, |
|||
{ |
|||
id: 3, |
|||
name: '张三', |
|||
phone: '13800138000', |
|||
country: '中国', |
|||
province: '广西', |
|||
city: '南宁市', |
|||
region: '青秀区', |
|||
address: '青秀区民族大道100号', |
|||
fullAddress: '广西壮族自治区南宁市青秀区民族大道100号', |
|||
lat: '23.129163', |
|||
lng: '113.382391', |
|||
gender: 1, |
|||
type: 'home', |
|||
isDefault: true, |
|||
userId: 1, |
|||
tenantId: 1, |
|||
createTime: '2021-09-01 10:10:10', |
|||
}]) |
|||
|
|||
const reload = () => { |
|||
listShopUserAddress({userId: Taro.getStorageSync('UserId')}).then(res => { |
|||
// setList(res)
|
|||
}).catch(error => { |
|||
console.error("Failed to fetch goods detail:", error); |
|||
}) |
|||
} |
|||
|
|||
useEffect(() => { |
|||
reload() |
|||
}, []); |
|||
|
|||
return ( |
|||
<> |
|||
{list.map((item) => ( |
|||
<div className={'flex flex-col bg-white my-3 py-1 px-4'}> |
|||
<div className={'py-1'}>{item.province}{item.city}{item.region}</div> |
|||
<div className={'py-1'}>{item.address}</div> |
|||
<div className={'text-gray-500 py-1'}>{item.name} {item.phone}</div> |
|||
</div> |
|||
))} |
|||
</> |
|||
); |
|||
}; |
|||
|
|||
export default Address; |
@ -0,0 +1,4 @@ |
|||
export default definePageConfig({ |
|||
navigationBarTitleText: '常见问题', |
|||
navigationBarTextStyle: 'black' |
|||
}) |
@ -0,0 +1,3 @@ |
|||
:root { |
|||
|
|||
} |
@ -0,0 +1,40 @@ |
|||
import {useEffect, useState} from "react"; |
|||
import {CmsArticle} from "@/api/cms/cmsArticle/model"; |
|||
import {listCmsArticle} from "@/api/cms/cmsArticle"; |
|||
import {Collapse} from '@nutui/nutui-react-taro' |
|||
import {ArrowDown} from '@nutui/icons-react-taro' |
|||
|
|||
const Helper = () => { |
|||
const [list, setList] = useState<CmsArticle[]>([]) |
|||
|
|||
const [category, setCategory] = useState(); |
|||
const getData = () => { |
|||
fetch("https://storage.360buyimg.com/nutui/3x/new-categoryData.js") |
|||
.then((response) => response.json()) |
|||
.then((res) => { |
|||
setCategory(res.categoryInfo.category) |
|||
}) |
|||
.catch((err) => console.log("Oh, error", err)); |
|||
}; |
|||
|
|||
const reload = () => { |
|||
listCmsArticle({model: 'help'}).then(res => { |
|||
setList(res) |
|||
}).catch(error => { |
|||
console.error("Failed to fetch goods detail:", error); |
|||
}) |
|||
} |
|||
|
|||
useEffect(() => { |
|||
reload() |
|||
getData(); |
|||
}, []); |
|||
|
|||
return ( |
|||
<> |
|||
{/*<Category category={category} showSecondLevelQuickNav={true}></Category>*/} |
|||
</> |
|||
); |
|||
}; |
|||
|
|||
export default Helper; |
Loading…
Reference in new issue