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
280b1ef3
Commit
280b1ef3
authored
Apr 06, 2023
by
m
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update
parent
4d2874c2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
44 deletions
+60
-44
group.ts
src/api/group.ts
+2
-2
index.ts
src/pages/group/model/index.ts
+3
-3
main.tsx
src/pages/main/main.tsx
+7
-39
use-show-share-modal.ts
src/pages/main/use-show-share-modal.ts
+48
-0
No files found.
src/api/group.ts
View file @
280b1ef3
...
...
@@ -83,12 +83,12 @@ export interface TribeInfo {
}
// 部落详情
export
const
getTribeInfo
=
()
=>
{
export
const
getTribeInfo
=
(
{
memberId
}:
{
memberId
?:
number
}
)
=>
{
return
requestAfterSilentLogin
<
TribeInfo
,
{
memberId
?:
number
}
>
((
userInfo
)
=>
({
url
:
'/service-idea/group/tribeInfo'
,
method
:
'POST'
,
data
:
{
memberId
:
userInfo
?.
userId
,
memberId
:
memberId
||
userInfo
?.
userId
,
}
}))
}
src/pages/group/model/index.ts
View file @
280b1ef3
...
...
@@ -11,7 +11,7 @@ export interface GroupModel {
groupMembers
:
Computed
<
GroupModel
,
MemberItem
[]
>
;
isEmpty
:
Computed
<
GroupModel
,
boolean
>
;
updateState
:
Action
<
GroupModel
,
Partial
<
State
<
GroupModel
>>>
;
fetchTribeInfo
:
Thunk
<
GroupModel
,
voi
d
,
void
,
AppStoreModel
,
Promise
<
TribeInfo
>>
;
fetchTribeInfo
:
Thunk
<
GroupModel
,
{
memberId
?:
number
}
|
undefine
d
,
void
,
AppStoreModel
,
Promise
<
TribeInfo
>>
;
queryTribePoint
:
Thunk
<
GroupModel
>
;
}
...
...
@@ -27,11 +27,11 @@ const groupModel: GroupModel = {
}
}),
fetchTribeInfo
:
thunk
(
async
(
actions
)
=>
{
fetchTribeInfo
:
thunk
(
async
(
actions
,
payload
)
=>
{
let
ret
:
TribeInfo
=
{}
try
{
Taro
.
showLoading
()
const
{
data
}
=
await
getTribeInfo
()
const
{
data
}
=
await
getTribeInfo
(
{
memberId
:
payload
?.
memberId
}
)
ret
=
data
}
catch
(
err
)
{
ret
=
{}
...
...
src/pages/main/main.tsx
View file @
280b1ef3
import
{
View
}
from
'@tarojs/components'
import
{
useRouter
,
showToast
,
getMenuButtonBoundingClientRect
,
useDidShow
,
getCurrentInstance
,
getTabBar
,
pageScrollTo
,
getSystemInfoSync
,
showModal
,
getMenuButtonBoundingClientRect
,
useDidShow
,
getCurrentInstance
,
getTabBar
,
pageScrollTo
,
getSystemInfoSync
,
nextTick
}
from
'@tarojs/taro'
import
{
useState
,
useMemo
,
useCallback
}
from
'react'
import
{
useStoreActions
,
useStoreState
}
from
'@/store/hooks'
import
{
joinTribe
}
from
'@/api/group'
import
{
useRequest
}
from
'@/hooks'
import
type
{
TabbarRef
}
from
'../../custom-tab-bar/index'
import
{
CurrentRoundId
,
SceneContext
,
StageStatus
}
from
'./components/scene/constants'
...
...
@@ -15,21 +13,21 @@ import MainHeader from './components/header'
import
MainChapter
from
'./components/chapter'
import
MainScene
from
'./components/scene'
import
MainShortCut
from
'./components/short-cut'
import
useShowShareModal
from
'./use-show-share-modal'
import
styles
from
'./main.module.scss'
const
MainPage
=
()
=>
{
const
page
=
useMemo
(()
=>
getCurrentInstance
().
page
,
[])
const
[
isReady
,
setIsReady
]
=
useState
(
false
)
const
userInfo
=
useStoreState
(
state
=>
state
.
userModel
.
userInfo
)
const
fetchStage
=
useStoreActions
(
actions
=>
actions
.
mainModel
.
fetchStage
)
const
stageList
=
useStoreState
(
state
=>
state
.
mainModel
.
stageList
)
const
fetchAccount
=
useStoreActions
(
actions
=>
actions
.
userModel
.
fetchAccount
)
const
updateUserInfo
=
useStoreActions
(
actions
=>
actions
.
userModel
.
updateUserInfo
)
const
fetchTribeInfo
=
useStoreActions
(
actions
=>
actions
.
groupModel
.
fetchTribeInfo
)
const
queryTribePoint
=
useStoreActions
(
actions
=>
actions
.
groupModel
.
queryTribePoint
)
const
[
nav
]
=
useState
(
getMenuButtonBoundingClientRect
())
const
router
=
useRouter
<
{
groupId
:
string
,
inviteId
:
string
}
>
()
const
{
groupId
,
inviteId
}
=
router
.
params
useShowShareModal
()
const
scrollToCurrent
=
useCallback
((
callback
?:
()
=>
void
)
=>
{
const
height
=
getSystemInfoSync
().
windowHeight
...
...
@@ -58,38 +56,8 @@ const MainPage = () => {
}
})
})
Promise
.
all
([
fetchTribeInfo
().
then
((
res
)
=>
{
if
(
!
res
||
!
res
.
id
)
{
joinTribeByCode
()
}
}),
queryTribePoint
()])
})
// 加入部落
const
{
run
}
=
useRequest
(
joinTribe
,
{
immediate
:
false
,
onSuccess
:
()
=>
{
showToast
({
title
:
'加入成功'
})
fetchTribeInfo
()
},
onError
:
()
=>
{
fetchTribeInfo
()
}
})
// 邀请弹框
const
joinTribeByCode
=
useCallback
(()
=>
{
if
(
groupId
&&
inviteId
&&
+
inviteId
!==
userInfo
.
userId
)
{
// 邀请人是不是自己
showModal
({
title
:
'加入部落'
,
success
:
({
confirm
})
=>
{
confirm
&&
run
({
groupId
:
+
groupId
})
}
})
}
},
[
groupId
,
inviteId
,
userInfo
.
userId
])
return
(
<>
<
MainHeader
/>
...
...
src/pages/main/use-show-share-modal.ts
0 → 100644
View file @
280b1ef3
import
{
useCallback
,
useEffect
}
from
'react'
import
{
useRouter
,
showToast
,
showModal
,
useDidShow
}
from
'@tarojs/taro'
import
{
useStoreActions
,
useStoreState
}
from
'@/store/hooks'
import
{
joinTribe
}
from
'@/api/group'
import
{
useRequest
}
from
'@/hooks'
export
default
function
useShowShareModal
()
{
const
userInfo
=
useStoreState
(
state
=>
state
.
userModel
.
userInfo
)
const
fetchTribeInfo
=
useStoreActions
(
actions
=>
actions
.
groupModel
.
fetchTribeInfo
)
const
queryTribePoint
=
useStoreActions
(
actions
=>
actions
.
groupModel
.
queryTribePoint
)
const
router
=
useRouter
<
{
groupId
:
string
,
inviteId
:
string
}
>
()
const
{
groupId
,
inviteId
}
=
router
.
params
useDidShow
(()
=>
{
Promise
.
all
([
queryTribePoint
(),
fetchTribeInfo
().
then
((
res
)
=>
{
if
(
!
res
||
!
res
.
id
)
{
joinTribeWithCode
()
}
})
])
})
// 加入部落
const
{
run
}
=
useRequest
(
joinTribe
,
{
immediate
:
false
,
onSuccess
:
()
=>
{
showToast
({
title
:
'加入成功'
})
fetchTribeInfo
()
}
})
// 邀请弹框
const
joinTribeWithCode
=
useCallback
(
async
()
=>
{
if
(
groupId
&&
inviteId
&&
+
inviteId
!==
userInfo
.
userId
)
{
// 邀请人是不是自己
const
res
=
await
fetchTribeInfo
({
memberId
:
+
inviteId
})
const
memberName
=
res
.
groupMembers
?.
find
(
item
=>
item
.
identity
===
'LEADER'
)?.
memberName
showModal
({
title
:
`
${
memberName
}
邀请你加入《
${
res
.
groupNo
}
》部落!`
,
success
:
({
confirm
})
=>
{
confirm
&&
run
({
groupId
:
+
groupId
})
}
})
}
},
[
groupId
,
inviteId
,
userInfo
.
userId
,
fetchTribeInfo
])
}
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