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
5dcb4a02
Commit
5dcb4a02
authored
Apr 05, 2023
by
hewenhao
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of dev.jiuaoedu.com:hewenhao/GeekLearnMathWeapp
parents
c31dcf8a
4fa13543
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
46 deletions
+51
-46
group.ts
src/api/group.ts
+1
-1
members.tsx
src/pages/group/components/members.tsx
+4
-9
index.tsx
src/pages/group/index.tsx
+24
-8
index.ts
src/pages/group/model/index.ts
+8
-13
main.tsx
src/pages/main/main.tsx
+14
-15
No files found.
src/api/group.ts
View file @
5dcb4a02
...
...
@@ -69,7 +69,7 @@ export type MemberItem = {
memberName
?:
number
,
schoolName
?:
number
,
stageNum
?:
number
;
identity
?:
string
;
identity
?:
'LEADER'
|
'NORMAL'
;
no
:
number
;
}
export
interface
TribeInfo
{
...
...
src/pages/group/components/members.tsx
View file @
5dcb4a02
...
...
@@ -5,20 +5,19 @@ import { useStoreState } from '@/store/hooks'
import
assets
from
'@/assets/oss/assets-group'
import
ShareButton
from
'./share-button'
import
styles
from
'./members.module.scss'
const
Members
=
()
=>
{
const
userInfo
=
useStoreState
(
state
=>
state
.
userModel
.
userInfo
)
const
{
groupMembers
,
isEmpty
}
=
useStoreState
(
state
=>
state
.
groupModel
)
const
renderItem
=
(
item
:
MemberItem
)
=>
{
const
renderItem
=
(
item
:
MemberItem
,
index
:
number
)
=>
{
const
isCurrent
=
userInfo
.
userId
===
item
.
memberId
return
(
<
View
key=
{
item
.
memberId
}
className=
{
styles
.
item
}
>
<
View
className=
{
styles
.
item_rank
}
>
{
[
1
,
2
,
3
].
includes
(
i
tem
.
no
)
?
<
Image
className=
{
styles
.
item_rank_icon
}
src=
{
assets
[
`rank-${i
tem.no
}.png`
].
u
}
/>
{
[
1
,
2
,
3
].
includes
(
i
ndex
+
1
)
?
<
Image
className=
{
styles
.
item_rank_icon
}
src=
{
assets
[
`rank-${i
ndex + 1
}.png`
].
u
}
/>
:
<
Text
className=
{
styles
.
item_rank_number
}
>
{
item
.
no
}
</
Text
>
}
</
View
>
...
...
@@ -32,7 +31,7 @@ const Members = () => {
</
View
>
<
Text
className=
{
styles
.
schoolName
}
>
{
item
.
schoolName
}
</
Text
>
</
View
>
<
Text
className=
{
styles
.
item_role
}
>
{
item
.
identity
}
</
Text
>
<
Text
className=
{
styles
.
item_role
}
>
{
item
.
identity
===
'LEADER'
?
'族长'
:
'成员'
}
</
Text
>
<
Text
className=
{
styles
.
item_count
}
>
{
item
.
stageNum
}
</
Text
>
</
View
>
)
...
...
@@ -51,10 +50,6 @@ const Members = () => {
{
groupMembers
.
map
(
renderItem
)
}
{
isEmpty
&&
<
View
className=
{
styles
.
empty
}
><
Text
>
暂无数据
</
Text
></
View
>
}
</
View
>
<
View
className=
{
styles
.
members_invite
}
>
<
ShareButton
/>
</
View
>
</
View
>
)
}
...
...
src/pages/group/index.tsx
View file @
5dcb4a02
import
{
View
,
Image
,
Input
}
from
'@tarojs/components'
import
{
View
,
Image
,
Input
,
ScrollView
}
from
'@tarojs/components'
import
{
useDidShow
,
getCurrentInstance
,
getTabBar
,
getMenuButtonBoundingClientRect
,
showModal
,
useShareAppMessage
}
from
'@tarojs/taro'
import
{
useMemo
,
useState
}
from
'react'
...
...
@@ -16,16 +16,19 @@ import MainHeader from './components/header'
import
Creator
from
'./components/creator'
import
Members
from
'./components/members'
import
ShareButton
from
'./components/share-button'
import
styles
from
'./index.module.scss'
import
memberStyles
from
'./components/members.module.scss'
const
Group
=
()
=>
{
const
page
=
getCurrentInstance
().
page
const
[
nav
]
=
useState
(
getMenuButtonBoundingClientRect
())
const
[
isVisible
,
{
setTrue
,
setFalse
}]
=
useBoolean
(
false
)
const
[
groupNo
,
setGroupNo
]
=
useState
<
string
>
(
''
)
const
[
refresher
,
{
toggle
}]
=
useBoolean
(
false
)
const
userInfo
=
useStoreState
(
state
=>
state
.
userModel
.
userInfo
)
const
{
tribeInfo
,
loading
}
=
useStoreState
(
state
=>
state
.
groupModel
)
const
{
tribeInfo
}
=
useStoreState
(
state
=>
state
.
groupModel
)
const
fetchTribeInfo
=
useStoreActions
(
actions
=>
actions
.
groupModel
.
fetchTribeInfo
)
const
tabBarHeight
=
useMemo
(()
=>
{
...
...
@@ -35,7 +38,6 @@ const Group = () => {
useDidShow
(()
=>
{
const
tabbar
=
getTabBar
<
TabbarRef
>
(
page
)
tabbar
?.
setSelected
(
1
)
fetchTribeInfo
()
})
useShareAppMessage
(()
=>
{
...
...
@@ -62,21 +64,35 @@ const Group = () => {
run({ groupNo })
}
if (loading) {
return null
const onRefresher = async () => {
try {
toggle()
await fetchTribeInfo()
} finally {
setTimeout(() => toggle(), 600)
}
}
return (
<View>
<TopHeader />
<View style={{ paddingTop: `
$
{
tabBarHeight
}
px
` }}>
<ScrollView
refresherEnabled={!!tribeInfo?.groupNo}
refresherTriggered={refresher}
onRefresherRefresh={onRefresher}
style={{ paddingTop: `
$
{
tabBarHeight
}
px
` }}
>
<MainHeader groupNo={tribeInfo?.groupNo!} />
<View>
{!tribeInfo?.
groupNo
? <Creator onClick={setTrue} /> : <Members />}
{!tribeInfo?.
id
? <Creator onClick={setTrue} /> : <Members />}
</View>
</View>
</ScrollView>
{tribeInfo?.id && <View className={memberStyles.members_invite}>
<ShareButton />
</View>}
<Modal isVisible={isVisible} tilte="学习部落名" onClose={setFalse}>
<View className={styles.modal}>
...
...
src/pages/group/model/index.ts
View file @
5dcb4a02
...
...
@@ -3,20 +3,18 @@ import {
action
,
Action
,
computed
,
Computed
,
Thunk
,
thunk
}
from
'easy-peasy'
import
{
getTribeInfo
,
type
TribeInfo
,
type
MemberItem
}
from
'@/api/group'
import
{
AppStoreModel
}
from
'@/store/store-model'
export
interface
GroupModel
{
tribeInfo
:
TribeInfo
|
null
;
loading
:
boolean
,
groupMembers
:
Computed
<
GroupModel
,
MemberItem
[]
>
;
isEmpty
:
Computed
<
GroupModel
,
boolean
>
;
updateState
:
Action
<
GroupModel
,
TribeInfo
|
null
>
;
setLoading
:
Action
<
GroupModel
,
boolean
>
;
fetchTribeInfo
:
Thunk
<
GroupModel
>
;
fetchTribeInfo
:
Thunk
<
GroupModel
,
void
,
void
,
AppStoreModel
,
Promise
<
TribeInfo
>>
;
}
const
groupModel
:
GroupModel
=
{
tribeInfo
:
null
,
loading
:
true
,
groupMembers
:
computed
((
state
)
=>
state
.
tribeInfo
?.
groupMembers
||
[]),
isEmpty
:
computed
((
state
)
=>
state
.
groupMembers
.
length
<
1
),
...
...
@@ -24,23 +22,20 @@ const groupModel: GroupModel = {
state
.
tribeInfo
=
payload
}),
setLoading
:
action
((
state
,
payload
)
=>
{
state
.
loading
=
payload
}),
fetchTribeInfo
:
thunk
(
async
(
actions
)
=>
{
let
ret
:
TribeInfo
=
{}
try
{
Taro
.
showLoading
()
actions
.
setLoading
(
true
)
const
{
data
}
=
await
getTribeInfo
()
actions
.
updateState
(
data
)
ret
=
data
}
catch
(
err
)
{
ret
=
{}
Taro
.
showModal
({
title
:
err
.
message
})
actions
.
updateState
(
null
)
}
finally
{
Taro
.
hideLoading
()
actions
.
setLoading
(
false
)
setTimeout
(()
=>
Taro
.
hideLoading
(),
300
)
}
actions
.
updateState
(
ret
)
return
ret
})
}
...
...
src/pages/main/main.tsx
View file @
5dcb4a02
...
...
@@ -24,6 +24,7 @@ const MainPage = () => {
const
fetchStage
=
useStoreActions
(
actions
=>
actions
.
mainModel
.
fetchStage
)
const
stageList
=
useStoreState
(
state
=>
state
.
mainModel
.
stageList
)
const
fetchAccount
=
useStoreActions
(
actions
=>
actions
.
userModel
.
fetchAccount
)
const
fetchTribeInfo
=
useStoreActions
(
actions
=>
actions
.
groupModel
.
fetchTribeInfo
)
const
[
nav
]
=
useState
(
getMenuButtonBoundingClientRect
())
const
router
=
useRouter
<
{
groupId
:
string
,
inviteId
:
string
}
>
()
const
{
groupId
,
inviteId
}
=
router
.
params
...
...
@@ -43,8 +44,6 @@ const MainPage = () => {
const
tabbar
=
getTabBar
<
TabbarRef
>
(
page
)
tabbar
?.
setSelected
(
0
)
joinTribeByCode
()
fetchStage
().
then
((
list
)
=>
{
nextTick
(()
=>
{
if
(
!
list
.
find
(
c
=>
c
.
status
===
StageStatus
.
CURRENT
))
{
...
...
@@ -56,6 +55,12 @@ const MainPage = () => {
}
})
})
fetchTribeInfo
().
then
((
res
)
=>
{
if
(
!
res
.
id
||
!
res
)
{
joinTribeByCode
()
}
})
})
// 加入部落
...
...
@@ -66,23 +71,17 @@ const MainPage = () => {
}
})
// 邀请弹框
const
joinTribeByCode
=
useCallback
(
async
()
=>
{
if
(
groupId
&&
inviteId
&&
+
inviteId
!==
userInfo
.
userId
)
{
// 邀请人是不是自己
try
{
const
res
=
await
getTribeInfo
()
if
(
!
res
.
data
.
id
)
{
// 是否已经加入部落
showModal
({
title
:
'加入部落'
,
success
:
({
confirm
})
=>
{
confirm
&&
run
({
groupId
:
+
groupId
})
}
})
showModal
({
title
:
'加入部落'
,
success
:
({
confirm
})
=>
{
confirm
&&
run
({
groupId
:
+
groupId
})
}
}
finally
{
console
.
log
(
'-finally-'
)
}
})
}
},
[
groupId
,
inviteId
])
},
[
groupId
,
inviteId
,
userInfo
.
userId
])
return
(
<>
...
...
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