Commit c7fd9ab4 authored by hewenhao's avatar hewenhao

feat: PKMath地心历险记

parent 3f91d0e4
{
"page-head-1.png": {
"u": "https://cdn.jkwljy.com/pk-math/2VfAqjESCKKmT1mZxmqjZ3fxL6LY/750x400",
"w": 750,
"h": 400,
"ossName": "/pk-math/2VfAqjESCKKmT1mZxmqjZ3fxL6LY/750x400"
},
"page-head-2.png": {
"u": "https://cdn.jkwljy.com/pk-math/43B2EAqbLXacaaPaweyHLeXRphAz/750x180",
"w": 750,
"h": 180,
"ossName": "/pk-math/43B2EAqbLXacaaPaweyHLeXRphAz/750x180"
},
"part-first.png": {
"u": "https://cdn.jkwljy.com/pk-math/34v9Dzno2ivB8jTJQghasypCRaS8/750x256",
"w": 750,
"h": 256,
"ossName": "/pk-math/34v9Dzno2ivB8jTJQghasypCRaS8/750x256"
},
"part-tail-1.png": {
"u": "https://cdn.jkwljy.com/pk-math/2FrE7PUscbSQXDBsJ1dEtwZUtLy1/750x256",
"w": 750,
"h": 256,
"ossName": "/pk-math/2FrE7PUscbSQXDBsJ1dEtwZUtLy1/750x256"
},
"part-tail-2.png": {
"u": "https://cdn.jkwljy.com/pk-math/3Mh1PCLrStZSLGaJg3f4a8LCqohD/750x256",
"w": 750,
"h": 256,
"ossName": "/pk-math/3Mh1PCLrStZSLGaJg3f4a8LCqohD/750x256"
},
"part-tail-3.png": {
"u": "https://cdn.jkwljy.com/pk-math/3QTkiAL1roWRhVMy48Q1eXFQvLei/750x256",
"w": 750,
"h": 256,
"ossName": "/pk-math/3QTkiAL1roWRhVMy48Q1eXFQvLei/750x256"
},
"part-tail-4.png": {
"u": "https://cdn.jkwljy.com/pk-math/4Y44FALbzo3siPYkonrZio3Pw8yu/750x256",
"w": 750,
"h": 256,
"ossName": "/pk-math/4Y44FALbzo3siPYkonrZio3Pw8yu/750x256"
},
"part-tail-5.png": {
"u": "https://cdn.jkwljy.com/pk-math/3MpVwq45BR5zV7bQseirLRdmBAZY/750x256",
"w": 750,
"h": 256,
"ossName": "/pk-math/3MpVwq45BR5zV7bQseirLRdmBAZY/750x256"
},
"part-tail-6.png": {
"u": "https://cdn.jkwljy.com/pk-math/3d3TbcPxXvxE3yn22sLs89LoUvRs/750x256",
"w": 750,
"h": 256,
"ossName": "/pk-math/3d3TbcPxXvxE3yn22sLs89LoUvRs/750x256"
},
"part-tail-7.png": {
"u": "https://cdn.jkwljy.com/pk-math/2GP5uTYHWimNSrTePieYx5DCPfPm/750x256",
"w": 750,
"h": 256,
"ossName": "/pk-math/2GP5uTYHWimNSrTePieYx5DCPfPm/750x256"
},
"part-tail-8.png": {
"u": "https://cdn.jkwljy.com/pk-math/GANoReKeAMhCWtSV2cLyfwAw6eR/750x256",
"w": 750,
"h": 256,
"ossName": "/pk-math/GANoReKeAMhCWtSV2cLyfwAw6eR/750x256"
},
"part-tail-9.png": {
"u": "https://cdn.jkwljy.com/pk-math/21G4Na7wFqbnr7V1CRPowvcArdk3/750x256",
"w": 750,
"h": 256,
"ossName": "/pk-math/21G4Na7wFqbnr7V1CRPowvcArdk3/750x256"
},
"stone-1.png": {
"u": "https://cdn.jkwljy.com/pk-math/FHY4pCXiH8wnrfPBYo7Qbt412MH/640x472",
"w": 640,
"h": 472,
"ossName": "/pk-math/FHY4pCXiH8wnrfPBYo7Qbt412MH/640x472"
},
"stone-2.png": {
"u": "https://cdn.jkwljy.com/pk-math/4MHzuWwpRQxyoJeVT7HHdC2VeV1f/540x440",
"w": 540,
"h": 440,
"ossName": "/pk-math/4MHzuWwpRQxyoJeVT7HHdC2VeV1f/540x440"
},
"part-center.png": {
"u": "https://cdn.jkwljy.com/pk-math/PRyWBXdaLmdgQobGf5rHgbXu6c7/750x336",
"w": 750,
"h": 336,
"ossName": "/pk-math/PRyWBXdaLmdgQobGf5rHgbXu6c7/750x336"
},
"part-bg.png": {
"u": "https://cdn.jkwljy.com/pk-math/uNKs9Mv9QquQbr8ox8Hjn1JAR7n/180x148",
"w": 180,
"h": 148,
"ossName": "/pk-math/uNKs9Mv9QquQbr8ox8Hjn1JAR7n/180x148"
},
"star.png": {
"u": "https://cdn.jkwljy.com/pk-math/2pDWfc9HCgR5mtQCRZ98xZ8nPNT7/64x64",
"w": 64,
"h": 64,
"ossName": "/pk-math/2pDWfc9HCgR5mtQCRZ98xZ8nPNT7/64x64"
},
"pk-btn.png": {
"u": "https://cdn.jkwljy.com/pk-math/3CmWqH2LVXPMeFfxDNZZHfHzfQG5/132x132",
"w": 132,
"h": 132,
"ossName": "/pk-math/3CmWqH2LVXPMeFfxDNZZHfHzfQG5/132x132"
},
"short-cut-arrow.png": {
"u": "https://cdn.jkwljy.com/pk-math/4WTwRcxT8H37hW1y5JwsztMDGj2d/60x60",
"w": 60,
"h": 60,
"ossName": "/pk-math/4WTwRcxT8H37hW1y5JwsztMDGj2d/60x60"
},
"short-cut-bg.png": {
"u": "https://cdn.jkwljy.com/pk-math/3NiaMjtuvnppeLtzizUhqeGPmX5T/108x108",
"w": 108,
"h": 108,
"ossName": "/pk-math/3NiaMjtuvnppeLtzizUhqeGPmX5T/108x108"
}
}
{
"enhance-clear-base.png": {
"u": "https://cdn.jkwljy.com/pk-math/31RfcpnSwcJGGUxYHi49NFDLUEF9/168x168",
"w": 168,
"h": 168,
"ossName": "/pk-math/31RfcpnSwcJGGUxYHi49NFDLUEF9/168x168"
},
"enhance-current-base.png": {
"u": "https://cdn.jkwljy.com/pk-math/3DFrNbU6V3N37n5p9GM4jF3SoUf4/168x168",
"w": 168,
"h": 168,
"ossName": "/pk-math/3DFrNbU6V3N37n5p9GM4jF3SoUf4/168x168"
},
"enhance-unlock.png": {
"u": "https://cdn.jkwljy.com/pk-math/4WToD7w6ifDbG3q1EqdRk6tUGirU/168x168",
"w": 168,
"h": 168,
"ossName": "/pk-math/4WToD7w6ifDbG3q1EqdRk6tUGirU/168x168"
},
"one-stop-clear-base.png": {
"u": "https://cdn.jkwljy.com/pk-math/3dnUBa46T7c8goyVij1MNh5LC45e/176x168",
"w": 176,
"h": 168,
"ossName": "/pk-math/3dnUBa46T7c8goyVij1MNh5LC45e/176x168"
},
"one-stop-current.png": {
"u": "https://cdn.jkwljy.com/pk-math/3yjtAWY3JyWaX1DUsVo2uv62tnjV/176x168",
"w": 176,
"h": 168,
"ossName": "/pk-math/3yjtAWY3JyWaX1DUsVo2uv62tnjV/176x168"
},
"one-stop-unlock.png": {
"u": "https://cdn.jkwljy.com/pk-math/4VGmrroZZ4RWerU26QX3xWXieCFs/176x168",
"w": 176,
"h": 168,
"ossName": "/pk-math/4VGmrroZZ4RWerU26QX3xWXieCFs/176x168"
},
"strong-clear-base.png": {
"u": "https://cdn.jkwljy.com/pk-math/3UxXgz646nHvwZbD3LDogLTPmjos/168x168",
"w": 168,
"h": 168,
"ossName": "/pk-math/3UxXgz646nHvwZbD3LDogLTPmjos/168x168"
},
"strong-current-base.png": {
"u": "https://cdn.jkwljy.com/pk-math/vftDoRdcNoX1S2mqTPs5cryz4R7/168x168",
"w": 168,
"h": 168,
"ossName": "/pk-math/vftDoRdcNoX1S2mqTPs5cryz4R7/168x168"
},
"strong-unlock.png": {
"u": "https://cdn.jkwljy.com/pk-math/uA5PvFMNpK4p3NgFbh7UrnAs1tz/168x168",
"w": 168,
"h": 168,
"ossName": "/pk-math/uA5PvFMNpK4p3NgFbh7UrnAs1tz/168x168"
},
"star-off.png": {
"u": "https://cdn.jkwljy.com/pk-math/2G5ZMXmbDUBEXzm46j48w6A4MsXi/32x32",
"w": 32,
"h": 32,
"ossName": "/pk-math/2G5ZMXmbDUBEXzm46j48w6A4MsXi/32x32"
},
"star-on.png": {
"u": "https://cdn.jkwljy.com/pk-math/2Fg3M5psawF5gKeFX8W78MhTwFzH/32x32",
"w": 32,
"h": 32,
"ossName": "/pk-math/2Fg3M5psawF5gKeFX8W78MhTwFzH/32x32"
},
"special-clear-base.png": {
"u": "https://cdn.jkwljy.com/pk-math/4LiAZH9L6ZrriKBX8q8j4EC6mgz6/192x192",
"w": 192,
"h": 192,
"ossName": "/pk-math/4LiAZH9L6ZrriKBX8q8j4EC6mgz6/192x192"
},
"special-current-base.png": {
"u": "https://cdn.jkwljy.com/pk-math/PcsyzXaHKj8o8KjRuMCNcGXdycL/192x192",
"w": 192,
"h": 192,
"ossName": "/pk-math/PcsyzXaHKj8o8KjRuMCNcGXdycL/192x192"
},
"special-unlock.png": {
"u": "https://cdn.jkwljy.com/pk-math/3xyyMEcMZYBF9ZBWbBPUd7o1ZCf8/192x192",
"w": 192,
"h": 192,
"ossName": "/pk-math/3xyyMEcMZYBF9ZBWbBPUd7o1ZCf8/192x192"
},
"pk-bg.png": {
"u": "https://cdn.jkwljy.com/pk-math/83TAXgfP8i5CfqZruPEzoY9Nse9/104x48",
"w": 104,
"h": 48,
"ossName": "/pk-math/83TAXgfP8i5CfqZruPEzoY9Nse9/104x48"
}
}
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
"miniprogramRoot": "dist/", "miniprogramRoot": "dist/",
"projectname": "GeekLearnMathWeapp", "projectname": "GeekLearnMathWeapp",
"description": "", "description": "",
"appid": "wx8f25def587982a19", "appid": "wx693fe3460124d84b",
"setting": { "setting": {
"urlCheck": false, "urlCheck": false,
"es6": false, "es6": false,
"enhance": false, "enhance": false,
"compileHotReLoad": false, "compileHotReLoad": false,
"bigPackageSizeSupport": true,
"postcss": false, "postcss": false,
"minified": false, "minified": false,
"babelSetting": { "babelSetting": {
......
{ {
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"setting": { "setting": {
"compileHotReLoad": true "compileHotReLoad": true,
"bigPackageSizeSupport": true
}, },
"projectname": "GeekLearnMathWeapp" "projectname": "GeekLearnMathWeapp"
} }
...@@ -28,6 +28,7 @@ export const enum StageType { ...@@ -28,6 +28,7 @@ export const enum StageType {
Strong = '强化', Strong = '强化',
Enhance = '练习', Enhance = '练习',
OneStop = '一战到底', OneStop = '一战到底',
Special = '奖励关卡'
} }
export const enum StageGear { export const enum StageGear {
...@@ -43,6 +44,8 @@ export const enum StageLevel { ...@@ -43,6 +44,8 @@ export const enum StageLevel {
} }
export interface Stage { export interface Stage {
isHead?: boolean;
index: number;
content: string; content: string;
gear: number; gear: number;
id: number; id: number;
......
/* eslint-disable quotes */
/* eslint-disable quote-props */
export default {
"page-head-1.png": {
"u": "https://cdn.jkwljy.com/pk-math/2VfAqjESCKKmT1mZxmqjZ3fxL6LY/750x400",
"w": 750,
"h": 400
},
"page-head-2.png": {
"u": "https://cdn.jkwljy.com/pk-math/43B2EAqbLXacaaPaweyHLeXRphAz/750x180",
"w": 750,
"h": 180
},
"part-first.png": {
"u": "https://cdn.jkwljy.com/pk-math/34v9Dzno2ivB8jTJQghasypCRaS8/750x256",
"w": 750,
"h": 256
},
"part-tail-1.png": {
"u": "https://cdn.jkwljy.com/pk-math/2FrE7PUscbSQXDBsJ1dEtwZUtLy1/750x256",
"w": 750,
"h": 256
},
"part-tail-2.png": {
"u": "https://cdn.jkwljy.com/pk-math/3Mh1PCLrStZSLGaJg3f4a8LCqohD/750x256",
"w": 750,
"h": 256
},
"part-tail-3.png": {
"u": "https://cdn.jkwljy.com/pk-math/3QTkiAL1roWRhVMy48Q1eXFQvLei/750x256",
"w": 750,
"h": 256
},
"part-tail-4.png": {
"u": "https://cdn.jkwljy.com/pk-math/4Y44FALbzo3siPYkonrZio3Pw8yu/750x256",
"w": 750,
"h": 256
},
"part-tail-5.png": {
"u": "https://cdn.jkwljy.com/pk-math/3MpVwq45BR5zV7bQseirLRdmBAZY/750x256",
"w": 750,
"h": 256
},
"part-tail-6.png": {
"u": "https://cdn.jkwljy.com/pk-math/3d3TbcPxXvxE3yn22sLs89LoUvRs/750x256",
"w": 750,
"h": 256
},
"part-tail-7.png": {
"u": "https://cdn.jkwljy.com/pk-math/2GP5uTYHWimNSrTePieYx5DCPfPm/750x256",
"w": 750,
"h": 256
},
"part-tail-8.png": {
"u": "https://cdn.jkwljy.com/pk-math/GANoReKeAMhCWtSV2cLyfwAw6eR/750x256",
"w": 750,
"h": 256
},
"part-tail-9.png": {
"u": "https://cdn.jkwljy.com/pk-math/21G4Na7wFqbnr7V1CRPowvcArdk3/750x256",
"w": 750,
"h": 256
},
"stone-1.png": {
"u": "https://cdn.jkwljy.com/pk-math/FHY4pCXiH8wnrfPBYo7Qbt412MH/640x472",
"w": 640,
"h": 472
},
"stone-2.png": {
"u": "https://cdn.jkwljy.com/pk-math/4MHzuWwpRQxyoJeVT7HHdC2VeV1f/540x440",
"w": 540,
"h": 440
},
"part-center.png": {
"u": "https://cdn.jkwljy.com/pk-math/PRyWBXdaLmdgQobGf5rHgbXu6c7/750x336",
"w": 750,
"h": 336
},
"part-bg.png": {
"u": "https://cdn.jkwljy.com/pk-math/uNKs9Mv9QquQbr8ox8Hjn1JAR7n/180x148",
"w": 180,
"h": 148
},
"star.png": {
"u": "https://cdn.jkwljy.com/pk-math/2pDWfc9HCgR5mtQCRZ98xZ8nPNT7/64x64",
"w": 64,
"h": 64
},
"pk-btn.png": {
"u": "https://cdn.jkwljy.com/pk-math/3CmWqH2LVXPMeFfxDNZZHfHzfQG5/132x132",
"w": 132,
"h": 132
},
"short-cut-arrow.png": {
"u": "https://cdn.jkwljy.com/pk-math/4WTwRcxT8H37hW1y5JwsztMDGj2d/60x60",
"w": 60,
"h": 60
},
"short-cut-bg.png": {
"u": "https://cdn.jkwljy.com/pk-math/3NiaMjtuvnppeLtzizUhqeGPmX5T/108x108",
"w": 108,
"h": 108
}
} as const
/* eslint-disable quotes */
/* eslint-disable quote-props */
export default {
"enhance-clear-base.png": {
"u": "https://cdn.jkwljy.com/pk-math/31RfcpnSwcJGGUxYHi49NFDLUEF9/168x168",
"w": 168,
"h": 168
},
"enhance-current-base.png": {
"u": "https://cdn.jkwljy.com/pk-math/3DFrNbU6V3N37n5p9GM4jF3SoUf4/168x168",
"w": 168,
"h": 168
},
"enhance-unlock.png": {
"u": "https://cdn.jkwljy.com/pk-math/4WToD7w6ifDbG3q1EqdRk6tUGirU/168x168",
"w": 168,
"h": 168
},
"one-stop-clear-base.png": {
"u": "https://cdn.jkwljy.com/pk-math/3dnUBa46T7c8goyVij1MNh5LC45e/176x168",
"w": 176,
"h": 168
},
"one-stop-current.png": {
"u": "https://cdn.jkwljy.com/pk-math/3yjtAWY3JyWaX1DUsVo2uv62tnjV/176x168",
"w": 176,
"h": 168
},
"one-stop-unlock.png": {
"u": "https://cdn.jkwljy.com/pk-math/4VGmrroZZ4RWerU26QX3xWXieCFs/176x168",
"w": 176,
"h": 168
},
"strong-clear-base.png": {
"u": "https://cdn.jkwljy.com/pk-math/3UxXgz646nHvwZbD3LDogLTPmjos/168x168",
"w": 168,
"h": 168
},
"strong-current-base.png": {
"u": "https://cdn.jkwljy.com/pk-math/vftDoRdcNoX1S2mqTPs5cryz4R7/168x168",
"w": 168,
"h": 168
},
"strong-unlock.png": {
"u": "https://cdn.jkwljy.com/pk-math/uA5PvFMNpK4p3NgFbh7UrnAs1tz/168x168",
"w": 168,
"h": 168
},
"star-off.png": {
"u": "https://cdn.jkwljy.com/pk-math/2G5ZMXmbDUBEXzm46j48w6A4MsXi/32x32",
"w": 32,
"h": 32
},
"star-on.png": {
"u": "https://cdn.jkwljy.com/pk-math/2Fg3M5psawF5gKeFX8W78MhTwFzH/32x32",
"w": 32,
"h": 32
},
"special-clear-base.png": {
"u": "https://cdn.jkwljy.com/pk-math/4LiAZH9L6ZrriKBX8q8j4EC6mgz6/192x192",
"w": 192,
"h": 192
},
"special-current-base.png": {
"u": "https://cdn.jkwljy.com/pk-math/PcsyzXaHKj8o8KjRuMCNcGXdycL/192x192",
"w": 192,
"h": 192
},
"special-unlock.png": {
"u": "https://cdn.jkwljy.com/pk-math/3xyyMEcMZYBF9ZBWbBPUd7o1ZCf8/192x192",
"w": 192,
"h": 192
},
"pk-bg.png": {
"u": "https://cdn.jkwljy.com/pk-math/83TAXgfP8i5CfqZruPEzoY9Nse9/104x48",
"w": 104,
"h": 48
}
} as const
import { View, Image } from '@tarojs/components' import { View, Image } from '@tarojs/components'
import assets from '@/assets/oss/assets-main' import assets from '@/assets/oss/assets-main'
import assetsMainNext from '@/assets/oss/assets-main-next'
import { useEffect, useState, useRef } from 'react' import { useEffect, useState, useRef } from 'react'
import { usePageScroll, createIntersectionObserver } from '@tarojs/taro' import { usePageScroll, createIntersectionObserver } from '@tarojs/taro'
import classNames from 'classnames' import classNames from 'classnames'
...@@ -10,7 +11,15 @@ import { CurrentRoundId, StageStatus } from './scene/constants' ...@@ -10,7 +11,15 @@ import { CurrentRoundId, StageStatus } from './scene/constants'
import styles from './short-cut.module.scss' import styles from './short-cut.module.scss'
type ShortCutProps = { type ShortCutProps = {
onClick: () => void onClick: () => void;
isNext?: boolean;
}
const getIcon = (isNext?: boolean) => {
if (isNext) {
return assetsMainNext
}
return assets
} }
const ShortCut = (props: ShortCutProps) => { const ShortCut = (props: ShortCutProps) => {
...@@ -18,6 +27,7 @@ const ShortCut = (props: ShortCutProps) => { ...@@ -18,6 +27,7 @@ const ShortCut = (props: ShortCutProps) => {
const [isDown, setIsDown] = useState(false) const [isDown, setIsDown] = useState(false)
const scrollRef = useRef(0) const scrollRef = useRef(0)
const stageList = useStoreState(state => state.mainModel.stageList) const stageList = useStoreState(state => state.mainModel.stageList)
const { isNext } = props
usePageScroll((payload) => { usePageScroll((payload) => {
scrollRef.current = payload.scrollTop scrollRef.current = payload.scrollTop
...@@ -50,8 +60,8 @@ const ShortCut = (props: ShortCutProps) => { ...@@ -50,8 +60,8 @@ const ShortCut = (props: ShortCutProps) => {
return ( return (
<EyeProtectionView className={styles.shortcut}> <EyeProtectionView className={styles.shortcut}>
<View className={classNames(styles.shortcutInner, isHide && styles.is_hide)} onClick={props.onClick} id="main_shortcut"> <View className={classNames(styles.shortcutInner, isHide && styles.is_hide)} onClick={props.onClick} id="main_shortcut">
<Image src={assets['short-cut-bg.png'].u} className={styles.bg}></Image> <Image src={getIcon(isNext)['short-cut-bg.png'].u} className={styles.bg}></Image>
<Image src={assets['short-cut-arrow.png'].u} className={classNames(styles.arrow, ((!isHide && isDown) || (isHide && !isDown)) && styles.isDown)}></Image> <Image src={getIcon(isNext)['short-cut-arrow.png'].u} className={classNames(styles.arrow, ((!isHide && isDown) || (isHide && !isDown)) && styles.isDown)}></Image>
</View> </View>
</EyeProtectionView> </EyeProtectionView>
) )
......
...@@ -103,7 +103,7 @@ const Tutorial = () => { ...@@ -103,7 +103,7 @@ const Tutorial = () => {
loadData() loadData()
preloadGuideImages() preloadGuideImages()
} }
if (isLoadRef.current) { if (isLoadRef.current || stageList.length < 1) {
return return
} }
isLoadRef.current = true isLoadRef.current = true
......
.chapter {
padding: 24px 32px 24px 32px;
background-color: #1786f7;
color: #FFFFFF;
display: flex;
align-items: center;
box-sizing: border-box;
z-index: 20;
position: relative;
height: 180px;
.bg {
position: absolute;
width: 100%;
top: 0;
left: 0;
right: 0;
z-index: 1;
}
}
.pk {
position: absolute;
bottom: -132px;
right: 16px;
z-index: 3000;
.dot {
position: absolute;
left: 22px;
top: 10px;
width: 20px;
height: 20px;
border-radius: 10px;
background-color: #FF5E5E;
border: 2px solid #FFFFFF;
box-sizing: border-box;
}
.pkIcon {
width: 132px;
height: 132px;
display: block;
}
}
.bgTopWrap {
position: relative;
.bgTop {
position: absolute;
left: 0;
bottom: 0;
right: 0;
width: 100%;
}
}
.chapterContent {
flex: 1;
min-width: 0;
position: relative;
z-index: 2;
display: flex;
align-items: center;
justify-content: center;
}
.chapterName {
height: 80px;
font-size: 40px;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #FFFFFF;
display: flex;
align-items: center;
justify-content: center;
padding: 0 24px;
background: rgba(0,0,0,0.53);
border-radius: 40px;
}
.chapterTips {
font-size: 36px;
font-weight: 400;
color: #FFFFFF;
line-height: 50px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-top: 8px;
}
.help {
width: 96px;
height: 96px;
background-image: url(../assets/help-bg.png);
background-size: 100% 100%;
display: flex;
align-items: center;
justify-content: center;
transition: transform .3s ease-in-out;
will-change: transform;
margin-left: 60px;
&.is-hover-btn {
transform: scale(.95);
}
.icon {
width: 60px;
height: 60px;
}
}
import { View, Text, Image } from '@tarojs/components'
import assetsMainNext from '@/assets/oss/assets-main-next'
import styles from './chapter.module.scss'
const MainHeader = () => {
return (
<>
<View className={styles.bgTopWrap}>
<Image src={assetsMainNext['page-head-1.png'].u} className={styles.bgTop} mode="widthFix"></Image>
</View>
<View className={styles.chapter}>
<Image src={assetsMainNext['page-head-2.png'].u} mode="widthFix" className={styles.bg}></Image>
<View className={styles.chapterContent}>
<View className={styles.chapterName}>
地心历险记
</View>
</View>
<View className={styles.pk}>
<View className={styles.dot}></View>
<Image src={assetsMainNext['pk-btn.png'].u} className={styles.pkIcon}></Image>
</View>
</View>
</>
)
}
export default MainHeader
.header {
position: fixed;
left: 0;
top: 0;
right: 0;
z-index: 2000;
}
.headerContent {
position: relative;
z-index: 2;
}
.bg {
position: absolute;
left: 0;
bottom: 0;
right: 0;
width: 100%;
}
.inner {
display: flex;
align-items: center;
font-size: 16PX;
font-weight: 500;
color: #FFFFFF;
line-height: 19PX;
}
.avatar {
margin-right: 12PX;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
.name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 14PX;
font-weight: 500;
margin-left: 12PX;
color: #FFFFFF;
}
}
.score {
display: flex;
align-items: center;
margin-right: 12PX;
.icon {
width: 32PX;
height: 32PX;
margin-right: 4PX;
}
}
.ph {
display: flex;
align-items: center;
.icon {
width: 32PX;
height: 32PX;
margin-right: 4PX;
}
}
import { View, Text, Image } from '@tarojs/components'
import { getMenuButtonBoundingClientRect, getSystemInfoSync, navigateTo } from '@tarojs/taro'
import { useMemo } from 'react'
import classNames from 'classnames'
import { EyeProtectionView } from '@/components'
import { useStoreState } from '@/store/hooks'
import { cs } from '@/styles'
import assets from '@/assets/oss/assets-main-next'
import MainChapter from './chapter'
import styles from './header.module.scss'
const goStore = () => {
navigateTo({
url: '/pages/market/index'
})
}
const MainHeader = () => {
const nav = useMemo(getMenuButtonBoundingClientRect, [])
const sys = useMemo(getSystemInfoSync, [])
const innerStyle = useMemo(() => {
return {
height: `${nav.height + 10}px`,
paddingRight: `${nav.width + (sys.windowWidth - nav.right) * 2}px`
}
}, [sys, nav])
const cardNum = useStoreState(state => state.userModel.cardNum)
const point = useStoreState(state => state.userModel.point)
const userInfo = useStoreState(state => state.userModel.userInfo)
return (
<EyeProtectionView className={styles.header}>
<Image src={assets['page-head-1.png'].u} className={styles.bg} mode="widthFix"></Image>
<View
className={styles.headerContent}
style={{
height: `${nav.height + 10}px`,
paddingTop: `${nav.top - 5}px`
}}
>
<View className={styles.inner} style={innerStyle}>
<View className={styles.avatar}>
<Text className={styles.name}>{userInfo?.nickName ?? ''}</Text>
</View>
<View className={classNames(styles.score, cs.bounce_btn)} onClick={goStore} hoverClass={cs.bounce_btn_hover} id="main_header_score">
<Image src={require('../assets/score.png')} className={styles.icon} />
<Text>{point}</Text>
</View>
<View className={classNames(styles.ph, cs.bounce_btn)} onClick={goStore} hoverClass={cs.bounce_btn_hover} id="main_header_ph">
<Image src={assets['star.png'].u} className={styles.icon} />
<Text>{cardNum}</Text>
</View>
</View>
</View>
<MainChapter />
</EyeProtectionView>
)
}
export default MainHeader
.body {
position: relative;
z-index: 1;
padding-bottom: 56PX;
background-color: #F3B751;
}
.chapterGap {
height: 180px;
}
@supports (height: constant(safe-area-inset-bottom)) or (height: env(safe-area-inset-bottom)) {
.gap {
height: constant(safe-area-inset-bottom);
height : env(safe-area-inset-bottom);
}
}
import { View } from '@tarojs/components'
import {
getMenuButtonBoundingClientRect,
getCurrentInstance, getTabBar, pageScrollTo, getSystemInfoSync,
nextTick,
onAppHide,
} from '@tarojs/taro'
import { useMemo, useCallback, useEffect } from 'react'
import { useStoreActions, useStoreState } from '@/store/hooks'
import { useFocus } from '@/hooks/use-focus'
import { EyeProtectionView } from '@/components'
import Tutorial from '../components/tutorial'
import type { TabbarRef } from '../../../custom-tab-bar/index'
import { CurrentRoundId, StageStatus } from '../components/scene/constants'
import MainHeader from './header'
import MainScene from './scene'
import MainShortCut from '../components/short-cut'
import ShareModal from '../components/share-modal'
import styles from './main-component.module.scss'
const MainPage = () => {
const page = useMemo(() => getCurrentInstance().page, [])
const updateReady = useStoreActions(actions => actions.mainModel.updateReady)
const fetchStage = useStoreActions(actions => actions.mainModel.fetchStage)
const stageList = useStoreState(state => state.mainModel.stageList)
const player = useStoreState(state => state.mainModel.player)
const isReady = useStoreState(state => state.mainModel.isReady)
const isGroupGuideComplete = useStoreState(state => state.guideModel.isGroupGuideComplete)
const isMainGuideComplete = useStoreState(state => state.guideModel.isMainGuideComplete)
const fetchAccount = useStoreActions(actions => actions.userModel.fetchAccount)
const updateGroupGuideActive = useStoreActions(actions => actions.guideModel.updateGroupGuideActive)
const fetchTribeInfo = useStoreActions(actions => actions.groupModel.fetchTribeInfo)
const userInfo = useStoreState(state => state.userModel.userInfo)
const nav = useMemo(getMenuButtonBoundingClientRect, [])
const scrollToCurrent = useCallback((callback?: () => void) => {
const height = getSystemInfoSync().windowHeight
pageScrollTo({
selector: `#${CurrentRoundId}`,
offsetTop: -height / 2,
complete: callback
})
}, [])
const isFocus = useFocus()
// 激活部落引导
useEffect(() => {
const fn = async () => {
if (
!isFocus ||
isGroupGuideComplete ||
userInfo.pointReceive === 'N' ||
!userInfo.city ||
!userInfo.grade ||
stageList.length < 1
) {
return
}
const currentIndex = stageList.findIndex(c => c.status === StageStatus.CURRENT)
const point = await fetchAccount()
if (point < 50 || currentIndex >= 3) {
const res = await fetchTribeInfo()
if (!res?.id) {
updateGroupGuideActive(true)
}
}
}
fn()
}, [fetchAccount, isGroupGuideComplete, stageList, updateGroupGuideActive, userInfo, fetchTribeInfo, isMainGuideComplete, isFocus])
onAppHide(() => {
player.pause()
})
useEffect(() => {
if (isFocus) {
player.play()
}
}, [player, isFocus])
useEffect(() => {
if (isFocus && userInfo.city && userInfo.grade) {
fetchAccount()
const tabbar = getTabBar<TabbarRef>(page)
tabbar?.setSelected(0)
fetchStage().then(([list, preList]) => {
setTimeout(() => {
nextTick(() => {
const currentItem = list.find(c => c.status === StageStatus.CURRENT)
if (!currentItem) {
updateReady(true)
} else {
const lastItem = preList.find(c => c.status === StageStatus.CURRENT)
if (currentItem?.id !== lastItem?.id) {
scrollToCurrent(() => {
updateReady(true)
})
}
setTimeout(() => {
updateReady(true)
}, 300)
}
})
}, 200)
})
}
}, [isFocus, fetchAccount, fetchStage, page, scrollToCurrent, updateReady, userInfo.city, userInfo.grade])
return (
<>
<MainHeader />
<EyeProtectionView className={styles.body} style={{ paddingTop: `${nav.height + nav.top + 5}px` }}>
<View className={styles.chapterGap} />
<MainScene stageList={stageList} />
<View className={styles.gap}></View>
</EyeProtectionView>
{isReady && (
<MainShortCut onClick={() => scrollToCurrent()} isNext />
)}
<ShareModal />
<Tutorial />
</>
)
}
export default MainPage
import assets from '@/assets/oss/assets-main-next'
import { createContext } from 'react'
import { type Stage, StageStatus, StageLevel, StageType } from '@/api'
import type { ImageSource } from '@/types'
import { preloadImage } from '@/utils/preload-image'
export const SceneContext = createContext<{ ready: boolean }>({ ready: false })
const PartBgPool = [
assets['part-tail-1.png'],
assets['part-tail-2.png'],
assets['part-tail-3.png'],
assets['part-tail-4.png'],
assets['part-tail-5.png'],
assets['part-tail-6.png'],
assets['part-tail-7.png'],
assets['part-tail-8.png'],
assets['part-tail-9.png'],
]
preloadImage([
...PartBgPool.map(c => c.u)
])
export { StageStatus, StageLevel, Stage, StageType }
export const CurrentRoundId = '__current_round__'
export type PartHead = {
partIndex: number;
isHead: true;
index: number;
}
export type StageNext = PartHead | Stage
export type StagePartNext = {
bg: ImageSource;
stages: StageNext[];
bgIndex: number;
}
function stageToStageNext (stageList: Stage[]): {nextList: StageNext[]; showList: Stage[]} {
const newList = stageList.slice().sort((a, b) => (a.part ?? 0) - (b.part ?? 0))
const ret: StageNext[] = []
const currentIndex = newList.findIndex(c => c.status === StageStatus.CURRENT)
let showList: Stage[] = []
if (currentIndex === -1) {
showList = newList
} else {
showList = newList.slice(0, Math.max(currentIndex + 3, 5))
}
let currentPart
let index = -1
for (let i = 0; i < showList.length; i++) {
const item = showList[i]
if (item.part !== currentPart) {
currentPart = item.part
ret.push({ partIndex: currentPart, isHead: true, index: ++index })
ret.push({ ...item, index: ++index })
} else {
ret.push({ ...item, index: ++index })
}
}
return { nextList: ret, showList }
}
export function isPartHead (stage: StageNext): stage is PartHead {
return !!stage.isHead
}
export type StageToStagePartNextRet = {
partList: StagePartNext[];
stageList: Stage[];
stageNextList: StageNext[];
}
export function stageToStagePartNext (stageList: Stage[]): StageToStagePartNextRet {
const { nextList: stageNextList, showList } = stageToStageNext(stageList)
const ret: StagePartNext[] = []
let currentBgIndex = 0
for (let index = 0; index < stageNextList.length;) {
/** 新的part */
if (currentBgIndex % 2 === 0) {
ret.push({
bg: getImageAssets(currentBgIndex),
stages: stageNextList.slice(index, index + 1),
bgIndex: currentBgIndex,
})
index += 1
} else {
ret.push({
bg: getImageAssets(currentBgIndex),
stages: stageNextList.slice(index, index + 2),
bgIndex: currentBgIndex,
})
index += 2
}
currentBgIndex += 1
}
return {
stageNextList,
partList: ret,
stageList: showList
}
}
export function stageToParts (stageList: Stage[]): Part[] {
const ret: Part[] = []
stageList.forEach((item, index) => {
const newItem = { ...item, index }
const last = ret.find(c => c.number === (item.part ?? 1) - 1)
if (last) {
last.stages.push(newItem)
} else {
ret.push({
number: (newItem.part ?? 1) - 1,
stages: [newItem]
})
}
})
return ret
}
const getImageAssets = (index: number): ImageSource => {
if (index === 0) {
return assets['part-first.png']
}
if (index % 2 === 0) {
return PartBgPool[(index / 2) % PartBgPool.length]
}
return assets['part-center.png']
}
export function groupRoundToSmallPart (part: Part): SmallPart[] {
const { number, stages } = part
const ret: SmallPart[] = []
const len = stages.length
let start = 0
const startBg = number
while (start < len) {
const currentStage = stages[start]
if (start === 0) {
const offset = startBg + currentStage.index
ret.push({
isHead: true,
stages: [],
bg: getImageAssets(offset),
offset,
type: 'even'
})
const nextOffset = offset + 1
if (nextOffset % 2 === 0) {
start += 1
ret.push({
stages: [currentStage],
bg: getImageAssets(nextOffset),
offset: nextOffset,
type: 'even'
})
} else {
start += 2
ret.push({
stages: stages.slice(start, start + 2),
bg: getImageAssets(nextOffset),
offset: nextOffset,
type: 'odd'
})
}
} else {
const offset = startBg + currentStage.index
if (offset % 2 === 0) {
start += 1
ret.push({
stages: [currentStage],
bg: getImageAssets(offset),
offset,
type: 'even'
})
} else {
start += 2
ret.push({
stages: stages.slice(start, start + 2),
bg: getImageAssets(offset),
offset,
type: 'odd'
})
}
}
}
return ret
}
export type SmallPart = {
isHead?: boolean;
stages: Stage[];
bg: ImageSource;
offset: number;
type: 'odd' | 'even' | 'special';
}
export type Part = {
stages: Stage[];
number: number;
}
export const getPartBg = (index) => {
if (index === 0) {
return assets['scene-head.png']
}
return PartBgPool[index % 3]
}
.container {
background-color: #F3B751;
position: relative;
overflow: hidden;
}
.stone {
position: absolute;
bottom: 0;
left: 0;
right: 0;
z-index: 2000;
pointer-events: none;
height: 472px;
transform: translate3d(0, -100%, 0);
&::after {
content: " ";
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.6) 100%);
z-index: 2;
}
.stone_1, .cover_1 {
width: 640px;
height: 472px;
margin-left: 110px;
display: block;
position: absolute;
right: 0;
top: 0;
z-index: 2;
opacity: 0;
transition: opacity .5s ease-out;
}
.stone_2, .cover_2 {
width: 540px;
height: 440px;
display: block;
position: absolute;
left: 0;
bottom: 0;
opacity: 0;
transition: opacity .5s ease-out;
}
.is_show {
opacity: 1;
}
.cover_1 {
top: unset;
opacity: 1;
bottom: -472px;
transform: rotateX(180deg);
z-index: 1;
}
.cover_2 {
opacity: 1;
bottom: -440px;
transform: rotateX(180deg);
z-index: 2;
}
.cover {
position: absolute;
left: 0;
right: 0;
bottom: -472px;
height: 472px;
background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, rgba(0,0,0,1) 100%);
z-index: 3;
}
}
import { View, Image } from '@tarojs/components'
import { nextTick, createSelectorQuery } from '@tarojs/taro'
import { useEffect, useMemo, useRef, useState } from 'react'
import assetsMainNext from '@/assets/oss/assets-main-next'
import classNames from 'classnames'
import { stageToStagePartNext, type Stage, isPartHead, StageStatus } from './constants'
import ScenePart from './part'
import styles from './index.module.scss'
type SceneProps = {
stageList: Stage[];
}
const Scene = (props: SceneProps) => {
const { partList, stageList, stageNextList } = useMemo(() => {
return stageToStagePartNext(props.stageList)
}, [props.stageList])
const currentStone = useMemo(() => {
const currentStage = stageNextList.find(c => !isPartHead(c) && c.status === StageStatus.CURRENT)
if (!currentStage) {
return null
}
if (currentStage.index < 4) {
return 2
}
if (currentStage.index % 3 === 1) {
return 2
}
return 1
}, [stageNextList])
const showStone = useMemo(() => {
return stageList.length < props.stageList.length
}, [stageList, props.stageList])
const domRef = useRef<any>()
const [containerHeight, setContainerHeight] = useState<number | null>(null)
useEffect(() => {
if (props.stageList.length < 1) return
nextTick(() => {
if (!domRef.current) return
createSelectorQuery()
.select(`#${domRef.current.uid}`)
.boundingClientRect().exec(([_rect]) => {
setContainerHeight(_rect.height)
})
})
}, [props.stageList])
const stoneStyle = useMemo(() => {
if (containerHeight === null) return {}
return {
top: `${containerHeight}px`,
bottom: 'unset',
transition: 'all .5s ease-out'
}
}, [containerHeight])
return (
<View className={styles.container} ref={domRef}>
{partList.map(item => {
return (
<ScenePart part={item} key={item.bgIndex} />
)
})}
{showStone && (
<View className={styles.stone} style={stoneStyle}>
<Image
src={assetsMainNext['stone-1.png'].u}
className={classNames(styles.stone_1, currentStone === 1 && styles.is_show)}
/>
<Image
src={assetsMainNext['stone-2.png'].u}
className={classNames(styles.stone_2, currentStone === 2 && styles.is_show)}
/>
<Image
src={assetsMainNext['stone-1.png'].u}
className={styles.cover_1}
></Image>
<Image
src={assetsMainNext['stone-2.png'].u}
className={styles.cover_2}
></Image>
<View className={styles.cover} />
</View>
)}
</View>
)
}
export default Scene
.partName {
height: 60px;
background: rgba(0,0,0,0.5);
border-radius: 60px;
font-size: 32px;
font-weight: 600;
color: #FFFFFF;
line-height: 44px;
padding: 0 32px;
}
.place_1 {
position: absolute;
top: 20px;
left: 288px;
}
.place_2 {
position: absolute;
top: 18px;
right: 108px;
}
.place_3 {
position: absolute;
bottom: 70px;
left: 112px;
}
.part {
background-image: url(https://cdn.jkwljy.com/pk-math/uNKs9Mv9QquQbr8ox8Hjn1JAR7n/180x148);
width: 180px;
height: 148px;
background-size: 100% 100%;
font-size: 40px;
font-weight: 600;
color: #FFFFFF;
line-height: 56px;
text-align: center;
box-sizing: border-box;
padding-top: 18px;
}
import { View } from '@tarojs/components'
import { useMemo } from 'react'
import classNames from 'classnames'
import { cs } from '@/styles'
import LazeImage from '../../components/lazy-image'
import { StagePartNext, isPartHead } from './constants'
import StageComp from './stage'
import styles from './part.module.scss'
const getClassName = (index) => {
if (index % 3 === 0) {
return styles.place_1
}
if (index % 3 === 1) {
return styles.place_2
}
return styles.place_3
}
type ScenePartProps = {
part: StagePartNext
}
const ScenePart = (props: ScenePartProps) => {
const { part } = props
return (
<LazeImage source={part.bg}>
{part.stages.map(item => {
if (isPartHead(item)) {
return (
<View className={classNames(styles.part, getClassName(item.index))} key={item.index}>
Part {item.partIndex}
</View>
)
}
return (
<StageComp stage={item} key={item.id} className={getClassName(item.index)} />
)
})}
</LazeImage>
)
}
export default ScenePart
import { Image } from '@tarojs/components'
import { useEffect, useRef, useMemo, useState } from 'react'
import assets from '@/assets/oss/assets-round'
import { useFocus } from '@/hooks'
import classNames from 'classnames'
import {
usePageScroll, createIntersectionObserver, getCurrentInstance,
getMenuButtonBoundingClientRect, IntersectionObserver, nextTick,
createInnerAudioContext, onAppHide, onAppShow
} from '@tarojs/taro'
import audio from '@/assets/oss/assets-audio'
import styles from './stage.module.scss'
let isHide = false
onAppHide(() => {
isHide = true
})
onAppShow(() => {
isHide = false
})
function palyAudio (src: string) {
if (isHide) return
// @ts-ignore
const innerAudioContext = createInnerAudioContext({ useWebAudioImplement: true })
innerAudioContext.src = src
innerAudioContext.play()
innerAudioContext.onEnded = () => {
innerAudioContext.destroy()
}
}
type StageTagProps = {
url?: string;
className: string;
id: number | string;
ready: boolean;
}
const animationQueue: (() => void)[] = []
let isAnimating = false
function flushQueue () {
if (isAnimating) {
return
}
const fn = animationQueue.shift()
if (fn) {
isAnimating = true
setTimeout(() => {
fn()
isAnimating = false
flushQueue()
}, 300)
}
}
const StageTag = (props: StageTagProps) => {
const page = useMemo(() => getCurrentInstance().page, [])
const nav = useRef(getMenuButtonBoundingClientRect())
const { url, className, id, ready } = props
const [isAnimated, setIsAnimated] = useState(false)
const isFocus = useFocus()
const scrollRef = useRef(0)
usePageScroll(payload => {
scrollRef.current = payload.scrollTop
})
useEffect(() => {
setIsAnimated(false)
}, [url])
const uid = useMemo(() => `tag_${id}`, [id])
useEffect(() => {
let observer: IntersectionObserver | null = null
if (isAnimated) return
const animateFn = () => {
palyAudio(audio['蹦蹦top出现首页.wav'].u)
setIsAnimated(true)
page?.animate?.(`#${uid}`, [
{ opacity: 0, translateY: 50, scale: [1, 1] },
{ opacity: 1, translateY: -20, scale: [1.5, 1.5], offset: 0.5 },
{ opacity: 1, translateY: -20, scale: [1.5, 1.5], offset: 0.75 },
{ opacity: 1, translateY: 0, scale: [1, 1] },
], 1000, () => {})
if (observer) {
observer.disconnect()
observer = null
}
}
const fn = () => {
if (ready && isFocus) {
const navVal = nav.current
if (url) {
// @ts-ignore
observer = createIntersectionObserver()
observer
.relativeToViewport({ bottom: 0, top: -navVal.height - navVal.top - 5 - 50 })
.observe(`#${uid}`, ({ intersectionRatio }) => {
if (intersectionRatio > 0) {
animationQueue.push(animateFn)
flushQueue()
} else if (!isAnimated) { // 隐藏了 还没有显示动画 就移除队列
const index = animationQueue.indexOf(animateFn)
if (index !== -1) {
animationQueue.splice(index, 1)
}
}
})
}
}
}
nextTick(fn)
return () => {
if (observer) {
observer.disconnect()
observer = null
}
}
}, [uid, ready, url, page, isFocus, isAnimated])
if (!ready) {
return null
}
return (
<>
{url && (
<Image src={url} className={className} style={{ opacity: 0 }} id={uid}></Image>
)}
<Image src={assets['top-bg.png'].u} className={classNames(className, styles.top_bg)}></Image>
</>
)
}
export default StageTag
.icon {
width: 168px;
height: 168px;
&.isOneStop {
width: 176px;
}
}
.guide_wrap {
border-radius: 50%;
&::after {
content: " ";
position: absolute;
left: -16px;
right: -16px;
top: -16px;
bottom: -16px;
pointer-events: none;
border: 8px dashed #fff;
border-radius: 50%;
}
}
.tutorial {
position: absolute;
left: 84px;
bottom: 48px;
transform: translate3d(-100%, 100%, 0);
white-space: nowrap;
display: flex;
flex-direction: column;
align-items: flex-end;
}
.tutorial_arrow {
width: 128px;
height: 128px;
margin-right: 54px;
display: block;
animation-name: bounce;
animation-duration: 1s;
animation-timing-function: ease-in;
animation-iteration-count: infinite;
}
@keyframes bounce {
0% {
transform: translate3d(-20px, 20px, 0);
}
50% {
transform: translate3d(0, 0, 0);
}
100% {
transform: translate3d(-20px, 20px, 0);
}
}
.tutorial_text {
font-size: 36px;
font-weight: 600;
color: #FFFFFF;
line-height: 50px;
margin-top: 24px;
}
.clear {
position: relative;
z-index: 1;
display: flex;
flex-direction: column;
align-items: center;
}
.clearIcon {
position: relative;
z-index: 2;
display: block;
}
.roundName {
// position: absolute;
// bottom: -48px;
margin: 8px 0px 0 0px;
text-align: center;
font-size: 28px;
font-weight: 500;
color: #FFFFFF;
line-height: 40px;
width: 168px;
white-space: nowrap;
display: flex;
flex-direction: column;
align-items: center;
}
.score {
position: absolute;
width: 96px;
height: 96px;
z-index: 3;
left: 50%;
top: 50%;
margin-top: -56px;
margin-left: -48px;
}
.upname {
position: absolute;
z-index: 3;
right: 30px;
bottom: 0;
width: 70px;
height: 28px;
}
.top_bg {
animation-name: fadeIn;
animation-duration: 1s;
animation-timing-function: ease-out;
animation-fill-mode: backwards;
animation-iteration-count: 1;
}
@keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.uparrow {
position: absolute;
z-index: 3;
right: 2px;
bottom: 2px;
width: 38px;
animation-name: updown;
animation-timing-function: ease-out;
animation-duration: 1s;
animation-iteration-count: infinite;
animation-delay: 0s;
height: 44px;
}
@keyframes updown {
0% {
transform: translateY(-10px);
}
50% {
transform: translateY(0px);
}
100% {
transform: translateY(-10px);
}
}
.star_1 {
position: absolute;
left: 40px;
top: 106px;
width: 32px;
height: 32px;
z-index: 3;
}
.pk {
position: absolute;
right: -64px;
top: 54px;
z-index: 3;
width: 104px;
height: 48px;
background-image: url(https://cdn.jkwljy.com/pk-math/83TAXgfP8i5CfqZruPEzoY9Nse9/104x48);
background-size: 100% 100%;
display: flex;
justify-content: space-between;
font-size: 24px;
font-weight: 600;
color: #FFFFFF;
align-items: center;
}
.pk_item {
padding-right: 8px;
flex: 1;
white-space: nowrap;
text-align: center;
&.is_right {
padding-right: 0px;
padding-left: 8px;
text-align: center;
}
}
.star_2 {
position: absolute;
left: 50%;
margin-left: -16px;
top: 118px;
width: 32px;
height: 32px;
z-index: 3;
}
.star_3 {
position: absolute;
right: 40px;
top: 106px;
width: 32px;
height: 32px;
z-index: 3;
}
.tag {
position: absolute;
z-index: 3;
left: 50%;
top: -26px;
margin-left: -96px;
width: 192px;
height: 80px;
}
import { View, Image } from '@tarojs/components'
import assets from '@/assets/oss/assets-round'
import assetsRoundNext from '@/assets/oss/assets-round-next'
import classNames from 'classnames'
import { cs } from '@/styles'
import { navigateTo } from '@tarojs/taro'
import type { ImageSource } from '@/types'
import { useStoreActions, useStoreState } from '@/store/hooks'
import { UserGuideView } from '@/components'
import tutorial from '@/assets/oss/assets-tutorial'
import { type Stage, StageType, StageStatus, StageLevel, CurrentRoundId } from './constants'
import StageTag from './stage-tag'
import styles from './stage.module.scss'
type StageProps = {
stage: Stage;
className?: string;
}
const getLockedIcon = (type?: StageType): ImageSource => {
switch (type) {
case StageType.Strong: {
return assetsRoundNext['strong-unlock.png']
}
case StageType.Enhance: {
return assetsRoundNext['enhance-unlock.png']
}
case StageType.OneStop: {
return assetsRoundNext['one-stop-unlock.png']
}
case StageType.Special: {
return assetsRoundNext['special-unlock.png']
}
}
return assetsRoundNext['strong-unlock.png']
}
const getTagIcon = (tag?: number): ImageSource | null => {
switch (tag) {
case 10: {
return assets['top-10.png']
}
case 20: {
return assets['top-20.png']
}
case 30: {
return assets['top-30.png']
}
// case 'topn': {
// return assets['top-n.png']
// }
}
return null
}
const getUnlockedIcon = (type?: StageType): ImageSource => {
switch (type) {
case StageType.Strong: {
return assetsRoundNext['strong-current-base.png']
}
case StageType.Enhance: {
return assetsRoundNext['enhance-current-base.png']
}
case StageType.OneStop: {
return assetsRoundNext['one-stop-current.png']
}
case StageType.Special: {
return assetsRoundNext['special-current-base.png']
}
}
return assetsRoundNext['strong-current-base.png']
}
const getClearIcon = (type?: StageType): ImageSource => {
switch (type) {
case StageType.Strong: {
return assetsRoundNext['strong-clear-base.png']
}
case StageType.Enhance: {
return assetsRoundNext['enhance-clear-base.png']
}
case StageType.OneStop: {
return assetsRoundNext['one-stop-clear-base.png']
}
case StageType.Special: {
return assetsRoundNext['special-clear-base.png']
}
}
return assetsRoundNext['strong-clear-base.png']
}
const getScoreIcon = (score?: StageLevel): ImageSource => {
switch (score) {
case StageLevel.S: {
return assets['score-s.png']
}
case StageLevel.A: {
return assets['score-a.png']
}
case StageLevel.B: {
return assets['score-b.png']
}
}
return assets['score-b.png']
}
const getStarSrc = (index: number, star: number) => {
if (star >= index) {
return assetsRoundNext['star-on.png'].u
}
return assetsRoundNext['star-off.png'].u
}
const getIconClassNames = (type?: StageType, extra: string[] = []) => {
return classNames(styles.icon, type === StageType.OneStop && styles.isOneStop, ...extra)
}
const isProduction = process.env.SERVER_ENDPOINT === 'https://geek.jkwljy.com'
const StageComp = (props: StageProps) => {
const { stage } = props
const updateState = useStoreActions(actions => actions.gameModel.updateState)
const completeMainGuide = useStoreActions(actions => actions.guideModel.completeMainGuide)
const isReady = useStoreState(state => state.mainModel.isReady)
const player = useStoreState(state => state.mainModel.player)
const mainGuideActive = useStoreState(state => state.guideModel.mainGuideActive)
const handleClick = () => {
if (stage.status !== StageStatus.DISABLED || !isProduction) {
/** 从首页进入更新状态 */
updateState({ isSubmit: false })
navigateTo({ url: `/pages/prepare/index?id=${stage.id}` })
player.stop()
}
}
const handleCompleteGuide = () => {
handleClick()
completeMainGuide()
}
const renderRound = (ready: boolean) => {
switch (stage.status) {
case StageStatus.DISABLED: {
return (
<Image src={getLockedIcon(stage.type).u} className={getIconClassNames(stage.type)} />
)
}
case StageStatus.CURRENT: {
return (
<UserGuideView
src={getUnlockedIcon(stage.type).u}
component={Image}
className={getIconClassNames(stage.type)}
isActive={mainGuideActive}
verticalPadding={0}
horizonPadding={0}
wrapClass={styles.guide_wrap}
onClickConent={handleCompleteGuide}
guideViewId="firt_stage_guide"
guideContent={(
<View className={styles.tutorial}>
<Image src={tutorial['arrow.png'].u} className={styles.tutorial_arrow}></Image>
<View className={styles.tutorial_text}>让我们从第一关开始吧~</View>
</View>
)}
></UserGuideView>
)
}
case StageStatus.PASSED: {
const tag = getTagIcon(stage.gear)
return (
<View className={styles.clear}>
<StageTag url={tag?.u} className={styles.tag} id={stage.id} ready={ready} />
<Image src={getScoreIcon(stage.level).u} className={styles.score} />
<Image src={getClearIcon(stage.type).u} className={getIconClassNames(stage.type, [styles.clearIcon])} />
<Image src={getStarSrc(1, 2)} className={styles.star_1}></Image>
<Image src={getStarSrc(2, 2)} className={styles.star_2}></Image>
<Image src={getStarSrc(3, 2)} className={styles.star_3}></Image>
<View className={styles.pk}>
<View className={styles.pk_item}>2</View>
<View className={classNames(styles.pk_item, styles.is_right)}>2</View>
</View>
</View>
)
}
}
return (
<Image src={getLockedIcon(stage.type).u} className={getIconClassNames(stage.type)} />
)
}
return (
<View
className={classNames(props.className, cs.bounce_btn)}
hoverClass={cs.bounce_btn_hover}
id={stage.status === StageStatus.CURRENT ? CurrentRoundId : undefined}
onClick={handleClick}
>
{renderRound(isReady)}
<View className={styles.roundName}>
<View>{!isProduction ? `${stage.id}.` : ''}{stage.name}</View>
</View>
</View>
)
}
export default StageComp
...@@ -7,7 +7,7 @@ import { setNavigationBarColor, useRouter } from '@tarojs/taro' ...@@ -7,7 +7,7 @@ import { setNavigationBarColor, useRouter } from '@tarojs/taro'
import { handleShare } from '@/utils/share' import { handleShare } from '@/utils/share'
import Loading from '@/components/Loading' import Loading from '@/components/Loading'
import styles from './main.module.scss' import styles from './main.module.scss'
import MainComponent from './components/main-component' import MainComponent from './main-underground/main-component'
import Guide from './guide' import Guide from './guide'
const MainPage = () => { const MainPage = () => {
......
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