Commit fa581ec1 authored by m's avatar m

feat: update

parent 4fa13543
...@@ -60,6 +60,11 @@ export type StageRank = { ...@@ -60,6 +60,11 @@ export type StageRank = {
userId: number; userId: number;
} }
export type NextStep = {
nextStep: string;
nextStepReward: number;
nextStepTime: number
}
export interface StageDetail extends Stage { export interface StageDetail extends Stage {
aTime: number; aTime: number;
bTime: number; bTime: number;
...@@ -70,9 +75,7 @@ export interface StageDetail extends Stage { ...@@ -70,9 +75,7 @@ export interface StageDetail extends Stage {
ranks?: StageRank[]; ranks?: StageRank[];
groupRanks?: StageRank[]; groupRanks?: StageRank[];
questionNum: number; questionNum: number;
nextStep: string; nextSteps?: NextStep[];
nextStepReward: number;
nextStepTime: number
} }
/** 获取关卡详情 */ /** 获取关卡详情 */
......
...@@ -80,7 +80,7 @@ const GameCompleteAchieve = () => { ...@@ -80,7 +80,7 @@ const GameCompleteAchieve = () => {
hoverClass={styles.is_active} hoverClass={styles.is_active}
onClick={handleContinue} onClick={handleContinue}
> >
继续 继续22
</View> </View>
</View> </View>
) )
......
...@@ -5,7 +5,7 @@ import { useMemo, useState } from 'react' ...@@ -5,7 +5,7 @@ import { useMemo, useState } from 'react'
import Modal from '@/components/Modal' import Modal from '@/components/Modal'
import Button from '@/components/Button' import Button from '@/components/Button'
import { useBoolean, useRequest } from '@/hooks' import { useBoolean, useRequest } from '@/hooks'
import { createTribe } from '@/api/group' import { createTribe, queryTribePoint } from '@/api/group'
import { useStoreActions, useStoreState } from '@/store/hooks' import { useStoreActions, useStoreState } from '@/store/hooks'
import type { TabbarRef } from '@/custom-tab-bar/index' import type { TabbarRef } from '@/custom-tab-bar/index'
...@@ -28,7 +28,7 @@ const Group = () => { ...@@ -28,7 +28,7 @@ const Group = () => {
const [refresher, { toggle }] = useBoolean(false) const [refresher, { toggle }] = useBoolean(false)
const userInfo = useStoreState(state => state.userModel.userInfo) const userInfo = useStoreState(state => state.userModel.userInfo)
const { tribeInfo } = useStoreState(state => state.groupModel) const tribeInfo = useStoreState(state => state.groupModel.tribeInfo)
const fetchTribeInfo = useStoreActions(actions => actions.groupModel.fetchTribeInfo) const fetchTribeInfo = useStoreActions(actions => actions.groupModel.fetchTribeInfo)
const tabBarHeight = useMemo(() => { const tabBarHeight = useMemo(() => {
...@@ -56,6 +56,10 @@ const Group = () => { ...@@ -56,6 +56,10 @@ const Group = () => {
} }
}) })
const { run: refresh } = useRequest(queryTribePoint, {
immediate: false
})
const onConfirm = () => { const onConfirm = () => {
if (!groupNo) { if (!groupNo) {
showModal({ title: '部落名不能为空' }) showModal({ title: '部落名不能为空' })
...@@ -67,7 +71,7 @@ const Group = () => { ...@@ -67,7 +71,7 @@ const Group = () => {
const onRefresher = async () => { const onRefresher = async () => {
try { try {
toggle() toggle()
await fetchTribeInfo() await Promise.all([fetchTribeInfo(), refresh()])
} finally { } finally {
setTimeout(() => toggle(), 600) setTimeout(() => toggle(), 600)
} }
......
...@@ -57,7 +57,7 @@ const MainPage = () => { ...@@ -57,7 +57,7 @@ const MainPage = () => {
}) })
fetchTribeInfo().then((res) => { fetchTribeInfo().then((res) => {
if (!res.id || !res) { if (!res || !res.id) {
joinTribeByCode() joinTribeByCode()
} }
}) })
...@@ -68,11 +68,15 @@ const MainPage = () => { ...@@ -68,11 +68,15 @@ const MainPage = () => {
immediate: false, immediate: false,
onSuccess: () => { onSuccess: () => {
showToast({ title: '加入成功' }) showToast({ title: '加入成功' })
fetchTribeInfo()
},
onError: () => {
fetchTribeInfo()
} }
}) })
// 邀请弹框 // 邀请弹框
const joinTribeByCode = useCallback(async () => { const joinTribeByCode = useCallback(() => {
if (groupId && inviteId && +inviteId !== userInfo.userId) { // 邀请人是不是自己 if (groupId && inviteId && +inviteId !== userInfo.userId) { // 邀请人是不是自己
showModal({ showModal({
title: '加入部落', title: '加入部落',
......
import { View, Text, Image } from '@tarojs/components' import { View, Text, Image } from '@tarojs/components'
import { useMemo } from 'react' import { useCallback, useMemo } from 'react'
import { useStoreState } from '@/store/hooks' import { useStoreState } from '@/store/hooks'
import { StageType, StageLevel, StageDetail } from '@/api' import { StageType, StageLevel, 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'
...@@ -59,25 +59,27 @@ const MainHeader = () => { ...@@ -59,25 +59,27 @@ const MainHeader = () => {
} }
}, [stageDetail.level]) }, [stageDetail.level])
// const levelRequirement = useMemo(() => { const renderNextStep = useCallback((item: NextStep) => {
// switch (stageDetail.level) { switch (item.nextStep) {
// case StageLevel.S: case 'S':
// return { return assets['level-big-s.png'].u
// v: 10, case 'A':
// u: assets['level-big-s.png'].u return assets['level-big-a.png'].u
// } case 'B':
// case StageLevel.A: return assets['level-big-b.png'].u
// return { case '10':
// v: 5, return assets['top-big-10.png'].u
// u: assets['level-big-a.png'].u case '20':
// } return assets['top-big-20.png'].u
// case StageLevel.B: case '30':
// return { return assets['top-big-30.png'].u
// v: 1, case 'upGear':
// u: assets['level-big-b.png'].u return assets['upgear-big.png'].u
// }
// } default:
// }, [stageDetail.level, stageDetail]) return ''
}
}, [])
const RequireItem = ({ u, v, t = 0 }: { u: string, v: number, t: number }) => ( const RequireItem = ({ u, v, t = 0 }: { u: string, v: number, t: number }) => (
<View key={u} className={styles.detail}> <View key={u} className={styles.detail}>
...@@ -109,9 +111,9 @@ const MainHeader = () => { ...@@ -109,9 +111,9 @@ const MainHeader = () => {
const renderAgain = () => ( const renderAgain = () => (
<View className={styles.details}> <View className={styles.details}>
{/* <RequireItem u={levelRequirement.u} v={levelRequirement.v} t={stageDetail.nextStepTime} /> */} {stageDetail.nextSteps?.map((item) => (
{/* <RequireItem u={stageDetail.upGear ? assets['upgear.png'].u : assets['upgear-un.png'].u} v={5} t={stageDetail.nextStepTime} /> */} <RequireItem u={renderNextStep(item)} v={item.nextStepReward} t={item.nextStepTime} />
{/* <RequireItem u={stageDetail.upGear ? assets['upgear.png'].u : assets['upgear-un.png'].u} v={5} t={stageDetail.nextStepTime} /> */} ))}
</View> </View>
) )
......
import assets from '@/assets/oss/assets-prepare'
export const requirement = {
newcomer: {
title: '通关要求',
clock: assets['clock.png'].u,
text: '用时 ≤49s'
},
strive: {
title: '继续努力,赢更多成就',
clock: assets['clock-up.png'].u,
text: '用时需提高0.3s',
},
}
import { View, Text, Image } from '@tarojs/components' import { View, Text, Image } from '@tarojs/components'
import { useEffect, useMemo, useState } from 'react' import { useMemo, useState } from 'react'
import { useRouter, useDidShow, getMenuButtonBoundingClientRect, useShareAppMessage, navigateTo } from '@tarojs/taro' import { useRouter, redirectTo, useDidShow, getMenuButtonBoundingClientRect, useShareAppMessage, navigateTo } from '@tarojs/taro'
import classNames from 'classnames' import classNames from 'classnames'
import Button from '@/components/Button' import Button from '@/components/Button'
...@@ -9,6 +9,7 @@ import ShareView from '@/pages/group/components/share-view' ...@@ -9,6 +9,7 @@ import ShareView from '@/pages/group/components/share-view'
import { useStoreState, useStoreActions } from '@/store/hooks' import { useStoreState, useStoreActions } from '@/store/hooks'
import { useBoolean, useRequest } from '@/hooks' import { useBoolean, useRequest } from '@/hooks'
import { pointToCard } from '@/api/account' import { pointToCard } from '@/api/account'
import { StageStatus } from '@/api/game'
import assets from '@/assets/oss/assets-prepare' import assets from '@/assets/oss/assets-prepare'
import assetsGroup from '@/assets/oss/assets-group' import assetsGroup from '@/assets/oss/assets-group'
...@@ -30,9 +31,13 @@ const Prepare = () => { ...@@ -30,9 +31,13 @@ const Prepare = () => {
const cardNum = useStoreState(state => state.userModel.cardNum) const cardNum = useStoreState(state => state.userModel.cardNum)
const point = useStoreState(state => state.userModel.point) const point = useStoreState(state => state.userModel.point)
const userInfo = useStoreState(state => state.userModel.userInfo) const userInfo = useStoreState(state => state.userModel.userInfo)
const isSubmit = useStoreState(state => state.gameModel.isSubmit)
const tribeInfo = useStoreState(state => state.groupModel.tribeInfo) const tribeInfo = useStoreState(state => state.groupModel.tribeInfo)
const questionList = useStoreState(state => state.gameModel.questionList)
const stageList = useStoreState(state => state.mainModel.stageList)
const getStageDetail = useStoreActions(actions => actions.gameModel.getStageDetail) const getStageDetail = useStoreActions(actions => actions.gameModel.getStageDetail)
const getQuestionList = useStoreActions(actions => actions.gameModel.getQuestionList) const getQuestionList = useStoreActions(actions => actions.gameModel.getQuestionList)
const updateState = useStoreActions(actions => actions.gameModel.updateState)
const tabs: TabItem[] = [ const tabs: TabItem[] = [
{ {
...@@ -52,6 +57,7 @@ const Prepare = () => { ...@@ -52,6 +57,7 @@ const Prepare = () => {
const { run: exchange, loading } = useRequest(pointToCard, { const { run: exchange, loading } = useRequest(pointToCard, {
immediate: false, immediate: false,
onSuccess: () => { onSuccess: () => {
setFalse()
getQuestionList(+router.params.id || 1).then(() => { getQuestionList(+router.params.id || 1).then(() => {
navigateTo({ navigateTo({
url: `/pages/game/play/index?id=${router.params.id}` url: `/pages/game/play/index?id=${router.params.id}`
...@@ -75,16 +81,16 @@ const Prepare = () => { ...@@ -75,16 +81,16 @@ const Prepare = () => {
return { return {
title: '来看看这个有趣的页面!', title: '来看看这个有趣的页面!',
path: `pages/main/main?groupId=${tribeInfo?.id}&inviteId=${userInfo.userId}`, path: `pages/main/main?groupId=${tribeInfo?.id}&inviteId=${userInfo.userId}`,
imageUrl: 'https://picx.zhimg.com/v2-7b7b072d4bebd5ccf48c04ec1146e844_1440w.jpg?', imageUrl: 'https://picx.zhimg.com/v2-7b7b072d4bebd5ccf48c04ec1146e844_1440w.jpg?',
} }
}) })
const handleClick = () => { const handleClick = () => {
if (cardNum < 1) { if (cardNum < 1 && !stageDetail?.firstTime) {
setTrue() setTrue()
} else { } else {
getQuestionList(+router.params.id || 1).then(() => { getQuestionList(+router.params.id || 1).then(() => {
console.log('questionList', questionList)
navigateTo({ navigateTo({
url: `/pages/game/play/index?id=${router.params.id}` url: `/pages/game/play/index?id=${router.params.id}`
}) })
...@@ -92,9 +98,42 @@ const Prepare = () => { ...@@ -92,9 +98,42 @@ const Prepare = () => {
} }
} }
// const renderFisrtButton = () => ( const onNext = () => {
const index = stageList.findIndex(item => item.id === stageDetail?.id)
const nextId = stageList[index + 1].id
if (nextId) {
navigateTo({ url: `/pages/prepare/index?id=${nextId}` })
updateState({ isSubmit: false })
}
}
const renderFisrtActions = () => (
<Button size="large" onClick={handleClick} className={styles.challenge} image={styles.image} hoverImage={styles.hover_image}>
<Text className={styles.challenge_text}>开始闯关</Text>
<View className={styles.card} style={{ position: 'absolute', right: 50 }}>
<Image className={styles.card_icon} src={require('@/pages/main/assets/ph.png')} />
<Text className={styles.card_text}>-1</Text>
</View>
{stageDetail?.firstTime && <View className={styles.tip}>
<Text className={styles.tip_text}>首次免答题卡</Text>
</View>}
</Button>
)
// ) const renderAgainActions = () => (
<View className={styles.challenge}>
<Button onClick={onNext} size="large" image={styles.short_image} hoverImage={styles.short_hover_image}>
下一关
</Button>
<Button size="large" onClick={handleClick} image={styles.long_image} hoverImage={styles.long_hover_image}>
<View className={styles.card}>
<Image className={styles.card_icon} src={require('@/pages/main/assets/ph.png')} />
<Text className={styles.card_text}>-1</Text>
</View>
<Text className={styles.challenge_text}>再次提升</Text>
</Button>
</View>
)
return ( return (
<View className={styles.wrapper}> <View className={styles.wrapper}>
...@@ -105,36 +144,14 @@ const Prepare = () => { ...@@ -105,36 +144,14 @@ const Prepare = () => {
</View> </View>
<View className={styles.footer_bar}> <View className={styles.footer_bar}>
{currentTab === 1 && <ShareView> {currentTab === 1 && 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>
</View> </View>
</ShareView>} </ShareView>}
<Button size="large" onClick={handleClick} className={styles.challenge} image={styles.image} hoverImage={styles.hover_image}> {isSubmit ? renderFisrtActions() : renderAgainActions()}
<Text className={styles.challenge_text}>开始闯关</Text>
<View className={styles.card} style={{ position: 'absolute', right: 50 }}>
<Image className={styles.card_icon} src={require('@/pages/main/assets/ph.png')} />
<Text className={styles.card_text}>-1</Text>
</View>
{stageDetail?.firstTime && <View className={styles.tip}>
<Text className={styles.tip_text}>首次免答题卡</Text>
</View>}
</Button>
{/* <View className={styles.challenge}>
<Button size="large" image={styles.short_image} hoverImage={styles.short_hover_image}>
下一关
</Button>
<Button size="large" onClick={handleClick} image={styles.long_image} hoverImage={styles.long_hover_image}>
<View className={styles.card}>
<Image className={styles.card_icon} src={require('@/pages/main/assets/ph.png')} />
<Text className={styles.card_text}>-1</Text>
</View>
<Text className={styles.challenge_text}>再次提升</Text>
</Button>
</View> */}
</View> </View>
<AnswerCardModal isVisible={isVisible} onClose={setFalse}> <AnswerCardModal isVisible={isVisible} onClose={setFalse}>
......
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