Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eppfax-h5-react
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
侯明涛
eppfax-h5-react
Commits
23cb7d4b
Commit
23cb7d4b
authored
Dec 25, 2023
by
hometown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: done.
parent
5a59fe7e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
25 deletions
+34
-25
src/pages/Home/components/HomeContent.tsx
+8
-2
src/pages/Home/index.tsx
+26
-23
No files found.
src/pages/Home/components/HomeContent.tsx
View file @
23cb7d4b
...
@@ -11,7 +11,11 @@ import apis from "@/apis";
...
@@ -11,7 +11,11 @@ import apis from "@/apis";
import
type
{
ProductCode
,
QueryBranchListResponseData
}
from
"@/apis/common"
;
import
type
{
ProductCode
,
QueryBranchListResponseData
}
from
"@/apis/common"
;
import
OrderHelper
from
"@/pages/Home/helper/order"
;
import
OrderHelper
from
"@/pages/Home/helper/order"
;
const
HomeContent
:
React
.
FC
=
()
=>
{
interface
HomeContentProps
{
queryUserOrders
:
()
=>
Promise
<
void
>
;
}
const
HomeContent
:
React
.
FC
<
HomeContentProps
>
=
(
props
)
=>
{
const
[
productList
]
=
useState
([
const
[
productList
]
=
useState
([
{
{
bannerImg
:
homeProductBanner1Img
,
bannerImg
:
homeProductBanner1Img
,
...
@@ -36,7 +40,9 @@ const HomeContent: React.FC = () => {
...
@@ -36,7 +40,9 @@ const HomeContent: React.FC = () => {
const
[
activeProductIdx
,
setActiveProductIdx
]
=
useState
(
-
1
);
const
[
activeProductIdx
,
setActiveProductIdx
]
=
useState
(
-
1
);
const
[
toasted
,
setToasted
]
=
useState
(
false
);
const
[
toasted
,
setToasted
]
=
useState
(
false
);
function
handleClickProduct
(
idx
:
number
)
{
async
function
handleClickProduct
(
idx
:
number
)
{
await
props
.
queryUserOrders
()
if
(
toasted
)
{
if
(
toasted
)
{
setActiveProductIdx
(
idx
);
setActiveProductIdx
(
idx
);
setShowBranchListPopup
(
true
);
setShowBranchListPopup
(
true
);
...
...
src/pages/Home/index.tsx
View file @
23cb7d4b
...
@@ -10,31 +10,34 @@ const Home: React.FC = () => {
...
@@ -10,31 +10,34 @@ const Home: React.FC = () => {
const
[
params
]
=
useSearchParams
();
const
[
params
]
=
useSearchParams
();
const
navigate
=
useNavigate
();
const
navigate
=
useNavigate
();
const
[
isAuthed
,
setIsAuthed
]
=
useState
(
false
);
const
[
isAuthed
,
setIsAuthed
]
=
useState
(
false
);
const
queryUserOrders
=
async
()
=>
{
const
[
res1
,
res2
]
=
await
Promise
.
all
([
await
apis
.
common
.
queryUserOrder
({
productCode
:
'4'
}),
await
apis
.
common
.
queryUserOrder
({
productCode
:
'5'
})
])
if
(
res1
.
ok
&&
res2
.
ok
)
{
// 买了普通产品
if
(
res1
.
data
.
orderId
)
{
navigate
(
`/orderDetail?orderId=
${
res1
.
data
.
orderId
}
`
,{
replace
:
true
})
}
useEffect
(()
=>
{
// 买了抽奖,但是没抽 或者 抽过了
const
authenticateAndFetchOrders
=
async
()
=>
{
if
(
res2
.
data
.
orderId
||
res2
.
data
.
lotteryOrderId
)
{
try
{
navigate
(
`/lottery`
,{
replace
:
true
})
const
authResult
=
await
AuthUtil
.
auth
(
params
);
const
[
res1
,
res2
]
=
await
Promise
.
all
([
await
apis
.
common
.
queryUserOrder
({
productCode
:
'4'
}),
await
apis
.
common
.
queryUserOrder
({
productCode
:
'5'
})
])
if
(
res1
.
ok
&&
res2
.
ok
)
{
// 买了普通产品
if
(
res1
.
data
.
orderId
)
{
navigate
(
`/orderDetail?orderId=
${
res1
.
data
.
orderId
}
`
,{
replace
:
true
})
}
// 买了抽奖,但是没抽 或者 抽过了
if
(
res2
.
data
.
orderId
||
res2
.
data
.
lotteryOrderId
)
{
navigate
(
`/lottery`
,{
replace
:
true
})
}
}
setIsAuthed
(
authResult
);
}
catch
(
error
)
{
}
}
};
}
}
const
authenticateAndFetchOrders
=
async
()
=>
{
try
{
const
authResult
=
await
AuthUtil
.
auth
(
params
);
await
queryUserOrders
()
setIsAuthed
(
authResult
);
}
catch
(
error
)
{
}
};
useEffect
(()
=>
{
setTimeout
(
authenticateAndFetchOrders
,
400
);
setTimeout
(
authenticateAndFetchOrders
,
400
);
},
[]);
},
[]);
...
@@ -43,7 +46,7 @@ const Home: React.FC = () => {
...
@@ -43,7 +46,7 @@ const Home: React.FC = () => {
{
isAuthed
&&
(
{
isAuthed
&&
(
<>
<>
<
HomeBg
/>
<
HomeBg
/>
<
HomeContent
/>
<
HomeContent
queryUserOrders=
{
queryUserOrders
}
/>
</>
</>
)
}
)
}
</
div
>
</
div
>
...
...
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