forked from gxwebsoft/mp-10550
refactor(user/order): 重构订单页面
- 移除了 OrderSearch 组件 - 简化了 OrderList 组件的接口- 优化了订单页面的逻辑结构 - 删除了未使用的 CSS 样式文件
This commit is contained in:
@@ -1,42 +1,37 @@
|
||||
import {useState} from "react";
|
||||
import Taro, {useDidShow} from '@tarojs/taro'
|
||||
import {Space, NavBar, Empty, Button, ConfigProvider, Input} from '@nutui/nutui-react-taro'
|
||||
import {Space, NavBar, Button, Input} from '@nutui/nutui-react-taro'
|
||||
import {Search, Filter, ArrowLeft} from '@nutui/icons-react-taro'
|
||||
import {View} from '@tarojs/components';
|
||||
import OrderList from "./components/OrderList";
|
||||
// import OrderSearch from "./components/OrderSearch";
|
||||
import {ShopOrder, ShopOrderParam} from "@/api/shop/shopOrder/model";
|
||||
import {pageShopOrder} from "@/api/shop/shopOrder";
|
||||
import {useRouter} from '@tarojs/taro'
|
||||
import {ShopOrderParam} from "@/api/shop/shopOrder/model";
|
||||
import './order.scss'
|
||||
|
||||
function Order() {
|
||||
const {params} = useRouter();
|
||||
const [statusBarHeight, setStatusBarHeight] = useState<number>()
|
||||
const [list, setList] = useState<ShopOrder[]>([])
|
||||
const [searchParams, setSearchParams] = useState<ShopOrderParam>({})
|
||||
const [searchParams, setSearchParams] = useState<ShopOrderParam>({
|
||||
statusFilter: params.statusFilter != undefined && params.statusFilter != '' ? parseInt(params.statusFilter) : -1
|
||||
})
|
||||
const [showSearch, setShowSearch] = useState(false)
|
||||
const [searchKeyword, setSearchKeyword] = useState('')
|
||||
|
||||
const reload = async (params?: ShopOrderParam) => {
|
||||
const searchConditions = {
|
||||
userId: Taro.getStorageSync('UserId'),
|
||||
...params
|
||||
}
|
||||
const orders = await pageShopOrder(searchConditions)
|
||||
if (orders) {
|
||||
setList(orders.list || [])
|
||||
}
|
||||
const reload = async (where?: ShopOrderParam) => {
|
||||
console.log(where,'where...')
|
||||
setSearchParams(prev => ({ ...prev, ...where }))
|
||||
}
|
||||
|
||||
// 处理搜索
|
||||
const handleSearch = (params: ShopOrderParam) => {
|
||||
setSearchParams(params)
|
||||
reload(params)
|
||||
const handleSearch = (where: ShopOrderParam) => {
|
||||
setSearchParams(where)
|
||||
reload(where).then()
|
||||
}
|
||||
|
||||
// 重置搜索
|
||||
const handleResetSearch = () => {
|
||||
setSearchParams({})
|
||||
reload()
|
||||
reload().then()
|
||||
}
|
||||
|
||||
useDidShow(() => {
|
||||
@@ -96,9 +91,6 @@ function Order() {
|
||||
onClick={() => setShowSearch(!showSearch)}
|
||||
/>
|
||||
</View>
|
||||
<View className="text-sm text-gray-500">
|
||||
共{list.length}个订单
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 搜索组件 */}
|
||||
@@ -147,36 +139,31 @@ function Order() {
|
||||
</View>
|
||||
)}
|
||||
{/*暂无订单*/}
|
||||
{list.length == 0 && (
|
||||
<ConfigProvider>
|
||||
<div className={'h-full flex flex-col justify-center items-center'} style={{
|
||||
height: showSearch ? 'calc(100vh - 200px)' : 'calc(100vh - 150px)',
|
||||
marginTop: showSearch ? '60px' : '0'
|
||||
}}>
|
||||
<Empty
|
||||
style={{
|
||||
backgroundColor: 'transparent'
|
||||
}}
|
||||
description="您还没有订单哦"
|
||||
/>
|
||||
<Space>
|
||||
<Button type="success" fill="dashed"
|
||||
onClick={() => Taro.switchTab({url: '/pages/index/index'})}>去挑选商品</Button>
|
||||
</Space>
|
||||
</div>
|
||||
</ConfigProvider>
|
||||
)}
|
||||
{/*{list.length == 0 && (*/}
|
||||
{/* <ConfigProvider>*/}
|
||||
{/* <div className={'h-full flex flex-col justify-center items-center'} style={{*/}
|
||||
{/* height: showSearch ? 'calc(100vh - 200px)' : 'calc(100vh - 150px)',*/}
|
||||
{/* marginTop: showSearch ? '60px' : '0'*/}
|
||||
{/* }}>*/}
|
||||
{/* <Empty*/}
|
||||
{/* style={{*/}
|
||||
{/* backgroundColor: 'transparent'*/}
|
||||
{/* }}*/}
|
||||
{/* description="您还没有订单哦"*/}
|
||||
{/* />*/}
|
||||
{/* <Space>*/}
|
||||
{/* <Button type="success" fill="dashed"*/}
|
||||
{/* onClick={() => Taro.switchTab({url: '/pages/index/index'})}>去挑选商品</Button>*/}
|
||||
{/* </Space>*/}
|
||||
{/* </div>*/}
|
||||
{/* </ConfigProvider>*/}
|
||||
{/*)}*/}
|
||||
{/*订单列表*/}
|
||||
{
|
||||
list.length > 0 && (
|
||||
<OrderList
|
||||
data={list}
|
||||
onReload={() => reload(searchParams)}
|
||||
searchParams={searchParams}
|
||||
showSearch={showSearch}
|
||||
/>
|
||||
)
|
||||
}
|
||||
<OrderList
|
||||
onReload={() => reload(searchParams)}
|
||||
searchParams={searchParams}
|
||||
showSearch={showSearch}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user