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
696da627
Commit
696da627
authored
Jul 02, 2019
by
姜雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改我的订单
parent
f4e54789
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
215 additions
and
142 deletions
+215
-142
OrderList.tsx
src/pages/Order/OrderList/OrderList.tsx
+197
-120
useConsumeOrders.ts
src/pages/Order/OrderList/useConsumeOrders.ts
+9
-11
useRechargeOrders.ts
src/pages/Order/OrderList/useRechargeOrders.ts
+9
-11
No files found.
src/pages/Order/OrderList/OrderList.tsx
View file @
696da627
This diff is collapsed.
Click to expand it.
src/pages/Order/OrderList/useConsumeOrders.ts
View file @
696da627
...
@@ -12,24 +12,20 @@ import {
...
@@ -12,24 +12,20 @@ import {
const
useConsumeOrders
=
(
const
useConsumeOrders
=
(
customerId
:
number
,
customerId
:
number
,
pageSize
:
number
,
pageSize
:
number
,
):
[
AllOrderItem
[],
()
=>
void
,
()
=>
void
]
=>
{
):
[
AllOrderItem
[],
()
=>
Promise
<
any
>
,
()
=>
Promise
<
any
>
]
=>
{
const
state
=
useSelector
(
const
state
=
useSelector
(
(
state
:
{
OrderList
:
OrderStoreState
})
=>
state
.
OrderList
.
consume
,
(
state
:
{
OrderList
:
OrderStoreState
})
=>
state
.
OrderList
.
consume
,
);
);
const
dispatch
=
useDispatch
();
const
dispatch
=
useDispatch
();
const
fetchData
=
(
const
fetchData
=
(
customerId
:
number
,
pageSize
:
number
)
=>
customerId
:
number
,
lastOrderId
:
number
,
pageSize
:
number
,
)
=>
fetchAllOrder
({
fetchAllOrder
({
customerId
,
customerId
,
lastOrderId
,
lastOrderId
:
state
.
lastOrderId
,
pageSize
,
pageSize
,
})
})
.
then
(
res
=>
{
.
then
(
res
=>
{
lastOrderId
state
.
lastOrderId
?
dispatch
(
appendConsumeOrders
(
res
.
data
))
?
dispatch
(
appendConsumeOrders
(
res
.
data
))
:
dispatch
(
updateConsumeOrders
(
res
.
data
));
:
dispatch
(
updateConsumeOrders
(
res
.
data
));
return
res
.
data
;
return
res
.
data
;
...
@@ -44,18 +40,20 @@ const useConsumeOrders = (
...
@@ -44,18 +40,20 @@ const useConsumeOrders = (
const
orderIdx
=
arr
[
itemIdx
].
data
.
length
-
1
;
const
orderIdx
=
arr
[
itemIdx
].
data
.
length
-
1
;
if
(
orderIdx
>=
0
)
{
if
(
orderIdx
>=
0
)
{
dispatch
(
updateConsumeLastId
(
arr
[
itemIdx
].
data
[
orderIdx
].
id
));
dispatch
(
updateConsumeLastId
(
arr
[
itemIdx
].
data
[
orderIdx
].
id
));
return
;
return
fetchData
(
customerId
,
pageSize
)
;
}
}
}
}
dispatch
(
updateConsumeLastId
(
0
));
dispatch
(
updateConsumeLastId
(
0
));
return
fetchData
(
customerId
,
pageSize
);
};
};
const
resetOrders
=
()
=>
{
const
resetOrders
=
()
=>
{
dispatch
(
updateConsumeLastId
(
0
));
dispatch
(
updateConsumeLastId
(
0
));
return
fetchData
(
customerId
,
pageSize
);
};
};
useEffect
(()
=>
{
useEffect
(()
=>
{
fetchData
(
customerId
,
state
.
lastOrderId
,
pageSize
);
fetchData
(
customerId
,
pageSize
);
},
[
customerId
,
state
.
lastOrderId
,
pageSize
]);
},
[
customerId
,
pageSize
]);
return
[
state
.
consumeOrders
,
fetchMore
,
resetOrders
];
return
[
state
.
consumeOrders
,
fetchMore
,
resetOrders
];
};
};
...
...
src/pages/Order/OrderList/useRechargeOrders.ts
View file @
696da627
...
@@ -11,23 +11,19 @@ import {
...
@@ -11,23 +11,19 @@ import {
const
useRechargeOrders
=
(
const
useRechargeOrders
=
(
customerId
:
number
,
customerId
:
number
,
pageSize
:
number
,
pageSize
:
number
,
):
[
RechargeOrderItem
[],
()
=>
void
,
()
=>
void
]
=>
{
):
[
RechargeOrderItem
[],
()
=>
Promise
<
any
>
,
()
=>
Promise
<
any
>
]
=>
{
const
state
=
useSelector
(
const
state
=
useSelector
(
(
state
:
{
OrderList
:
OrderStoreState
})
=>
state
.
OrderList
.
recharge
,
(
state
:
{
OrderList
:
OrderStoreState
})
=>
state
.
OrderList
.
recharge
,
);
);
const
dispatch
=
useDispatch
();
const
dispatch
=
useDispatch
();
const
fetchData
=
(
const
fetchData
=
(
customerId
:
number
,
pageSize
:
number
)
=>
customerId
:
number
,
lastOrderId
:
number
,
pageSize
:
number
,
)
=>
fetchRechargeOrders
({
fetchRechargeOrders
({
customerId
,
customerId
,
lastOrderId
,
lastOrderId
:
state
.
lastOrderId
,
pageSize
,
pageSize
,
})
})
.
then
(
res
=>
{
.
then
(
res
=>
{
lastOrderId
state
.
lastOrderId
?
dispatch
(
appendRechargeOrders
(
res
.
data
))
?
dispatch
(
appendRechargeOrders
(
res
.
data
))
:
dispatch
(
updateRechargeOrders
(
res
.
data
));
:
dispatch
(
updateRechargeOrders
(
res
.
data
));
return
res
.
data
;
return
res
.
data
;
...
@@ -42,18 +38,20 @@ const useRechargeOrders = (
...
@@ -42,18 +38,20 @@ const useRechargeOrders = (
const
orderIdx
=
arr
[
itemIdx
].
data
.
length
-
1
;
const
orderIdx
=
arr
[
itemIdx
].
data
.
length
-
1
;
if
(
orderIdx
>=
0
)
{
if
(
orderIdx
>=
0
)
{
dispatch
(
updateRechargeLastId
(
arr
[
itemIdx
].
data
[
orderIdx
].
id
));
dispatch
(
updateRechargeLastId
(
arr
[
itemIdx
].
data
[
orderIdx
].
id
));
return
;
return
fetchData
(
customerId
,
pageSize
)
;
}
}
}
}
dispatch
(
updateRechargeLastId
(
0
));
dispatch
(
updateRechargeLastId
(
0
));
return
fetchData
(
customerId
,
pageSize
);
};
};
const
resetOrders
=
()
=>
{
const
resetOrders
=
()
=>
{
dispatch
(
updateRechargeLastId
(
0
));
dispatch
(
updateRechargeLastId
(
0
));
return
fetchData
(
customerId
,
pageSize
);
};
};
useEffect
(()
=>
{
useEffect
(()
=>
{
fetchData
(
customerId
,
state
.
lastOrderId
,
pageSize
);
fetchData
(
customerId
,
pageSize
);
},
[
customerId
,
state
.
lastOrderId
,
pageSize
]);
},
[
customerId
,
pageSize
]);
return
[
state
.
rechargeOrders
,
fetchMore
,
resetOrders
];
return
[
state
.
rechargeOrders
,
fetchMore
,
resetOrders
];
};
};
...
...
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