Commit 170e6d51 authored by hewenhao's avatar hewenhao

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

parents 32ba5d59 65539151
...@@ -100,5 +100,41 @@ ...@@ -100,5 +100,41 @@
"w": 108, "w": 108,
"h": 108, "h": 108,
"ossName": "/pk-math/3h61NcsK8f2Urp9GAB8PkwsnuGQY/108x108" "ossName": "/pk-math/3h61NcsK8f2Urp9GAB8PkwsnuGQY/108x108"
},
"share-bg.png": {
"u": "https://cdn.jkwljy.com/pk-math/3JmdaED61erY4F9f4pzxoYXj2hsy/654x978",
"w": 654,
"h": 978,
"ossName": "/pk-math/3JmdaED61erY4F9f4pzxoYXj2hsy/654x978"
},
"share-diamond.png": {
"u": "https://cdn.jkwljy.com/pk-math/4JQf8wdXqJ5uAwVSWXcmMq5gNBgm/96x96",
"w": 96,
"h": 96,
"ossName": "/pk-math/4JQf8wdXqJ5uAwVSWXcmMq5gNBgm/96x96"
},
"share-flag.png": {
"u": "https://cdn.jkwljy.com/pk-math/Xj64hgWiQC4ZCEGtvpufrj5gQBf/96x96",
"w": 96,
"h": 96,
"ossName": "/pk-math/Xj64hgWiQC4ZCEGtvpufrj5gQBf/96x96"
},
"share-pk.png": {
"u": "https://cdn.jkwljy.com/pk-math/2UhijHfydsKkm6Rd7LQuybonQ388/96x96",
"w": 96,
"h": 96,
"ossName": "/pk-math/2UhijHfydsKkm6Rd7LQuybonQ388/96x96"
},
"share-subtitle.png": {
"u": "https://cdn.jkwljy.com/pk-math/4RG6wKv3MbAHSTtT1QcwdDuKVq6/190x32",
"w": 190,
"h": 32,
"ossName": "/pk-math/4RG6wKv3MbAHSTtT1QcwdDuKVq6/190x32"
},
"share-title.png": {
"u": "https://cdn.jkwljy.com/pk-math/2hY71nSJZALkZzKSyjd6ok4VSvk2/322x38",
"w": 322,
"h": 38,
"ossName": "/pk-math/2hY71nSJZALkZzKSyjd6ok4VSvk2/322x38"
} }
} }
...@@ -30,6 +30,12 @@ export const enum StageType { ...@@ -30,6 +30,12 @@ export const enum StageType {
OneStop = '一战到底', OneStop = '一战到底',
} }
export const enum StageGear {
TOP10 = '10',
TOP20 = '20',
TOP30 = '30',
}
export const enum StageLevel { export const enum StageLevel {
S = 'S', S = 'S',
A = 'A', A = 'A',
...@@ -38,7 +44,7 @@ export const enum StageLevel { ...@@ -38,7 +44,7 @@ export const enum StageLevel {
export interface Stage { export interface Stage {
content: string; content: string;
gear: number; gear: number | string;
id: number; id: number;
label: string; label: string;
level: StageLevel; level: StageLevel;
...@@ -62,7 +68,7 @@ export type StageRank = { ...@@ -62,7 +68,7 @@ export type StageRank = {
} }
export type NextStep = { export type NextStep = {
nextStep: string; nextStep: string | number;
nextStepReward: number; nextStepReward: number;
nextStepTime: number nextStepTime: number
} }
......
...@@ -35,14 +35,15 @@ export const postTribePoint = ({ type }: Pick<PointType, 'type'>) => { ...@@ -35,14 +35,15 @@ export const postTribePoint = ({ type }: Pick<PointType, 'type'>) => {
} }
// 加入部落 // 加入部落
export const joinTribe = ({ groupId }: { groupId: number }) => { export const joinTribe = ({ groupId, shareUserId }: { groupId: number, shareUserId: number }) => {
return requestAfterSilentLogin<{}, { groupId: number }>((userInfo) => ({ return requestAfterSilentLogin<{}, { groupId: number, shareUserId: number }>((userInfo) => ({
url: '/service-idea/group/joinTribe', url: '/service-idea/group/joinTribe',
method: 'POST', method: 'POST',
data: { data: {
groupId, groupId,
shareUserId,
memberId: userInfo?.userId, memberId: userInfo?.userId,
memberName: userInfo?.nickName || '爹🐂' memberName: userInfo?.nickName
} }
})) }))
} }
......
...@@ -85,5 +85,35 @@ export default { ...@@ -85,5 +85,35 @@ export default {
"u": "https://cdn.jkwljy.com/pk-math/3h61NcsK8f2Urp9GAB8PkwsnuGQY/108x108", "u": "https://cdn.jkwljy.com/pk-math/3h61NcsK8f2Urp9GAB8PkwsnuGQY/108x108",
"w": 108, "w": 108,
"h": 108 "h": 108
},
"share-bg.png": {
"u": "https://cdn.jkwljy.com/pk-math/3JmdaED61erY4F9f4pzxoYXj2hsy/654x978",
"w": 654,
"h": 978
},
"share-diamond.png": {
"u": "https://cdn.jkwljy.com/pk-math/4JQf8wdXqJ5uAwVSWXcmMq5gNBgm/96x96",
"w": 96,
"h": 96
},
"share-flag.png": {
"u": "https://cdn.jkwljy.com/pk-math/Xj64hgWiQC4ZCEGtvpufrj5gQBf/96x96",
"w": 96,
"h": 96
},
"share-pk.png": {
"u": "https://cdn.jkwljy.com/pk-math/2UhijHfydsKkm6Rd7LQuybonQ388/96x96",
"w": 96,
"h": 96
},
"share-subtitle.png": {
"u": "https://cdn.jkwljy.com/pk-math/4RG6wKv3MbAHSTtT1QcwdDuKVq6/190x32",
"w": 190,
"h": 32
},
"share-title.png": {
"u": "https://cdn.jkwljy.com/pk-math/2hY71nSJZALkZzKSyjd6ok4VSvk2/322x38",
"w": 322,
"h": 38
} }
} as const } as const
...@@ -47,7 +47,7 @@ const Group = () => { ...@@ -47,7 +47,7 @@ const Group = () => {
useShareAppMessage(() => { useShareAppMessage(() => {
return { return {
title: '来看看这个有趣的页面!', title: '来看看这个有趣的页面!',
path: `pages/main/main?groupId=${tribeInfo?.id}&inviteId=${userInfo.userId}`, path: `pages/main/main?groupId=${tribeInfo?.id}&shareUserId=${userInfo.userId}`,
imageUrl: 'https://picx.zhimg.com/v2-7b7b072d4bebd5ccf48c04ec1146e844_1440w.jpg?', imageUrl: 'https://picx.zhimg.com/v2-7b7b072d4bebd5ccf48c04ec1146e844_1440w.jpg?',
} }
}) })
...@@ -80,10 +80,9 @@ const Group = () => { ...@@ -80,10 +80,9 @@ const Group = () => {
return ( return (
<View> <View>
<TopHeader /> <TopHeader />
<ScrollView <ScrollView
refresherEnabled={!!tribeInfo?.groupNo} refresherEnabled={!!tribeInfo?.id}
refresherTriggered={refresher} refresherTriggered={!!tribeInfo?.id && refresher}
onRefresherRefresh={onRefresher} onRefresherRefresh={onRefresher}
style={{ paddingTop: `${tabBarHeight}px` }} style={{ paddingTop: `${tabBarHeight}px` }}
> >
......
.mask {
position: fixed;
left: 0;
top: 0;
bottom: 0;
right: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 10001;
overflow: hidden;
display: flex;
align-items: center;
justify-self: center;
opacity: 0;
pointer-events: none;
// transition: opacity .5s cubic-bezier(0.175,0.885,0.32,1.0);
transition: opacity 0.3s ease-in-out;
&.is_show {
opacity: 1;
pointer-events: all;
}
}
.modal {
position: fixed;
left: 48px;
right: 48px;
background-image: url('https://cdn.jkwljy.com/pk-math/3JmdaED61erY4F9f4pzxoYXj2hsy/654x978');
background-size: 100% 100%;
color: #465164;
padding: 64px 24px 0;
.header {
display: flex;
flex-direction: column;
gap: 12px;
padding: 0 24px;
> .title {
font-size: 36px;
font-weight: 600;
}
> .logo {
width: 322px;
height: 38px;
}
}
.main {
gap: 16px;
font-size: 24px;
margin-top: 40px;
background-color: #FCFFED;
border-radius: 24px;
padding: 36px 32px 26px;
position: relative;
.message {
top: -22px;
justify-self: center;
left: 0;
right: 0;
position: absolute;
display: flex;
justify-content: center;
color: rgba(70,81,100,0.5);
&_text {
padding: 8px 20px 0;
border-radius: 22px;
background-color: #FCFFED;
}
}
> .details {
display: flex;
flex-direction: column;
gap: 12px;
.detail {
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px 32px;
background: rgba(174,218,0,0.1);
border-radius: 30px;
.label {
color: rgba(70,81,100,0.5);
}
.value {
letter-spacing: 1PX;
font-size: 28px;
font-weight: 600;
}
}
}
}
.description {
display: flex;
flex-direction: column;
gap: 32px;
margin-top: 16px;
background-color: #FCFFED;
border-radius: 24px;
padding: 28px 32px;
> .title {
display: flex;
gap: 16px;
align-items: center;
.line {
flex: 1;
height: 2PX;
background: #FE9B45;
}
> .logo {
width: 190px;
height: 32px;
}
}
> .details {
display: flex;
gap: 32px;
.detail {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: rgba(254,155,69,0.1);
border-radius: 32px;
padding: 24px 0 20px;
gap: 12px;
.logo {
width: 96px;
height: 96px;
}
.text {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 4px;
color: #FE9B45;
font-size: 32px;
}
}
}
}
.footer {
display: flex;
align-items: center;
padding: 0 40px;
font-size: 28px;
font-weight: 500;
gap: 32px;
color: #FFFFFF;
margin: 32px 0;
.cancel {
flex: 1;
height: 72px;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
border-radius: 36px;
color: #465164;
border: 2PX solid #465164;
}
.confirm {
flex: 1;
height: 72px;
display: flex;
background-color: #465164;
align-items: center;
justify-content: center;
border-radius: 36px;
}
}
}
@supports (padding-bottom: constant(safe-area-inset-bottom)) or (padding-bottom: env(safe-area-inset-bottom)) {
.modal {
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom : env(safe-area-inset-bottom);
}
}
\ No newline at end of file
import { View, Text, RootPortal, Image } from '@tarojs/components'
import { useCallback, useState } from 'react'
import { useRouter, showToast, showModal, switchTab, useDidShow } from '@tarojs/taro'
import classNames from 'classnames'
import { useStoreActions, useStoreState } from '@/store/hooks'
import { getTribeInfo, joinTribe, type MemberItem } from '@/api/group'
import { useRequest, useBoolean } from '@/hooks'
import assets from '@/assets/oss/assets-main'
import styles from './share-modal.module.scss'
type DetailType = {
numbers?: number,
groupId?: number,
shareUserId?: number,
groupNo?: string,
leader?: MemberItem,
member?: MemberItem
}
export default function ShareModal () {
const [isVisible, { setTrue, setFalse }] = useBoolean(false)
const [detail, setDetail] = useState<DetailType>({})
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, shareUserId: string }>()
const { groupId, shareUserId } = router.params
useDidShow(() => {
Promise.all([queryTribePoint(), showShareModal()])
})
// 邀请弹框
const joinTribeWithCode = useCallback(async () => {
if (groupId && shareUserId && +shareUserId !== userInfo.userId) { // 邀请人是不是自己
try {
refresh({ memberId: +shareUserId })
} catch (error) {
showModal({ title: error })
}
}
}, [groupId, shareUserId, userInfo.userId, fetchTribeInfo])
const showShareModal = useCallback(async () => {
const res = await fetchTribeInfo()
if (!res || !res.id) { // 没有加入过部落
joinTribeWithCode()
}
}, [joinTribeWithCode, fetchTribeInfo])
// 加入部落
const { run } = useRequest(joinTribe, {
immediate: false,
onSuccess: async () => {
setFalse()
await showToast({ title: '加入成功', mask: true })
await fetchTribeInfo()
switchTab({ url: '/pages/group/index' })
}
})
const { run: refresh } = useRequest(getTribeInfo, {
immediate: false,
onSuccess: (res) => {
const leader = res.groupMembers?.find(item => item.identity === 'LEADER')
const member = res.groupMembers?.find(item => item.memberId === +shareUserId)
setTrue()
setDetail({
leader,
member,
groupId: +groupId,
shareUserId: +shareUserId,
groupNo: res.groupNo,
numbers: res.groupMembers?.length
})
}
})
if (!isVisible) {
return null
}
return (
<RootPortal enable>
<View className={classNames(styles.mask, isVisible && styles.is_show)}>
<View className={styles.modal}>
<View className={styles.header}>
<Text className={styles.title}>{detail.member?.memberName || '-'}</Text>
<Image className={styles.logo} src={assets['share-title.png'].u} />
</View>
<View className={styles.main}>
<View className={styles.message}>
<Text className={styles.message_text}>部落信息</Text>
</View>
<View className={styles.details}>
<View className={styles.detail}>
<Text className={styles.label}>部落名称:</Text>
<Text className={styles.value}>{detail.groupNo}</Text>
</View>
<View className={styles.detail}>
<Text className={styles.label}>部落族长:</Text>
<Text className={styles.value}>{detail.leader?.memberName}</Text>
</View>
<View className={styles.detail}>
<Text className={styles.label}>成员数量:</Text>
<Text className={styles.value}>{detail.numbers || 0}人</Text>
</View>
</View>
</View>
<View className={styles.description}>
<View className={styles.title}>
<Text className={styles.line} />
<Image className={styles.logo} src={assets['share-subtitle.png'].u} />
<Text className={styles.line} />
</View>
<View className={styles.details}>
<View className={styles.detail}>
<Image className={styles.logo} src={assets['share-diamond.png'].u} />
<View className={styles.text}>
<Text>+50</Text>
<Text>获取奖励</Text>
</View>
</View>
<View className={styles.detail}>
<Image className={styles.logo} src={assets['share-pk.png'].u} />
<View className={styles.text}>
<Text>一起PK</Text>
<Text>互相激励</Text>
</View>
</View>
<View className={styles.detail}>
<Image className={styles.logo} src={assets['share-flag.png'].u} />
<View className={styles.text}>
<Text>部落大赛</Text>
<Text>好玩有趣</Text>
</View>
</View>
</View>
</View>
<View className={styles.footer}>
<Text className={styles.cancel} onClick={setFalse}>暂不加入</Text>
<Text className={styles.confirm} onClick={() => run({ groupId: detail.groupId!, shareUserId: detail.shareUserId! })}>
确定加入
</Text>
</View>
</View>
</View>
</RootPortal>
)
}
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])
}
...@@ -2,7 +2,7 @@ import { View, Text, Image } from '@tarojs/components' ...@@ -2,7 +2,7 @@ import { View, Text, Image } from '@tarojs/components'
import { useCallback, useMemo } from 'react' import { useCallback, useMemo } from 'react'
import { useStoreState } from '@/store/hooks' import { useStoreState } from '@/store/hooks'
import { StageType, StageLevel, type StageDetail, type NextStep } from '@/api' import { StageType, StageLevel, StageGear, type StageDetail, type NextStep } from '@/api'
import assets from '@/assets/oss/assets-prepare' import assets from '@/assets/oss/assets-prepare'
import styles from './main-header.module.scss' import styles from './main-header.module.scss'
...@@ -10,9 +10,9 @@ import styles from './main-header.module.scss' ...@@ -10,9 +10,9 @@ import styles from './main-header.module.scss'
const MainHeader = () => { const MainHeader = () => {
const stageDetail = useStoreState(state => state.gameModel.stageDetail) || {} as StageDetail const stageDetail = useStoreState(state => state.gameModel.stageDetail) || {} as StageDetail
const isKing = useMemo(() => { // 是王者了 const isKing = useMemo(() => { // 王者
return stageDetail.level === 'S' && stageDetail.upGear && stageDetail.gear === 10 return stageDetail.level === StageLevel.S && stageDetail.gear === StageGear.TOP10
}, [stageDetail.level, stageDetail.upGear, stageDetail.gear]) }, [stageDetail.level, stageDetail.gear])
const type = useMemo(() => { const type = useMemo(() => {
switch (stageDetail.type) { switch (stageDetail.type) {
...@@ -35,12 +35,12 @@ const MainHeader = () => { ...@@ -35,12 +35,12 @@ const MainHeader = () => {
}, [stageDetail?.type]) }, [stageDetail?.type])
const topAchieve = useMemo(() => { const topAchieve = useMemo(() => {
switch (stageDetail.gear) { switch (stageDetail.gear?.toString()) {
case 10: case StageGear.TOP10:
return assets['top-10.png'].u return assets['top-10.png'].u
case 20: case StageGear.TOP20:
return assets['top-20.png'].u return assets['top-20.png'].u
case 30: case StageGear.TOP30:
return assets['top-30.png'].u return assets['top-30.png'].u
default: default:
return assets['top-un.png'].u return assets['top-un.png'].u
...@@ -62,17 +62,17 @@ const MainHeader = () => { ...@@ -62,17 +62,17 @@ const MainHeader = () => {
const renderNextStep = useCallback((item: NextStep) => { const renderNextStep = useCallback((item: NextStep) => {
switch (item.nextStep) { switch (item.nextStep) {
case 'S': case StageLevel.S:
return assets['level-big-s.png'].u return assets['level-big-s.png'].u
case 'A': case StageLevel.A:
return assets['level-big-a.png'].u return assets['level-big-a.png'].u
case 'B': case StageLevel.B:
return assets['level-big-b.png'].u return assets['level-big-b.png'].u
case '10': case StageGear.TOP10:
return assets['top-big-10.png'].u return assets['top-big-10.png'].u
case '20': case StageGear.TOP20:
return assets['top-big-20.png'].u return assets['top-big-20.png'].u
case '30': case StageGear.TOP30:
return assets['top-big-30.png'].u return assets['top-big-30.png'].u
case 'upGear': case 'upGear':
return assets['upgear-big.png'].u return assets['upgear-big.png'].u
...@@ -82,7 +82,9 @@ const MainHeader = () => { ...@@ -82,7 +82,9 @@ const MainHeader = () => {
} }
}, []) }, [])
const RequireItem = ({ u, v, t = 0 }: { u: string, v: number, t: number }) => ( const RequireItem = ({ u, v, t = 0 }: { u: string, v: number, t: number }) => {
t = t > 0 ? t : 0 // 有些错题为负数的情况
return (
<View key={u} className={styles.detail}> <View key={u} className={styles.detail}>
<View className={styles.content}> <View className={styles.content}>
<Image className={styles.badge} src={u} mode="widthFix" /> <Image className={styles.badge} src={u} mode="widthFix" />
...@@ -101,6 +103,7 @@ const MainHeader = () => { ...@@ -101,6 +103,7 @@ const MainHeader = () => {
</View> </View>
</View> </View>
) )
}
const renderFirst = useCallback(() => ( const renderFirst = useCallback(() => (
<View className={styles.details}> <View className={styles.details}>
...@@ -131,7 +134,7 @@ const MainHeader = () => { ...@@ -131,7 +134,7 @@ const MainHeader = () => {
<Text className={styles.label}>共 {stageDetail.questionNum} 题</Text> <Text className={styles.label}>共 {stageDetail.questionNum} 题</Text>
</View> </View>
<View className={styles.replay}> {!stageDetail.firstTime && <View className={styles.replay}>
<View className={styles.performance}> <View className={styles.performance}>
<Text>最佳表现</Text> <Text>最佳表现</Text>
<View className={styles.details}> <View className={styles.details}>
...@@ -144,12 +147,12 @@ const MainHeader = () => { ...@@ -144,12 +147,12 @@ const MainHeader = () => {
<View className={styles.details}> <View className={styles.details}>
<Image src={levelAchieve} className={styles.logo} /> <Image src={levelAchieve} className={styles.logo} />
<Image src={topAchieve} className={styles.logo} /> <Image src={topAchieve} className={styles.logo} />
<Image src={stageDetail.upGear ? assets['upgear.png'].u : assets['upgear-un.png'].u} className={styles.logo} /> <Image src={(isKing || stageDetail.upGear) ? assets['upgear.png'].u : assets['upgear-un.png'].u} className={styles.logo} />
</View>
</View> </View>
</View> </View>
</View>}
<View className={styles.requirement}> {!isKing && <View className={styles.requirement}>
<View className={styles.header}> <View className={styles.header}>
<View className={styles.line}></View> <View className={styles.line}></View>
<Text className={styles.text}> <Text className={styles.text}>
...@@ -158,7 +161,7 @@ const MainHeader = () => { ...@@ -158,7 +161,7 @@ const MainHeader = () => {
<View className={styles.line}></View> <View className={styles.line}></View>
</View> </View>
{stageDetail.firstTime ? renderFirst() : isKing ? null : renderAgain()} {stageDetail.firstTime ? renderFirst() : isKing ? null : renderAgain()}
</View> </View>}
</View> </View>
) )
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
position: relative; position: relative;
z-index: 10; z-index: 10;
background-image: url(./assets/head-bg.png); background-image: url(./assets/head-bg.png);
background-size: 100%; background-size: 100% 100%;
background-attachment: fixed; background-attachment: fixed;
} }
...@@ -123,6 +123,7 @@ ...@@ -123,6 +123,7 @@
z-index: 999; z-index: 999;
background-color: #fff; background-color: #fff;
padding: 16PX 0 24PX; padding: 16PX 0 24PX;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
.tribe_share { .tribe_share {
border-radius: 10PX; border-radius: 10PX;
......
import { View, Text, Image } from '@tarojs/components' import { View, Text, Image } from '@tarojs/components'
import { useMemo, useState, useEffect, useCallback } from 'react' import { useMemo, useState, useEffect, useCallback } from 'react'
import { useRouter, redirectTo, useDidShow, getMenuButtonBoundingClientRect, useShareAppMessage, navigateTo, showLoading, hideLoading } from '@tarojs/taro' import { useRouter, redirectTo, getMenuButtonBoundingClientRect, useShareAppMessage, navigateTo, showLoading, hideLoading, useDidShow } from '@tarojs/taro'
import classNames from 'classnames' import classNames from 'classnames'
import Button from '@/components/Button' import Button from '@/components/Button'
...@@ -24,8 +24,8 @@ const Prepare = () => { ...@@ -24,8 +24,8 @@ const Prepare = () => {
const nav = useMemo(getMenuButtonBoundingClientRect, []) const nav = useMemo(getMenuButtonBoundingClientRect, [])
const router = useRouter<{ id: string }>() const router = useRouter<{ id: string }>()
const [currentTab, setCurrentTab] = useState(0) const [currentTab, setCurrentTab] = useState(0)
const [loading, setLoading] = useState(false)
const [isVisible, { setTrue, setFalse }] = useBoolean(false) const [isVisible, { setTrue, setFalse }] = useBoolean(false)
const [isLoad, { toggle: toggleLoad }] = useBoolean(true)
const stageDetail = useStoreState(state => state.gameModel.stageDetail) const stageDetail = useStoreState(state => state.gameModel.stageDetail)
const cardNum = useStoreState(state => state.userModel.cardNum) const cardNum = useStoreState(state => state.userModel.cardNum)
...@@ -63,9 +63,9 @@ const Prepare = () => { ...@@ -63,9 +63,9 @@ const Prepare = () => {
}, [nav.height, nav.top]) }, [nav.height, nav.top])
useDidShow(async () => { useDidShow(async () => {
setLoading(true) toggleLoad()
await getStageDetail(+router.params.id || 1) await getStageDetail(+router.params.id || 1)
setLoading(false) toggleLoad()
}) })
useEffect(() => { useEffect(() => {
...@@ -74,14 +74,10 @@ const Prepare = () => { ...@@ -74,14 +74,10 @@ const Prepare = () => {
} }
}, [cardNum, getSetting]) }, [cardNum, getSetting])
useEffect(() => {
!loading && hideLoading()
}, [loading])
useShareAppMessage(() => { useShareAppMessage(() => {
return { return {
title: '来看看这个有趣的页面!', title: '来看看这个有趣的页面!',
path: `pages/main/main?groupId=${tribeInfo?.id}&inviteId=${userInfo.userId}`, path: `pages/main/main?groupId=${tribeInfo?.id}&shareUserId=${userInfo.userId}`,
imageUrl: 'https://picx.zhimg.com/v2-7b7b072d4bebd5ccf48c04ec1146e844_1440w.jpg?', imageUrl: 'https://picx.zhimg.com/v2-7b7b072d4bebd5ccf48c04ec1146e844_1440w.jpg?',
} }
}) })
...@@ -114,9 +110,9 @@ const Prepare = () => { ...@@ -114,9 +110,9 @@ const Prepare = () => {
<View className={styles.challenge}> <View className={styles.challenge}>
<Button size="large" onClick={handleClick} image={styles.image} hoverImage={styles.hover_image}> <Button size="large" onClick={handleClick} image={styles.image} hoverImage={styles.hover_image}>
<Text className={styles.challenge_text}>开始闯关</Text> <Text className={styles.challenge_text}>开始闯关</Text>
<View className={styles.card} style={{ position: 'absolute', right: 50 }}> <View className={styles.card} style={{ position: 'absolute', right: 60 }}>
<Image className={styles.card_icon} src={require('@/pages/main/assets/ph.png')} /> <Image className={styles.card_icon} src={require('@/pages/main/assets/ph.png')} />
<Text className={styles.card_text}>-1</Text> {!stageDetail?.firstTime && <Text className={styles.card_text}>-1</Text>}
</View> </View>
{stageDetail?.firstTime && <View className={styles.tip}> {stageDetail?.firstTime && <View className={styles.tip}>
<Text className={styles.tip_text}>首次免答题卡</Text> <Text className={styles.tip_text}>首次免答题卡</Text>
...@@ -164,7 +160,11 @@ const Prepare = () => { ...@@ -164,7 +160,11 @@ const Prepare = () => {
</View> </View>
) )
if (loading) { useEffect(() => {
isLoad && hideLoading()
}, [isLoad, hideLoading])
if (!isLoad) {
return showLoading() return showLoading()
} }
...@@ -178,7 +178,7 @@ const Prepare = () => { ...@@ -178,7 +178,7 @@ const Prepare = () => {
</View> </View>
<View className={styles.footer_bar}> <View className={styles.footer_bar}>
{currentTab === 1 && tribeInfo?.id && <ShareView> {currentTab === 1 && tribeInfo && tribeInfo.id && <ShareView>
<View className={styles.tribe_share}> <View className={styles.tribe_share}>
<Image style={{ width: 32, height: 32 }} src={assetsGroup['invite-small.png'].u} /> <Image style={{ width: 32, height: 32 }} src={assetsGroup['invite-small.png'].u} />
<Text style={{ color: '#FF7A18', fontSize: 16 }}>邀请更多好友加入学习部落</Text> <Text style={{ color: '#FF7A18', fontSize: 16 }}>邀请更多好友加入学习部落</Text>
......
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