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
d985c18d
Commit
d985c18d
authored
Apr 05, 2023
by
m
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update
parent
30e65cfb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
20 deletions
+25
-20
index.tsx
src/pages/group/index.tsx
+2
-5
main.tsx
src/pages/main/main.tsx
+23
-15
No files found.
src/pages/group/index.tsx
View file @
d985c18d
import
{
View
,
Image
,
Input
}
from
'@tarojs/components'
import
{
useDidShow
,
getCurrentInstance
,
getTabBar
,
getMenuButtonBoundingClientRect
,
showModal
,
useShareAppMessage
}
from
'@tarojs/taro'
import
{
useMemo
,
useState
,
useEffect
}
from
'react'
import
{
useMemo
,
useState
}
from
'react'
import
Modal
from
'@/components/Modal'
import
Button
from
'@/components/Button'
...
...
@@ -35,6 +35,7 @@ const Group = () => {
useDidShow
(()
=>
{
const
tabbar
=
getTabBar
<
TabbarRef
>
(
page
)
tabbar
?.
setSelected
(
1
)
fetchTribeInfo
()
})
useShareAppMessage
(()
=>
{
...
...
@@ -45,10 +46,6 @@ const Group = () => {
}
})
useEffect(() => {
fetchTribeInfo()
}, [fetchTribeInfo])
const { run, loading: spining } = useRequest(createTribe, {
immediate: false,
onSuccess: () => {
...
...
src/pages/main/main.tsx
View file @
d985c18d
...
...
@@ -2,7 +2,7 @@ import { View } from '@tarojs/components'
import
{
useRouter
,
showToast
,
getMenuButtonBoundingClientRect
,
useDidShow
,
getCurrentInstance
,
getTabBar
,
pageScrollTo
,
getSystemInfoSync
,
showModal
}
from
'@tarojs/taro'
import
{
useState
,
useMemo
,
useCallback
}
from
'react'
import
{
useStoreActions
,
useStoreState
}
from
'@/store/hooks'
import
{
joinTribe
}
from
'@/api/group'
import
{
getTribeInfo
,
joinTribe
}
from
'@/api/group'
import
{
useRequest
}
from
'@/hooks'
import
type
{
TabbarRef
}
from
'../../custom-tab-bar/index'
...
...
@@ -24,13 +24,6 @@ const MainPage = () => {
const
router
=
useRouter
<
{
groupId
:
string
,
inviteId
:
string
}
>
()
const
{
groupId
,
inviteId
}
=
router
.
params
const
{
run
}
=
useRequest
(
joinTribe
,
{
immediate
:
false
,
onSuccess
:
()
=>
{
showToast
()
}
})
const
scrollToCurrent
=
useCallback
((
callback
?:
()
=>
void
)
=>
{
const
height
=
getSystemInfoSync
().
windowHeight
pageScrollTo
({
...
...
@@ -61,14 +54,29 @@ const MainPage = () => {
})
})
const
joinTribeByCode
=
useCallback
(()
=>
{
if
(
groupId
&&
inviteId
&&
+
inviteId
!==
userInfo
.
userId
)
{
showModal
({
title
:
'加入部落'
,
success
:
(
res
)
=>
{
res
.
confirm
&&
run
({
groupId
:
+
groupId
})
// 加入部落
const
{
run
}
=
useRequest
(
joinTribe
,
{
immediate
:
false
,
onSuccess
:
()
=>
{
showToast
({
title
:
'加入成功'
})
}
})
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
})
}
})
}
})
}
finally
{
console
.
log
(
'-finally-'
)
}
}
},
[
groupId
,
inviteId
])
...
...
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