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