Commit 3c86091c authored by hewenhao's avatar hewenhao

Merge branch 'master' of dev.jiuaoedu.com:hewenhao/GeekLearnMathWeapp

parents 61efbd65 e7445d0f
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: () => {
......
......@@ -6,7 +6,7 @@ import {
} 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'
......@@ -28,13 +28,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({
......@@ -65,15 +58,30 @@ const MainPage = () => {
})
})
const joinTribeByCode = useCallback(() => {
if (groupId && inviteId && +inviteId !== userInfo.userId) {
// 加入部落
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: (res) => {
res.confirm && run({ groupId: +groupId })
success: ({ confirm }) => {
confirm && run({ groupId: +groupId })
}
})
}
} finally {
console.log('-finally-')
}
}
}, [groupId, inviteId])
return (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment