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
61efbd65
Commit
61efbd65
authored
Apr 05, 2023
by
hewenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 兑换配置
parent
cdb99eb2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
5 deletions
+31
-5
auth.ts
src/api/auth.ts
+8
-0
main.tsx
src/pages/main/main.tsx
+7
-3
index.tsx
src/pages/market/index.tsx
+4
-1
user.ts
src/store/modules/user.ts
+12
-1
No files found.
src/api/auth.ts
View file @
61efbd65
...
...
@@ -36,3 +36,11 @@ export function getAccountInfo () {
}
}))
}
export
function
getSetting
()
{
return
requestAfterSilentLogin
<
{
pointToCard
:
number
},
{}
>
(()
=>
({
method
:
'GET'
,
url
:
'/service-idea/inlet/config/getConfig'
,
data
:
{}
}))
}
src/pages/main/main.tsx
View file @
61efbd65
import
{
View
}
from
'@tarojs/components'
import
{
useRouter
,
showToast
,
getMenuButtonBoundingClientRect
,
useDidShow
,
getCurrentInstance
,
getTabBar
,
pageScrollTo
,
getSystemInfoSync
,
showModal
}
from
'@tarojs/taro'
import
{
useRouter
,
showToast
,
getMenuButtonBoundingClientRect
,
useDidShow
,
getCurrentInstance
,
getTabBar
,
pageScrollTo
,
getSystemInfoSync
,
showModal
,
nextTick
}
from
'@tarojs/taro'
import
{
useState
,
useMemo
,
useCallback
}
from
'react'
import
{
useStoreActions
,
useStoreState
}
from
'@/store/hooks'
import
{
joinTribe
}
from
'@/api/group'
...
...
@@ -49,7 +53,7 @@ const MainPage = () => {
joinTribeByCode
()
fetchStage
().
then
((
list
)
=>
{
setTimeout
(()
=>
{
nextTick
(()
=>
{
if
(
!
list
.
find
(
c
=>
c
.
status
===
StageStatus
.
CURRENT
))
{
setIsReady
(
true
)
}
else
{
...
...
@@ -57,7 +61,7 @@ const MainPage = () => {
setIsReady
(
true
)
})
}
}
,
1000
)
})
})
})
...
...
src/pages/market/index.tsx
View file @
61efbd65
...
...
@@ -45,9 +45,12 @@ const StudyMarket = () => {
const
[
isVisible
,
{
setTrue
,
setFalse
}]
=
useBoolean
(
false
)
const
[
currentGoods
,
setCurrentGoods
]
=
useState
<
ExchangeGoods
|
null
>
(
null
)
const
point
=
useStoreState
(
state
=>
state
.
userModel
.
point
)
const
setting
=
useStoreState
(
state
=>
state
.
userModel
.
setting
)
const
fetchAccount
=
useStoreActions
(
actions
=>
actions
.
userModel
.
fetchAccount
)
const
getSetting
=
useStoreActions
(
actions
=>
actions
.
userModel
.
getSetting
)
useDidShow
(()
=>
{
getSetting
()
fetchAccount
()
})
...
...
@@ -70,7 +73,7 @@ const StudyMarket = () => {
title=
{
item
.
subTitle
}
cover=
{
item
.
img
}
stock=
{
item
.
stock
}
price=
{
item
.
price
}
price=
{
setting
.
pointToCard
}
disabled=
{
item
.
stock
!==
null
&&
item
.
stock
<
1
}
subtitle=
{
item
.
description
}
onClick=
{
()
=>
{
...
...
src/store/modules/user.ts
View file @
61efbd65
import
{
action
,
Action
,
Thunk
,
thunk
,
State
}
from
'easy-peasy'
import
{
getAccountInfo
}
from
'@/api'
import
{
getAccountInfo
,
getSetting
}
from
'@/api'
import
type
{
UserInfo
}
from
'@/types'
import
{
pointToCard
}
from
'@/api/account'
import
{
showModal
,
showToast
,
showLoading
,
hideLoading
}
from
'@tarojs/taro'
...
...
@@ -15,6 +15,8 @@ export interface UserModel {
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
>
;
exchangeItem
:
Thunk
<
UserModel
,
{
name
:
string
;
num
:
number
;
},
void
,
AppStoreModel
>
;
}
...
...
@@ -23,6 +25,15 @@ const userModel: UserModel = {
userInfo
:
getStorage
(
StorageKeys
.
userInfo
)
!
,
cardNum
:
0
,
point
:
0
,
setting
:
{
pointToCard
:
Infinity
},
getSetting
:
thunk
(
async
(
actions
)
=>
{
try
{
const
{
data
}
=
await
getSetting
()
actions
.
updateState
({
setting
:
data
})
}
catch
(
err
)
{
actions
.
updateState
({
setting
:
{
pointToCard
:
Infinity
}
})
}
}),
exchangeItem
:
thunk
(
async
(
actions
,
payload
)
=>
{
try
{
showLoading
({
mask
:
true
,
title
:
'兑换中...'
})
...
...
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