Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
GeekLearnMathWeapp
Project
Project
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
frontend
GeekLearnMathWeapp
Commits
fa590a85
Commit
fa590a85
authored
Apr 28, 2023
by
hewenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update
parent
6c81b0c9
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
377 additions
and
27 deletions
+377
-27
.oss
assets/guide/.oss
+18
-0
btn-off.png
assets/guide/btn-off.png
+0
-0
btn-on.png
assets/guide/btn-on.png
+0
-0
market-auth-reject.png
assets/guide/market-auth-reject.png
+0
-0
project.config.json
project.config.json
+1
-1
assets-guide.ts
src/assets/oss/assets-guide.ts
+15
-0
index.tsx
src/pages/main/components/tutorial/index.tsx
+14
-0
scene-6.tsx
src/pages/main/guide/scene-6.tsx
+4
-6
exchange-item.tsx
src/pages/market/components/exchange-item.tsx
+1
-1
auth-phone-before.tsx
src/pages/market/components/tutorial/auth-phone-before.tsx
+40
-0
index.tsx
src/pages/market/components/tutorial/index.tsx
+5
-2
receive-point.tsx
src/pages/market/components/tutorial/receive-point.tsx
+100
-5
shared.module.scss
src/pages/market/components/tutorial/shared.module.scss
+143
-0
index.tsx
src/pages/market/index.tsx
+5
-4
guide.ts
src/store/modules/guide.ts
+2
-0
user.ts
src/store/modules/user.ts
+27
-8
types.ts
src/types.ts
+2
-0
No files found.
assets/guide/.oss
View file @
fa590a85
...
...
@@ -190,5 +190,23 @@
"w": 300,
"h": 300,
"ossName": "/pk-math/2GNZg5jHSKPtJRMcB66gGpUoGXMH/300x300"
},
"market-auth-reject.png": {
"u": "https://cdn.jkwljy.com/pk-math/2VzNk35B3Xt4YkG2oFWsEBoAehZK/260x260",
"w": 260,
"h": 260,
"ossName": "/pk-math/2VzNk35B3Xt4YkG2oFWsEBoAehZK/260x260"
},
"btn-off.png": {
"u": "https://cdn.jkwljy.com/pk-math/u2HbzQr4pxceDVNWEzgmmDN4QLF/248x72",
"w": 248,
"h": 72,
"ossName": "/pk-math/u2HbzQr4pxceDVNWEzgmmDN4QLF/248x72"
},
"btn-on.png": {
"u": "https://cdn.jkwljy.com/pk-math/iPLMRuPfEJnBj5o8ZT8jEWpWqen/248x72",
"w": 248,
"h": 72,
"ossName": "/pk-math/iPLMRuPfEJnBj5o8ZT8jEWpWqen/248x72"
}
}
assets/guide/btn-off.png
0 → 100644
View file @
fa590a85
2.86 KB
assets/guide/btn-on.png
0 → 100644
View file @
fa590a85
2.2 KB
assets/guide/market-auth-reject.png
0 → 100644
View file @
fa590a85
37.7 KB
project.config.json
View file @
fa590a85
...
...
@@ -2,7 +2,7 @@
"miniprogramRoot"
:
"dist/"
,
"projectname"
:
"GeekLearnMathWeapp"
,
"description"
:
""
,
"appid"
:
"wx
8f25def587982a19
"
,
"appid"
:
"wx
693fe3460124d84b
"
,
"setting"
:
{
"urlCheck"
:
false
,
"es6"
:
false
,
...
...
src/assets/oss/assets-guide.ts
View file @
fa590a85
...
...
@@ -160,5 +160,20 @@ export default {
"u"
:
"https://cdn.jkwljy.com/pk-math/2GNZg5jHSKPtJRMcB66gGpUoGXMH/300x300"
,
"w"
:
300
,
"h"
:
300
},
"market-auth-reject.png"
:
{
"u"
:
"https://cdn.jkwljy.com/pk-math/2VzNk35B3Xt4YkG2oFWsEBoAehZK/260x260"
,
"w"
:
260
,
"h"
:
260
},
"btn-off.png"
:
{
"u"
:
"https://cdn.jkwljy.com/pk-math/u2HbzQr4pxceDVNWEzgmmDN4QLF/248x72"
,
"w"
:
248
,
"h"
:
72
},
"btn-on.png"
:
{
"u"
:
"https://cdn.jkwljy.com/pk-math/iPLMRuPfEJnBj5o8ZT8jEWpWqen/248x72"
,
"w"
:
248
,
"h"
:
72
}
}
as
const
src/pages/main/components/tutorial/index.tsx
View file @
fa590a85
...
...
@@ -2,11 +2,24 @@ import { useState, useCallback, useEffect, useRef } from 'react'
import
{
getAreaAndGrades
,
type
AreaAndGrades
,
StageStatus
}
from
'@/api'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
{
useFocus
}
from
'@/hooks'
import
assets
from
'@/assets/oss/assets-guide'
import
{
preloadImage
}
from
'@/utils/preload-image'
import
ModalArea
from
'./modal-area'
import
ModalGrade
from
'./modal-grade'
import
ModalResult
from
'./modal-result'
import
ModalGroupGuide
from
'./modal-group-guide'
let
isLoad
=
false
const
preloadGuideImages
=
()
=>
{
if
(
isLoad
)
return
isLoad
=
true
const
items
:
string
[]
=
[]
for
(
const
key
in
assets
)
{
items
.
push
(
assets
[
key
].
u
)
}
preloadImage
(
items
)
}
export
type
TutorialRef
=
{
start
:
()
=>
void
;
}
...
...
@@ -88,6 +101,7 @@ const Tutorial = () => {
if
(
isFocus
)
{
if
(
!
data
.
areas
.
length
)
{
loadData
()
preloadGuideImages
()
}
if
(
isLoadRef
.
current
)
{
return
...
...
src/pages/main/guide/scene-6.tsx
View file @
fa590a85
...
...
@@ -36,12 +36,9 @@ const Scene6 = (props: Scene6Props) => {
const
updateNickNameAndPhone
=
useStoreActions
(
actions
=>
actions
.
userModel
.
updateNickNameAndPhone
)
const
handleGetPhone
=
useCallback
<
CommonEventFunction
<
ButtonProps
.
onGetPhoneNumberEventDetail
>>
((
e
)
=>
{
if
(
!
e
.
detail
.
code
)
{
console
.
log
(
e
.
detail
.
errMsg
)
return
}
if
(
loading
)
return
setLoading
(
true
)
updateNickNameAndPhone
({
code
:
e
.
detail
.
code
!
,
name
})
updateNickNameAndPhone
({
code
:
e
.
detail
.
code
,
name
})
.
then
(()
=>
{
setLoading
(
false
)
onNext
()
...
...
@@ -50,7 +47,7 @@ const Scene6 = (props: Scene6Props) => {
setLoading
(
false
)
console
.
log
(
err
)
})
},
[
updateNickNameAndPhone
,
onNext
,
name
])
},
[
updateNickNameAndPhone
,
onNext
,
name
,
loading
])
const
_getNickNameWords
=
useCallback
(
async
()
=>
{
const
words
=
await
getNickNameWords
()
...
...
@@ -124,6 +121,7 @@ const Scene6 = (props: Scene6Props) => {
onGetPhoneNumber=
{
handleGetPhone
}
className=
{
cs
.
btn
}
loading=
{
loading
}
disabled=
{
loading
}
id=
"main_guide_6"
hoverClass=
{
cs
.
is_hover
}
>
确定
</
Button
>
...
...
src/pages/market/components/exchange-item.tsx
View file @
fa590a85
...
...
@@ -25,7 +25,7 @@ const ExchangeItem = (props: ExchangeItemProps) => {
const
[
val
,
setVal
]
=
useState
(
1
)
const
isGuideActive
=
useMemo
(()
=>
{
return
storeGuideStep
===
3
&&
storeGuideActive
return
storeGuideStep
===
4
&&
storeGuideActive
},
[
storeGuideStep
,
storeGuideActive
])
const
handleMinus
=
useCallback
(()
=>
{
...
...
src/pages/market/components/tutorial/auth-phone-before.tsx
0 → 100644
View file @
fa590a85
import
{
View
,
RootPortal
,
Image
,
Text
}
from
'@tarojs/components'
import
tutorialAssets
from
'@/assets/oss/assets-tutorial'
import
classNames
from
'classnames'
import
styles
from
'./shared.module.scss'
type
ModalAuthPhoneBeforeProps
=
{
onConfirm
:
()
=>
void
;
}
const
ModalAuthPhoneBefore
=
(
props
:
ModalAuthPhoneBeforeProps
)
=>
{
const
{
onConfirm
}
=
props
return
(
<
RootPortal
>
<
View
className=
{
styles
.
mask
}
catchMove
></
View
>
<
View
className=
{
styles
.
result_wrap
}
catchMove
>
<
Image
src=
{
tutorialAssets
[
'cat.png'
].
u
}
className=
{
styles
.
result_cat
}
/>
<
View
className=
{
styles
.
result_main
}
>
<
View
className=
{
classNames
(
styles
.
dialog
)
}
onClick=
{
()
=>
onConfirm
()
}
id=
"market-guide-before-authphone"
>
<
View
>
为了让阿喵老师能给你发放礼品,需要你进行授权哦。
<
View
>
<
Text
className=
{
styles
.
em
}
>
授权成功后,
</
Text
>
还可以
<
Text
className=
{
styles
.
em
}
>
获得100水晶
</
Text
>
奖励哦!
</
View
>
</
View
>
<
View
className=
{
styles
.
continue
}
>
<
View
className=
{
styles
.
continue_btn
}
>
继续
<
Image
src=
{
tutorialAssets
[
'continue-arrow.png'
].
u
}
className=
{
styles
.
continue_icon
}
/>
</
View
>
</
View
>
</
View
>
</
View
>
</
View
>
</
RootPortal
>
)
}
export
default
ModalAuthPhoneBefore
src/pages/market/components/tutorial/index.tsx
View file @
fa590a85
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
ReceivePointModal
from
'./receive-point'
import
GuideFinish
from
'./guide-finish'
import
ModalAuthPhoneBefore
from
'./auth-phone-before'
export
type
TutorialRef
=
{
start
:
()
=>
void
;
...
...
@@ -11,11 +12,13 @@ const Tutorial = () => {
const
storeGuideActive
=
useStoreState
(
state
=>
state
.
guideModel
.
storeGuideActive
)
const
revceiPoint
=
useStoreActions
(
state
=>
state
.
guideModel
.
revceiPoint
)
const
completeStoreGuide
=
useStoreActions
(
state
=>
state
.
guideModel
.
completeStoreGuide
)
const
nextStoreGuide
=
useStoreActions
(
state
=>
state
.
guideModel
.
nextStoreGuide
)
return
(
<>
{
storeGuideActive
&&
storeGuideStep
===
1
&&
<
ReceivePointModal
onConfirm=
{
revceiPoint
}
/>
}
{
storeGuideActive
&&
storeGuideStep
===
4
&&
<
GuideFinish
onConfirm=
{
completeStoreGuide
}
/>
}
{
storeGuideActive
&&
storeGuideStep
===
1
&&
<
ModalAuthPhoneBefore
onConfirm=
{
nextStoreGuide
}
/>
}
{
storeGuideActive
&&
storeGuideStep
===
2
&&
<
ReceivePointModal
onConfirm=
{
revceiPoint
}
/>
}
{
storeGuideActive
&&
storeGuideStep
===
5
&&
<
GuideFinish
onConfirm=
{
completeStoreGuide
}
/>
}
</>
)
}
...
...
src/pages/market/components/tutorial/receive-point.tsx
View file @
fa590a85
import
{
View
,
RootPortal
,
Image
,
Button
}
from
'@tarojs/components'
import
{
View
,
RootPortal
,
Image
,
Button
,
CommonEventFunction
,
ButtonProps
}
from
'@tarojs/components'
import
{
showToast
}
from
'@tarojs/taro'
import
{
useBoolean
}
from
'@/hooks'
import
{
receivePoint
}
from
'@/api'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
guideAssets
from
'@/assets/oss/assets-guide'
import
giftAssets
from
'@/assets/oss/assets-gift'
import
styles
from
'./shared.module.scss'
...
...
@@ -12,12 +15,45 @@ type ReceivePointProps = {
const
ModalReceivePoint
=
(
props
:
ReceivePointProps
)
=>
{
const
{
onConfirm
}
=
props
const
[
loading
,
loadingActions
]
=
useBoolean
(
false
)
const
useInfo
=
useStoreState
(
state
=>
state
.
userModel
.
userInfo
)
const
completeStoreGuide
=
useStoreActions
(
actions
=>
actions
.
guideModel
.
completeStoreGuide
)
const
updateNickNameAndPhone
=
useStoreActions
(
actions
=>
actions
.
userModel
.
updateNickNameAndPhone
)
const
[
fail
,
failActions
]
=
useBoolean
(
false
)
const
handleConfirm
=
async
(
)
=>
{
const
updatePhoneAndReceive
=
async
(
code
:
string
)
=>
{
if
(
loading
)
return
loadingActions
.
setTrue
()
try
{
await
updateNickNameAndPhone
({
code
})
await
receivePoint
()
onConfirm
&&
onConfirm
()
loadingActions
.
setFalse
()
}
catch
(
err
)
{
loadingActions
.
setFalse
()
}
}
const
handleConfirmAndAuth
:
CommonEventFunction
<
ButtonProps
.
onGetPhoneNumberEventDetail
>
=
(
arg
)
=>
{
if
(
!
arg
.
detail
.
code
)
{
failActions
.
setTrue
()
return
}
updatePhoneAndReceive
(
arg
.
detail
.
code
)
}
const
handleConfirmAndAuthTwice
:
CommonEventFunction
<
ButtonProps
.
onGetPhoneNumberEventDetail
>
=
arg
=>
{
if
(
!
arg
.
detail
.
code
)
{
completeStoreGuide
()
return
}
updatePhoneAndReceive
(
arg
.
detail
.
code
)
}
const
handleConfirm
=
async
()
=>
{
if
(
loading
)
return
loadingActions
.
setTrue
()
try
{
// await receivePoint()
loadingActions
.
setFalse
()
onConfirm
&&
onConfirm
()
}
catch
(
err
)
{
...
...
@@ -26,15 +62,74 @@ const ModalReceivePoint = (props: ReceivePointProps) => {
}
}
const
finish
=
()
=>
{
completeStoreGuide
()
}
const
renderModal
=
()
=>
{
if
(
fail
)
{
return
(
<
View
className=
{
styles
.
modal
}
catchMove
>
<
View
className=
{
styles
.
reject_modal
}
>
<
Image
src=
{
guideAssets
[
'market-auth-reject.png'
].
u
}
className=
{
styles
.
reject_cat
}
></
Image
>
<
View
className=
{
styles
.
tips_1
}
>
授权失败
</
View
>
<
View
className=
{
styles
.
tips_2
}
>
<
View
>
授权失败,阿喵老师将
</
View
>
<
View
>
无法给你发放成长奖励礼品哦?
</
View
>
</
View
>
<
View
className=
{
styles
.
reject_modal_footer
}
>
<
View
className=
{
styles
.
btn_reject_2
}
onClick=
{
finish
}
id=
"market_guide_reject_point"
>
先不要了
</
View
>
<
Button
className=
{
styles
.
btn_receive_2
}
onGetPhoneNumber=
{
handleConfirmAndAuthTwice
}
openType=
"getPhoneNumber"
loading=
{
loading
}
hoverClass=
{
styles
.
btn_receive_2_active
}
id=
"market_guide_receive_and_auth_2"
>
领取
</
Button
>
</
View
>
</
View
>
</
View
>
)
}
return
(
<
RootPortal
>
<
View
className=
{
styles
.
mask
}
catchMove
></
View
>
<
View
className=
{
styles
.
modal
}
catchMove
>
<
Image
src=
{
giftAssets
[
'point-receive.png'
].
u
}
className=
{
styles
.
icon
}
></
Image
>
<
View
className=
{
styles
.
count
}
>
水晶 +100
</
View
>
<
View
className=
{
styles
.
tips
}
>
阿喵老师的奖励,继续加油哦~
</
View
>
<
Button
className=
{
styles
.
btn
}
onClick=
{
handleConfirm
}
loading=
{
loading
}
id=
"market_guide_receive"
>
领取
</
Button
>
{
useInfo
.
authPhone
===
'Y'
?
(
<
Button
className=
{
styles
.
btn
}
onClick=
{
handleConfirm
}
loading=
{
loading
}
id=
"market_guide_receive"
>
领取
</
Button
>
)
:
(
<
Button
className=
{
styles
.
btn
}
onGetPhoneNumber=
{
handleConfirmAndAuth
}
openType=
"getPhoneNumber"
loading=
{
loading
}
id=
"market_guide_receive_and_auth"
>
领取
</
Button
>
)
}
</
View
>
)
}
return
(
<
RootPortal
>
<
View
className=
{
styles
.
mask
}
catchMove
></
View
>
{
renderModal
()
}
</
RootPortal
>
)
}
...
...
src/pages/market/components/tutorial/shared.module.scss
View file @
fa590a85
...
...
@@ -59,3 +59,146 @@
height
:
960px
;
margin-top
:
-80px
;
}
.dialog
{
width
:
510px
;
height
:
272px
;
padding
:
24px
20px
0
42px
;
box-sizing
:
border-box
;
background-size
:
100%
100%
;
background-image
:
url(https://cdn.jkwljy.com/pk-math/mFR86xsmGbKnCC9yu5ak2yadejB/510x272)
;
font-size
:
28px
;
font-weight
:
500
;
color
:
rgba
(
70
,
81
,
100
,
0
.8
);
line-height
:
44px
;
.em
{
color
:
#FFC056
;
}
}
.result_wrap
{
position
:
fixed
;
z-index
:
100000
;
bottom
:
15vh
;
left
:
0
;
right
:
0
;
display
:
flex
;
padding
:
0
16px
;
}
.result_main
{
flex
:
1
;
padding-top
:
60px
;
margin-left
:
-8px
;
}
.result_cat
{
width
:
200px
;
height
:
300px
;
}
.continue
{
display
:
flex
;
justify-content
:
flex-end
;
}
.continue_btn
{
display
:
flex
;
justify-content
:
flex-end
;
align-items
:
center
;
font-size
:
28px
;
font-weight
:
500
;
color
:
#1786F7
;
padding
:
2px
8px
2px
20px
;
margin-right
:
-8px
;
line-height
:
40px
;
}
.continue_icon
{
width
:
28px
;
height
:
28px
;
display
:
block
;
margin-left
:
4px
;
}
.reject_modal
{
width
:
654px
;
background
:
#FFFEFF
;
border-radius
:
32px
;
position
:
relative
;
padding
:
140px
64px
32px
64px
;
box-sizing
:
border-box
;
text-align
:
center
;
.reject_cat
{
position
:
absolute
;
left
:
50%
;
width
:
260px
;
height
:
260px
;
top
:
-120px
;
margin-left
:
-130px
;
}
.tips_1
{
font-size
:
48px
;
font-weight
:
600
;
color
:
#586170
;
line-height
:
66px
;
padding-top
:
32px
;
}
.tips_2
{
padding-top
:
32px
;
font-size
:
32px
;
font-weight
:
400
;
color
:
#586170
;
line-height
:
48px
;
}
}
.btn_receive_2
{
width
:
248px
;
height
:
72px
;
background-image
:
url(https://cdn.jkwljy.com/pk-math/u2HbzQr4pxceDVNWEzgmmDN4QLF/248x72)
;
background-size
:
100%
100%
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
font-size
:
28px
;
font-weight
:
500
;
color
:
#FFFFFF
;
line-height
:
40px
;
border
:
none
;
&
:
:
after
{
border
:
none
;
background-color
:
transparent
;
}
&
.btn_receive_2_active
{
background-image
:
url(https://cdn.jkwljy.com/pk-math/iPLMRuPfEJnBj5o8ZT8jEWpWqen/248x72)
;
}
}
.btn_reject_2
{
width
:
246px
;
height
:
72px
;
border-radius
:
36px
;
border
:
4px
solid
rgba
(
70
,
81
,
100
,
0
.3
);
box-sizing
:
border-box
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
font-size
:
28px
;
font-weight
:
500
;
color
:
rgba
(
70
,
81
,
100
,
0
.5
);
line-height
:
40px
;
margin-right
:
34px
;
}
.reject_modal_footer
{
display
:
flex
;
padding-top
:
48px
;
align-items
:
center
;
}
src/pages/market/index.tsx
View file @
fa590a85
...
...
@@ -82,6 +82,7 @@ const StudyMarket = () => {
const
setting
=
useStoreState
(
state
=>
state
.
userModel
.
setting
)
const
storeGuideStep
=
useStoreState
(
state
=>
state
.
guideModel
.
storeGuideStep
)
const
storeGuideActive
=
useStoreState
(
state
=>
state
.
guideModel
.
storeGuideActive
)
const
isStoreGuideComplete
=
useStoreState
(
state
=>
state
.
guideModel
.
isStoreGuideComplete
)
const
userInfo
=
useStoreState
(
state
=>
state
.
userModel
.
userInfo
)
const
fetchAccount
=
useStoreActions
(
actions
=>
actions
.
userModel
.
fetchAccount
)
const
getSetting
=
useStoreActions
(
actions
=>
actions
.
userModel
.
getSetting
)
...
...
@@ -94,10 +95,10 @@ const StudyMarket = () => {
})
useEffect
(()
=>
{
if
(
userInfo
.
pointReceive
===
'N'
)
{
if
(
userInfo
.
pointReceive
===
'N'
&&
!
isStoreGuideComplete
)
{
updateStoreGuideActive
(
true
)
}
},
[
userInfo
,
updateStoreGuideActive
])
},
[
userInfo
,
updateStoreGuideActive
,
isStoreGuideComplete
])
const
list
:
ExchangeGoods
[]
=
useMemo
(()
=>
{
return
[
...
...
@@ -120,7 +121,7 @@ const StudyMarket = () => {
},
[
setTrue
])
const
isMaskActive
=
useMemo
(()
=>
{
return
(
storeGuideStep
===
0
||
storeGuideStep
===
2
)
&&
storeGuideActive
return
(
storeGuideStep
===
0
||
storeGuideStep
===
3
)
&&
storeGuideActive
},
[
storeGuideStep
,
storeGuideActive
])
const
isStep1Active
=
useMemo
(()
=>
{
...
...
@@ -180,7 +181,7 @@ const StudyMarket = () => {
disabled=
{
(
!
(
item
.
isGuideCard
&&
isStep1Active
))
&&
disabled
}
subtitle=
{
item
.
description
}
disabledText=
{
disabledText
}
isGuideActive=
{
isMaskActive
&&
storeGuideStep
===
2
&&
index
===
0
}
isGuideActive=
{
isMaskActive
&&
storeGuideStep
===
3
&&
index
===
0
}
onClick=
{
()
=>
{
open
(
item
)
}
}
...
...
src/store/modules/guide.ts
View file @
fa590a85
...
...
@@ -64,6 +64,7 @@ const guideModel: GuideModel = {
state
.
pointToCardNum
=
num
}
}),
revceiPoint
:
thunk
(
async
(
actions
,
_
,
helpers
)
=>
{
actions
.
nextStoreGuide
()
const
userInfo
=
getStorage
(
StorageKeys
.
userInfo
)
...
...
@@ -72,6 +73,7 @@ const guideModel: GuideModel = {
helpers
.
getStoreActions
().
userModel
.
updateState
({
userInfo
:
newUserInfo
})
helpers
.
getStoreActions
().
userModel
.
fetchAccount
()
}),
nextGroupGuide
:
action
(
state
=>
{
state
.
groupGuideStep
+=
1
}),
...
...
src/store/modules/user.ts
View file @
fa590a85
...
...
@@ -25,7 +25,7 @@ export interface UserModel {
exchangeItem
:
Thunk
<
UserModel
,
{
name
:
string
;
num
:
number
;
},
void
,
AppStoreModel
>
;
updateNickNameAndPhone
:
Thunk
<
UserModel
,
{
code
:
string
;
name
:
string
},
void
,
AppStoreModel
>
;
updateNickNameAndPhone
:
Thunk
<
UserModel
,
{
code
?:
string
;
name
?
:
string
},
void
,
AppStoreModel
>
;
}
const
userModel
:
UserModel
=
{
...
...
@@ -64,16 +64,35 @@ const userModel: UserModel = {
updateNickNameAndPhone
:
thunk
(
async
(
actions
,
payload
,
helpers
)
=>
{
try
{
if
(
!
payload
.
code
)
{
throw
new
Error
(
''
)
const
fns
:
Promise
<
any
>
[]
=
[
]
if
(
payload
.
name
)
{
fns
.
push
(
updateUserInfo
({
nickName
:
payload
.
name
}))
}
await
Promise
.
all
([
updateUserPhone
(
payload
.
code
),
updateUserInfo
({
nickName
:
payload
.
name
}),
])
let
authPhone
if
(
payload
.
code
)
{
fns
.
push
(
updateUserPhone
(
payload
.
code
))
authPhone
=
'Y'
}
await
Promise
.
all
(
fns
)
const
{
userInfo
}
=
helpers
.
getState
()
const
current
=
{
...
userInfo
,
nickName
:
payload
.
name
}
let
current
=
{
...
userInfo
}
if
(
authPhone
)
{
current
=
{
...
current
,
authPhone
}
}
if
(
payload
.
name
)
{
current
=
{
...
current
,
nickName
:
payload
.
name
}
}
updateStorage
(
StorageKeys
.
userInfo
,
current
)
actions
.
updateState
({
userInfo
:
current
})
...
...
src/types.ts
View file @
fa590a85
...
...
@@ -9,6 +9,8 @@ export type UserInfo = {
phone
?:
string
|
null
;
/** 是否以获取了积分 */
pointReceive
?:
'Y'
|
'N'
;
/** 是否授权了手机号 */
authPhone
?:
'Y'
|
'N'
;
}
export
type
RequestResultPagingLike
<
T
>
=
RequestResult
<
PagingLike
<
T
>>
...
...
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