Commit 43a647e3 authored by hewenhao's avatar hewenhao

feat: 首页

parent 24d90c96
...@@ -3,11 +3,9 @@ ...@@ -3,11 +3,9 @@
#构建模式 #构建模式
BUILD_MODE=production BUILD_MODE=production
# 微信小程序appid wxa90a0810c0c52555 wxb1383b0817e6206b WEAPP_ID=wx8f25def587982a19
WEAPP_ID=wxb1383b0817e6206b
# 服务器接口地址 # 服务器接口地址
SERVER_ENDPOINT=http://172.10.62.70 SERVER_ENDPOINT=http://172.10.61.170
# 天御验证码App id # 天御验证码App id
TARO_T_CAPTCHA_APP_ID=2034167834 TARO_T_CAPTCHA_APP_ID=2034167834
......
...@@ -94,5 +94,17 @@ ...@@ -94,5 +94,17 @@
"w": 192, "w": 192,
"h": 80, "h": 80,
"ossName": "/pk-math/4EfUGL88udGyL8osFRS6K8unorkb/192x80" "ossName": "/pk-math/4EfUGL88udGyL8osFRS6K8unorkb/192x80"
},
"up-bonus-arrow.png": {
"u": "https://cdn.jkwljy.com/pk-math/Dt6tavQFh4eoHhg4uBW2dsmVacm/38x44",
"w": 38,
"h": 44,
"ossName": "/pk-math/Dt6tavQFh4eoHhg4uBW2dsmVacm/38x44"
},
"up-bonus.png": {
"u": "https://cdn.jkwljy.com/pk-math/3GCGt4XjNrPVSmCXYAqivEd9uNRa/70x28",
"w": 70,
"h": 28,
"ossName": "/pk-math/3GCGt4XjNrPVSmCXYAqivEd9uNRa/70x28"
} }
} }
...@@ -80,5 +80,15 @@ export default { ...@@ -80,5 +80,15 @@ export default {
"u": "https://cdn.jkwljy.com/pk-math/4EfUGL88udGyL8osFRS6K8unorkb/192x80", "u": "https://cdn.jkwljy.com/pk-math/4EfUGL88udGyL8osFRS6K8unorkb/192x80",
"w": 192, "w": 192,
"h": 80 "h": 80
},
"up-bonus-arrow.png": {
"u": "https://cdn.jkwljy.com/pk-math/Dt6tavQFh4eoHhg4uBW2dsmVacm/38x44",
"w": 38,
"h": 44
},
"up-bonus.png": {
"u": "https://cdn.jkwljy.com/pk-math/3GCGt4XjNrPVSmCXYAqivEd9uNRa/70x28",
"w": 70,
"h": 28
} }
} as const } as const
.chapter { .chapter {
padding: 28px 32px 30px 32px; padding: 28px 32px 30px 32px;
border-top: 2px solid #03459C;
background-color: #1786f7; background-color: #1786f7;
background-image: url(../assets/chapter-bg.png); background-image: url(../assets/chapter-bg.png);
background-size: 100% 100%; background-size: 100% 100%;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
.headerContent { .headerContent {
position: relative; position: relative;
z-index: 2; z-index: 2;
border-bottom: 2px solid #03459C;
} }
.bg { .bg {
......
...@@ -118,6 +118,7 @@ export type Round = { ...@@ -118,6 +118,7 @@ export type Round = {
id: number; id: number;
name?: string; name?: string;
tag?: string; tag?: string;
upBonus?: boolean;
} }
export type SmallPart = { export type SmallPart = {
......
...@@ -20,7 +20,8 @@ const dataList: Part[] = [ ...@@ -20,7 +20,8 @@ const dataList: Part[] = [
{ {
state: RoundState.Clear, state: RoundState.Clear,
type: RoundType.Enhance, type: RoundType.Enhance,
score: RoundScore.S, score: RoundScore.A,
upBonus: true,
tag: 'top20', tag: 'top20',
name: '应用过关1', name: '应用过关1',
id: 2, id: 2,
...@@ -37,6 +38,7 @@ const dataList: Part[] = [ ...@@ -37,6 +38,7 @@ const dataList: Part[] = [
state: RoundState.Clear, state: RoundState.Clear,
type: RoundType.Strong, type: RoundType.Strong,
score: RoundScore.A, score: RoundScore.A,
upBonus: true,
tag: 'topn', tag: 'topn',
name: '计算达标3', name: '计算达标3',
id: 4, id: 4,
...@@ -55,25 +57,57 @@ const dataList: Part[] = [ ...@@ -55,25 +57,57 @@ const dataList: Part[] = [
rounds: [ rounds: [
{ {
id: 6, id: 6,
state: RoundState.UnLocked, state: RoundState.Clear,
type: RoundType.Enhance,
name: '计算达标1',
score: RoundScore.A,
},
{
id: 7,
state: RoundState.Clear,
type: RoundType.Strong,
score: RoundScore.S,
tag: 'top20',
name: '计算达标1',
},
{
id: 8,
state: RoundState.Clear,
type: RoundType.OneStop,
score: RoundScore.S,
tag: 'top10',
name: '计算达标1', name: '计算达标1',
}, },
{ id: 7 }, {
{ id: 8 }, id: 9,
{ id: 9 } state: RoundState.Clear,
type: RoundType.Enhance,
score: RoundScore.A,
name: '计算达标1',
}
], ],
number: 1 number: 1
}, },
{ {
rounds: [{ id: 10 }, { id: 11 }, { id: 12 }, { id: 13 }, { id: 14 }, { id: 15 }], rounds: [
{ id: 10, type: RoundType.Enhance, state: RoundState.UnLocked, name: '计算达标1' },
{ id: 11 },
{
id: 12,
type: RoundType.OneStop,
},
{ id: 13, type: RoundType.Enhance, },
{ id: 14 },
{ id: 15, type: RoundType.Enhance, }
],
number: 2 number: 2
}, },
{ {
rounds: [{ id: 16 }, { id: 17 }, { id: 18 }], rounds: [{ id: 16, type: RoundType.Enhance, }, { id: 17 }, { id: 18, type: RoundType.OneStop }],
number: 3 number: 3
}, },
{ {
rounds: [{ id: 19 }, { id: 20 }, { id: 21 }, { id: 22 }, { id: 23 }, { id: 24 }, { id: 25 }], rounds: [{ id: 19 }, { id: 20, type: RoundType.OneStop }, { id: 21 }, { id: 22, type: RoundType.Enhance }, { id: 23, type: RoundType.OneStop }, { id: 24 }, { id: 25 }],
number: 4 number: 4
}, },
] ]
......
...@@ -41,6 +41,41 @@ ...@@ -41,6 +41,41 @@
margin-left: -48px; margin-left: -48px;
} }
.upname {
position: absolute;
z-index: 3;
right: 30px;
bottom: 0;
width: 70px;
height: 28px;
}
.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);
}
}
.tag { .tag {
position: absolute; position: absolute;
z-index: 3; z-index: 3;
......
...@@ -122,6 +122,12 @@ const RoundComp = (props: RoundProps) => { ...@@ -122,6 +122,12 @@ const RoundComp = (props: RoundProps) => {
)} )}
<Image src={getScoreIcon(round.score).u} className={styles.score} /> <Image src={getScoreIcon(round.score).u} className={styles.score} />
<Image src={getClearIcon(round.type).u} className={getIconClassNames(round.type, [styles.clearIcon])} /> <Image src={getClearIcon(round.type).u} className={getIconClassNames(round.type, [styles.clearIcon])} />
{!!round.upBonus && (
<>
<Image src={assets['up-bonus.png'].u} className={styles.upname}></Image>
<Image src={assets['up-bonus-arrow.png'].u} className={styles.uparrow}></Image>
</>
)}
</View> </View>
) )
} }
......
...@@ -12,7 +12,7 @@ type ShortCutProps = { ...@@ -12,7 +12,7 @@ type ShortCutProps = {
} }
const ShortCut = (props: ShortCutProps) => { const ShortCut = (props: ShortCutProps) => {
const [isShow, setIsShow] = useState(false) const [isShow, setIsShow] = useState(true)
const [isDown, setIsDown] = useState(false) const [isDown, setIsDown] = useState(false)
const scrollRef = useRef(0) const scrollRef = useRef(0)
const lastEffectedScroll = useRef(0) const lastEffectedScroll = useRef(0)
...@@ -27,12 +27,11 @@ const ShortCut = (props: ShortCutProps) => { ...@@ -27,12 +27,11 @@ const ShortCut = (props: ShortCutProps) => {
const show = intersectionRatio > 0 const show = intersectionRatio > 0
setIsShow(show) setIsShow(show)
if (show) { setIsDown(lastEffectedScroll.current < scrollRef.current)
setIsDown(lastEffectedScroll.current < scrollRef.current)
}
lastEffectedScroll.current = scrollRef.current lastEffectedScroll.current = scrollRef.current
}) })
return () => { return () => {
if (observer) { if (observer) {
observer.disconnect() observer.disconnect()
...@@ -45,7 +44,7 @@ const ShortCut = (props: ShortCutProps) => { ...@@ -45,7 +44,7 @@ const ShortCut = (props: ShortCutProps) => {
<View className={styles.shortcut}> <View className={styles.shortcut}>
<View className={classNames(styles.shortcutInner, isShow && styles.isShow)} onClick={props.onClick}> <View className={classNames(styles.shortcutInner, isShow && styles.isShow)} onClick={props.onClick}>
<Image src={assets['short-cut-bg.png'].u} className={styles.bg}></Image> <Image src={assets['short-cut-bg.png'].u} className={styles.bg}></Image>
<Image src={assets['short-cut-arrow.png'].u} className={classNames(styles.arrow, isDown && styles.isDown)}></Image> <Image src={assets['short-cut-arrow.png'].u} className={classNames(styles.arrow, ((!isShow && isDown) || (isShow && !isDown)) && styles.isDown)}></Image>
</View> </View>
</View> </View>
) )
......
...@@ -11,6 +11,7 @@ import styles from './main.module.scss' ...@@ -11,6 +11,7 @@ import styles from './main.module.scss'
const MainPage = () => { const MainPage = () => {
const page = useMemo(() => getCurrentInstance().page, []) const page = useMemo(() => getCurrentInstance().page, [])
const [isReady, setIsReady] = useState(false)
useDidShow(() => { useDidShow(() => {
const tabbar = getTabBar(page) as any const tabbar = getTabBar(page) as any
...@@ -18,19 +19,22 @@ const MainPage = () => { ...@@ -18,19 +19,22 @@ const MainPage = () => {
}) })
const [nav] = useState(getMenuButtonBoundingClientRect()) const [nav] = useState(getMenuButtonBoundingClientRect())
const scrollToCurrent = useCallback(() => { const scrollToCurrent = useCallback((callback?: () => void) => {
const height = getSystemInfoSync().windowHeight const height = getSystemInfoSync().windowHeight
pageScrollTo({ pageScrollTo({
selector: `#${CurrentRoundId}`, selector: `#${CurrentRoundId}`,
offsetTop: -height / 2 offsetTop: -height / 2,
complete: callback
}) })
}, []) }, [])
useEffect(() => { useEffect(() => {
setTimeout(() => { setTimeout(() => {
scrollToCurrent() scrollToCurrent(() => {
setIsReady(true)
})
}, 1000) }, 1000)
}, []) }, [scrollToCurrent])
return ( return (
<View className={styles.viewport}> <View className={styles.viewport}>
...@@ -40,7 +44,9 @@ const MainPage = () => { ...@@ -40,7 +44,9 @@ const MainPage = () => {
<MainScene /> <MainScene />
<View className={styles.gap}></View> <View className={styles.gap}></View>
</View> </View>
<MainShortCut onClick={scrollToCurrent} /> {isReady && (
<MainShortCut onClick={() => scrollToCurrent()} />
)}
</View> </View>
) )
} }
......
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