Commit acc860b3 authored by hewenhao's avatar hewenhao

feat: update

parent a90fc4d7
import { View, Image, Text } from '@tarojs/components'
import assets from '@/assets/oss/assets-complete'
import { useMemo } from 'react'
import { useMemo, useCallback } from 'react'
import { navigateBack } from '@tarojs/taro'
import classNames from 'classnames'
import { useStoreState } from '@/store/hooks'
import { StageLevel } from '@/api'
......@@ -68,11 +69,16 @@ const GameCompleteAchieve = () => {
return Math.ceil(rankNo / 500) * 500
}, [rankNo])
const handleContinue = useCallback(() => {
navigateBack()
}, [])
const renderBtn = () => (
<View className={styles.footer}>
<View
className={styles.btn_continue}
hoverClass={styles.is_active}
onClick={handleContinue}
>
继续
</View>
......@@ -83,7 +89,7 @@ const GameCompleteAchieve = () => {
return null
}
if (gameResult.errNum > 0) {
if (gameResult.errNum > 0 || !gameResult.level) {
return (
<>
<View>没关系,差一点就成功了! 加油!加油!</View>
......
......@@ -47,6 +47,27 @@ let evenIndex = 0
let oddIndex = 0
let specialIndex = 0
export function stageToParts (stageList: Stage[]): Part[] {
evenIndex = 0
oddIndex = 0
specialIndex = 0
const ret: Part[] = []
stageList.forEach(item => {
const last = ret.find(c => c.number === (item.part || 0))
if (last) {
last.stages.push(item)
} else {
ret.push({
number: item.part ?? 0,
stages: [item]
})
}
})
return ret
}
export function groupRoundToSmallPart (list: Stage[]): SmallPart[] {
const ret: SmallPart[] = []
let flag: 'even' | 'odd' = 'even'
......
......@@ -2,34 +2,16 @@ import { View } from '@tarojs/components'
import assets from '@/assets/oss/assets-main'
import { useMemo } from 'react'
import LazeImage from '../lazy-image'
import { Part, Stage } from './constants'
import { stageToParts, type Stage } from './constants'
import ScenePart from './part'
type SceneProps = {
stageList: Stage[];
}
function toPart (stageList: Stage[]): Part[] {
const ret: Part[] = []
stageList.forEach(item => {
const last = ret.find(c => c.number === (item.part || 0))
if (last) {
last.stages.push(item)
} else {
ret.push({
number: item.part ?? 0,
stages: [item]
})
}
})
return ret
}
const Scene = (props: SceneProps) => {
const partList = useMemo(() => {
return toPart(props.stageList)
return stageToParts(props.stageList)
}, [props.stageList])
return (
......
......@@ -18,14 +18,8 @@ const MainPage = () => {
const fetchStage = useStoreActions(actions => actions.mainModel.fetchStage)
const stageList = useStoreState(state => state.mainModel.stageList)
const fetchAccount = useStoreActions(actions => actions.userModel.fetchAccount)
useDidShow(() => {
fetchAccount()
const tabbar = getTabBar<TabbarRef>(page)
tabbar?.setSelected(0)
})
const [nav] = useState(getMenuButtonBoundingClientRect())
const scrollToCurrent = useCallback((callback?: () => void) => {
const height = getSystemInfoSync().windowHeight
pageScrollTo({
......@@ -35,7 +29,10 @@ const MainPage = () => {
})
}, [])
useEffect(() => {
useDidShow(() => {
fetchAccount()
const tabbar = getTabBar<TabbarRef>(page)
tabbar?.setSelected(0)
fetchStage().then(() => {
setTimeout(() => {
scrollToCurrent(() => {
......@@ -43,7 +40,7 @@ const MainPage = () => {
})
}, 1000)
})
}, [scrollToCurrent, fetchStage])
})
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