Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wx-school-app
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姜雷
wx-school-app
Commits
f12d52d1
Commit
f12d52d1
authored
Jul 01, 2019
by
姜雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
改造订单页面
parent
8a561f99
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
5 deletions
+59
-5
order.ts
src/api/order.ts
+1
-1
OrderList.tsx
src/pages/Order/OrderList/OrderList.tsx
+0
-0
store.ts
src/pages/Order/OrderList/store.ts
+2
-2
useConsumeOrders.ts
src/pages/Order/OrderList/useConsumeOrders.ts
+51
-0
useRechargeOrders.ts
src/pages/Order/OrderList/useRechargeOrders.ts
+5
-2
No files found.
src/api/order.ts
View file @
f12d52d1
...
...
@@ -118,7 +118,7 @@ export type RechargeOrder = {
handler
?:
string
;
/** 主键id */
id
?
:
number
;
id
:
number
;
/** 操作类型 1入账 2出账 */
operType
?:
string
;
...
...
src/pages/Order/OrderList/OrderList.tsx
View file @
f12d52d1
This diff is collapsed.
Click to expand it.
src/pages/Order/OrderList/store.ts
View file @
f12d52d1
...
...
@@ -6,7 +6,7 @@ import {
UPDATE_ALL_LIST
,
}
from
'./actions'
;
export
interface
StoreState
{
export
interface
Order
StoreState
{
orderState
:
String
;
payList
:
Order
[];
allList
:
AllOrderItem
[];
...
...
@@ -19,7 +19,7 @@ const INITIAL_STATE = {
};
export
default
function
OrderList
(
state
:
StoreState
=
INITIAL_STATE
,
state
:
Order
StoreState
=
INITIAL_STATE
,
actions
:
Actions
,
)
{
switch
(
actions
.
type
)
{
...
...
src/pages/Order/OrderList/useConsumeOrders.ts
0 → 100644
View file @
f12d52d1
import
{
useEffect
,
useReducer
}
from
'@tarojs/taro'
;
import
{
fetchAllOrder
}
from
'@/api/order'
;
import
Actions
from
'@/types/Store/Actions'
;
import
{
AllOrderItem
}
from
'@/types/Order/Order'
;
const
reducer
=
(
state
:
AllOrderItem
[],
action
:
Actions
)
=>
{
switch
(
action
.
type
)
{
case
'updateConsumeOrders'
:
return
action
.
payload
;
case
'appendConsumeOrders'
:
return
[...
state
,
...
action
.
payload
];
default
:
return
state
;
}
};
const
useConsumeOrders
=
(
customerId
:
number
,
lastOrderId
:
number
,
pageSize
:
number
,
):
AllOrderItem
[]
=>
{
const
[
state
,
dispatch
]
=
useReducer
(
reducer
,
[]);
const
fetchData
=
(
customerId
:
number
,
lastOrderId
:
number
,
pageSize
:
number
,
)
=>
fetchAllOrder
({
customerId
,
lastOrderId
,
pageSize
,
})
.
then
(
res
=>
{
lastOrderId
?
dispatch
({
type
:
'appendConsumeOrders'
,
payload
:
res
.
data
})
:
dispatch
({
type
:
'updateConsumeOrders'
,
payload
:
res
.
data
});
return
res
.
data
;
})
.
catch
(
err
=>
{
console
.
log
(
err
);
});
useEffect
(()
=>
{
console
.
log
(
'in fetch'
);
fetchData
(
customerId
,
lastOrderId
,
pageSize
);
},
[
customerId
,
lastOrderId
,
pageSize
]);
return
state
;
};
export
default
useConsumeOrders
;
src/
hooks
/useRechargeOrders.ts
→
src/
pages/Order/OrderList
/useRechargeOrders.ts
View file @
f12d52d1
...
...
@@ -6,7 +6,8 @@ const reducer = (state: RechargeOrderItem[], action: Actions) => {
switch
(
action
.
type
)
{
case
'updateRechargeOrders'
:
return
action
.
payload
;
case
'appendRechargeOrders'
:
return
[...
state
,
...
action
.
payload
];
default
:
return
state
;
}
...
...
@@ -28,7 +29,9 @@ const useRechargeOrders = (
pageSize
,
})
.
then
(
res
=>
{
dispatch
({
type
:
'updateRechargeOrders'
,
payload
:
res
.
data
});
lastOrderId
?
dispatch
({
type
:
'appendRechargeOrders'
,
payload
:
res
.
data
})
:
dispatch
({
type
:
'updateRechargeOrders'
,
payload
:
res
.
data
});
return
res
.
data
;
})
.
catch
(
err
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment