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
a11177bb
Commit
a11177bb
authored
Apr 05, 2023
by
hewenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update
parent
51553d35
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
14 deletions
+38
-14
auth.ts
src/api/auth.ts
+11
-0
header.module.scss
src/pages/main/components/header.module.scss
+8
-6
header.tsx
src/pages/main/components/header.tsx
+2
-1
user.ts
src/store/modules/user.ts
+16
-6
silent-login.ts
src/utils/silent-login.ts
+1
-1
No files found.
src/api/auth.ts
View file @
a11177bb
...
...
@@ -37,6 +37,17 @@ export function getAccountInfo () {
}))
}
export
function
updateUserInfo
(
nickName
:
string
)
{
return
requestAfterSilentLogin
<
void
,
{
nickName
:
string
;
userId
?:
number
;
}
>
(
userInfo
=>
({
method
:
'POST'
,
url
:
'/service-idea/stage/user/updateUserInfo'
,
data
:
{
nickName
,
userId
:
userInfo
?.
userId
}
}))
}
export
function
getSetting
()
{
return
requestAfterSilentLogin
<
{
pointToCard
:
number
},
{}
>
(()
=>
({
method
:
'GET'
,
...
...
src/pages/main/components/header.module.scss
View file @
a11177bb
...
...
@@ -32,13 +32,15 @@
.avatar
{
flex
:
1
;
.icon
{
min-width
:
0
;
.name
{
overflow
:
hidden
;
text-overflow
:
ellipsis
;
white-space
:
nowrap
;
font-size
:
14
PX
;
font-weight
:
500
;
margin-left
:
16
PX
;
width
:
32
PX
;
height
:
32
PX
;
margin-right
:
4
PX
;
border-radius
:
16
PX
;
background-color
:
#999
;
color
:
#FFFFFF
;
}
}
...
...
src/pages/main/components/header.tsx
View file @
a11177bb
...
...
@@ -25,6 +25,7 @@ const MainHeader = () => {
const
cardNum
=
useStoreState
(
state
=>
state
.
userModel
.
cardNum
)
const
point
=
useStoreState
(
state
=>
state
.
userModel
.
point
)
const
userInfo
=
useStoreState
(
state
=>
state
.
userModel
.
userInfo
)
return
(
<
View
className=
{
styles
.
header
}
>
...
...
@@ -38,7 +39,7 @@ const MainHeader = () => {
>
<
View
className=
{
styles
.
inner
}
style=
{
innerStyle
}
>
<
View
className=
{
styles
.
avatar
}
>
<
Image
src=
"https://cdn.jkwljy.com/pbb/6gkGHSsPmxc_coeGYahBkelo_2w_/96x96"
className=
{
styles
.
icon
}
></
Image
>
<
Text
className=
{
styles
.
name
}
>
{
userInfo
?.
nickname
??
''
}
</
Text
>
</
View
>
<
View
className=
{
classNames
(
styles
.
score
,
cs
.
bounce_btn
)
}
onClick=
{
goStore
}
hoverClass=
{
cs
.
bounce_btn_hover
}
>
<
Image
src=
{
require
(
'../assets/score.png'
)
}
className=
{
styles
.
icon
}
/>
...
...
src/store/modules/user.ts
View file @
a11177bb
import
{
action
,
Action
,
Thunk
,
thunk
,
State
}
from
'easy-peasy'
import
{
getAccountInfo
,
getSetting
}
from
'@/api'
import
{
getAccountInfo
,
getSetting
,
updateUserInfo
}
from
'@/api'
import
type
{
UserInfo
}
from
'@/types'
import
{
pointToCard
}
from
'@/api/account'
import
{
showModal
,
showToast
,
showLoading
,
hideLoading
}
from
'@tarojs/taro'
import
{
getStorage
,
StorageKeys
}
from
'@/utils/storage'
import
{
getStorage
,
StorageKeys
,
updateStorage
}
from
'@/utils/storage'
import
{
AppStoreModel
}
from
'../store-model'
export
interface
UserModel
{
...
...
@@ -14,9 +14,9 @@ export interface UserModel {
point
:
number
;
updateState
:
Action
<
UserModel
,
Partial
<
State
<
UserModel
>>>
;
fetchAccount
:
Thunk
<
UserModel
,
void
,
void
,
AppStoreModel
>
;
updateUserInfo
:
Action
<
UserModel
,
UserInfo
>
;
setting
:
{
pointToCard
:
number
};
getSetting
:
Thunk
<
UserModel
,
void
,
void
,
AppStoreModel
>
;
updateUserInfo
:
Thunk
<
UserModel
,
string
,
void
,
AppStoreModel
>
;
exchangeItem
:
Thunk
<
UserModel
,
{
name
:
string
;
num
:
number
;
},
void
,
AppStoreModel
>
;
}
...
...
@@ -34,6 +34,19 @@ const userModel: UserModel = {
actions
.
updateState
({
setting
:
{
pointToCard
:
Infinity
}
})
}
}),
updateUserInfo
:
thunk
(
async
(
actions
,
nickname
,
helpers
)
=>
{
try
{
await
updateUserInfo
(
nickname
)
const
{
userInfo
}
=
helpers
.
getState
()
const
current
=
{
...
userInfo
,
nickname
}
updateStorage
(
StorageKeys
.
userInfo
,
current
)
actions
.
updateState
({
userInfo
:
current
})
}
catch
(
err
)
{
console
.
log
(
err
)
}
}),
exchangeItem
:
thunk
(
async
(
actions
,
payload
)
=>
{
try
{
showLoading
({
mask
:
true
,
title
:
'兑换中...'
})
...
...
@@ -52,9 +65,6 @@ const userModel: UserModel = {
})
}
}),
updateUserInfo
:
action
((
state
,
user
)
=>
{
state
.
userInfo
=
user
}),
updateState
:
action
((
state
,
payload
)
=>
{
for
(
const
key
in
payload
)
{
state
[
key
]
=
payload
[
key
]
...
...
src/utils/silent-login.ts
View file @
a11177bb
...
...
@@ -28,7 +28,7 @@ async function silentLogin () {
updateStorage(StorageKeys.openid, data.openId)
updateStorage(StorageKeys.userInfo, data)
store.getActions().userModel.update
UserInfo(data
)
store.getActions().userModel.update
State({ userInfo: data }
)
setProfile(data.openId, `
$
{
data
.
userId
}
`)
} catch (silentLoginError) {
...
...
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