Commit ac80d7e2 authored by hewenhao's avatar hewenhao

feat: 完成页

parent 6a11fa6f
{
"level-big-a.png": {
"u": "https://cdn.jkwljy.com/pk-math/2zfPkUez7MvWGX9byzvYEWRt534g/600x536",
"w": 600,
"h": 536,
"ossName": "/pk-math/2zfPkUez7MvWGX9byzvYEWRt534g/600x536"
},
"level-big-b.png": {
"u": "https://cdn.jkwljy.com/pk-math/3KDAVH97DVVjgDxQyZa2VDWkUg2r/600x536",
"w": 600,
"h": 536,
"ossName": "/pk-math/3KDAVH97DVVjgDxQyZa2VDWkUg2r/600x536"
},
"level-big-fail.png": {
"u": "https://cdn.jkwljy.com/pk-math/436awCGeTzf2tgvWSXUG7NKemLoG/600x536",
"w": 600,
"h": 536,
"ossName": "/pk-math/436awCGeTzf2tgvWSXUG7NKemLoG/600x536"
},
"level-big-s.png": {
"u": "https://cdn.jkwljy.com/pk-math/2TLyxTrzYPfQNnqjAC4EKU5yeJDc/600x536",
"w": 600,
"h": 536,
"ossName": "/pk-math/2TLyxTrzYPfQNnqjAC4EKU5yeJDc/600x536"
},
"level-small-a.png": {
"u": "https://cdn.jkwljy.com/pk-math/3mjQxagkFJdkLNhebtT8JsfBoyhn/96x96",
"w": 96,
"h": 96,
"ossName": "/pk-math/3mjQxagkFJdkLNhebtT8JsfBoyhn/96x96"
},
"level-small-b.png": {
"u": "https://cdn.jkwljy.com/pk-math/KiwVWrKQq95Shz2vXTJfjWYUP7z/96x96",
"w": 96,
"h": 96,
"ossName": "/pk-math/KiwVWrKQq95Shz2vXTJfjWYUP7z/96x96"
},
"level-small-s.png": {
"u": "https://cdn.jkwljy.com/pk-math/W2YpeW3W1dyAw5DCnRJDN8EwbTc/96x96",
"w": 96,
"h": 96,
"ossName": "/pk-math/W2YpeW3W1dyAw5DCnRJDN8EwbTc/96x96"
},
"rank.png": {
"u": "https://cdn.jkwljy.com/pk-math/442Pwd6Lhv2rg3bAuswGBRcgxCWP/96x96",
"w": 96,
"h": 96,
"ossName": "/pk-math/442Pwd6Lhv2rg3bAuswGBRcgxCWP/96x96"
},
"top-10.png": {
"u": "https://cdn.jkwljy.com/pk-math/39isvoNV9Ff7bxj7KrLy9xa1Snwf/96x96",
"w": 96,
"h": 96,
"ossName": "/pk-math/39isvoNV9Ff7bxj7KrLy9xa1Snwf/96x96"
},
"top-20.png": {
"u": "https://cdn.jkwljy.com/pk-math/2kvKyUPeFuDRDc4gMBmZyUCgNJE5/96x96",
"w": 96,
"h": 96,
"ossName": "/pk-math/2kvKyUPeFuDRDc4gMBmZyUCgNJE5/96x96"
},
"top-30.png": {
"u": "https://cdn.jkwljy.com/pk-math/atKFsVMz8d2uk7EgpTMP4SrDn23/96x96",
"w": 96,
"h": 96,
"ossName": "/pk-math/atKFsVMz8d2uk7EgpTMP4SrDn23/96x96"
},
"upgear.png": {
"u": "https://cdn.jkwljy.com/pk-math/3fub4EVopGTCveFoM4fhbpnNzssq/96x96",
"w": 96,
"h": 96,
"ossName": "/pk-math/3fub4EVopGTCveFoM4fhbpnNzssq/96x96"
},
"btn-bg.png": {
"u": "https://cdn.jkwljy.com/pk-math/2CsZUPRwpdDQj41Co2dkdGNywHiM/686x112",
"w": 686,
"h": 112,
"ossName": "/pk-math/2CsZUPRwpdDQj41Co2dkdGNywHiM/686x112"
}
}
...@@ -11,6 +11,7 @@ export default { ...@@ -11,6 +11,7 @@ export default {
'pages/prepare/index', 'pages/prepare/index',
'pages/study-market/index', 'pages/study-market/index',
'pages/game/play/index', 'pages/game/play/index',
'pages/game/complete/index',
'pages/summary/index', 'pages/summary/index',
], ],
subPackages: {{packages}}, subPackages: {{packages}},
......
...@@ -98,17 +98,29 @@ interface CompleteStageParamIn extends CompleteStageParam { ...@@ -98,17 +98,29 @@ interface CompleteStageParamIn extends CompleteStageParam {
} }
export interface CompleteStageOut { export interface CompleteStageOut {
/** 单题耗时 */
averageTime: number; averageTime: number;
/** 排名档位 */
gear: number; gear: number;
/** 成就等级:SAB */
level: StageLevel; level: StageLevel;
/** 下一档位 */
nextGear: number; nextGear: number;
/** 下一档位时间 */
nextGearTime: number; nextGearTime: number;
/** 积分后 */
pointAfter: number; pointAfter: number;
/** 积分前 */
pointBefore: number; pointBefore: number;
/** 排名 */
ranks: StageRank[]; ranks: StageRank[];
/** 正确率 */
rate: number; rate: number;
/** 耗时 */
resultTime: number; resultTime: number;
/** S时间 */
sLevelTime: number; sLevelTime: number;
/** 是否升档奖励 */
upGear: boolean; upGear: boolean;
} }
......
/* eslint-disable quotes */
/* eslint-disable quote-props */
export default {
"level-big-a.png": {
"u": "https://cdn.jkwljy.com/pk-math/2zfPkUez7MvWGX9byzvYEWRt534g/600x536",
"w": 600,
"h": 536
},
"level-big-b.png": {
"u": "https://cdn.jkwljy.com/pk-math/3KDAVH97DVVjgDxQyZa2VDWkUg2r/600x536",
"w": 600,
"h": 536
},
"level-big-fail.png": {
"u": "https://cdn.jkwljy.com/pk-math/436awCGeTzf2tgvWSXUG7NKemLoG/600x536",
"w": 600,
"h": 536
},
"level-big-s.png": {
"u": "https://cdn.jkwljy.com/pk-math/2TLyxTrzYPfQNnqjAC4EKU5yeJDc/600x536",
"w": 600,
"h": 536
},
"level-small-a.png": {
"u": "https://cdn.jkwljy.com/pk-math/3mjQxagkFJdkLNhebtT8JsfBoyhn/96x96",
"w": 96,
"h": 96
},
"level-small-b.png": {
"u": "https://cdn.jkwljy.com/pk-math/KiwVWrKQq95Shz2vXTJfjWYUP7z/96x96",
"w": 96,
"h": 96
},
"level-small-s.png": {
"u": "https://cdn.jkwljy.com/pk-math/W2YpeW3W1dyAw5DCnRJDN8EwbTc/96x96",
"w": 96,
"h": 96
},
"rank.png": {
"u": "https://cdn.jkwljy.com/pk-math/442Pwd6Lhv2rg3bAuswGBRcgxCWP/96x96",
"w": 96,
"h": 96
},
"top-10.png": {
"u": "https://cdn.jkwljy.com/pk-math/39isvoNV9Ff7bxj7KrLy9xa1Snwf/96x96",
"w": 96,
"h": 96
},
"top-20.png": {
"u": "https://cdn.jkwljy.com/pk-math/2kvKyUPeFuDRDc4gMBmZyUCgNJE5/96x96",
"w": 96,
"h": 96
},
"top-30.png": {
"u": "https://cdn.jkwljy.com/pk-math/atKFsVMz8d2uk7EgpTMP4SrDn23/96x96",
"w": 96,
"h": 96
},
"upgear.png": {
"u": "https://cdn.jkwljy.com/pk-math/3fub4EVopGTCveFoM4fhbpnNzssq/96x96",
"w": 96,
"h": 96
},
"btn-bg.png": {
"u": "https://cdn.jkwljy.com/pk-math/2CsZUPRwpdDQj41Co2dkdGNywHiM/686x112",
"w": 686,
"h": 112
}
} as const
.title {
font-size: 36px;
font-weight: 500;
color: #465164;
line-height: 50px;
padding: 16px 0 24px 32px;
}
.achieve_item {
display: flex;
margin: 0 32px 24px 32px;
padding: 24px 48px 24px 24px;
align-items: center;
background: #F7F7F7;
border-radius: 32px;
}
.achieve_item_main {
flex: 1;
}
.main_text {
font-size: 32px;
font-weight: 600;
color: #465164;
line-height: 44px;
}
.tips_text {
font-size: 28px;
font-weight: 500;
color: rgba(70,81,100,0.5);
line-height: 40px;
margin-top: 8px;
}
.rank_text {
font-size: 32px;
font-weight: 600;
color: #FF9D00;
line-height: 44px;
}
.achieve_icon {
width: 96px;
height: 96px;
margin-right: 24px;
}
.bonus_icon {
width: 56px;
height: 56px;
}
.bonus_text {
font-size: 24px;
font-weight: 500;
color: #00AEFF;
line-height: 30px;
margin-top: 4px;
}
.footer {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 2000;
background-color: #fff;
}
@supports (padding-bottom: constant(safe-area-inset-bottom)) or (padding-bottom: env(safe-area-inset-bottom)) {
.footer {
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom : env(safe-area-inset-bottom);
}
.wrap {
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom : env(safe-area-inset-bottom);
}
}
.gap {
height: 160px;
}
.btn_continue {
background-image: url(https://cdn.jkwljy.com/pk-math/2CsZUPRwpdDQj41Co2dkdGNywHiM/686x112);
background-size: 100% 100%;
width: 686px;
margin: 16px 32px 32px 32px;
height: 112px;
display: flex;
align-items: center;
justify-content: center;
font-size: 40px;
font-weight: 600;
color: #FFFFFF;
line-height: 56px;
}
import { View, Image } from '@tarojs/components'
import assets from '@/assets/oss/assets-complete'
import { useMemo } from 'react'
import { useStoreState } from '@/store/hooks'
import { StageLevel } from '@/api'
import { cs } from '@/styles'
import styles from './complete-achieve.module.scss'
const getLevelBg = (s?: StageLevel): string => {
switch (s) {
case StageLevel.S: {
return assets['level-small-s.png'].u
}
case StageLevel.A: {
return assets['level-small-a.png'].u
}
case StageLevel.B: {
return assets['level-small-b.png'].u
}
}
return assets['level-small-b.png'].u
}
const getTopIcon = (s: number) => {
switch (s) {
case 10: {
return assets['top-10.png'].u
}
case 20: {
return assets['top-20.png'].u
}
case 30: {
return assets['top-30.png'].u
}
}
return null
}
const GameCompleteAchieve = () => {
const gameResult = useStoreState(state => state.gameModel.gameResult)
const level = useMemo(() => {
return getLevelBg(gameResult?.level)
}, [gameResult])
const topIcon = useMemo(() => {
return getTopIcon(gameResult?.gear ?? 0)
}, [gameResult])
return (
<>
<View className={styles.wrap}>
<View className={styles.title}>本关成就获得</View>
<View className={styles.achieve_item}>
<Image src={level} className={styles.achieve_icon}></Image>
<View className={cs.flex__item}>
<View className={styles.main_text}>B等级</View>
<View className={styles.tips_text}>全对且用时≤1分30秒</View>
</View>
<View>
<Image src={require('../assets/bonus.png')} className={styles.bonus_icon}></Image>
<View className={styles.bonus_text}>+30</View>
</View>
</View>
{topIcon && (
<View className={styles.achieve_item}>
<Image src={topIcon} className={styles.achieve_icon}></Image>
<View className={cs.flex__item}>
<View className={styles.main_text}>TOP {gameResult?.gear ?? 0}%</View>
<View className={styles.tips_text}>恭喜你成为了最优秀的{gameResult?.gear ?? 0}%</View>
</View>
<View>
<Image src={require('../assets/bonus.png')} className={styles.bonus_icon}></Image>
<View className={styles.bonus_text}>+20</View>
</View>
</View>
)}
<View className={styles.achieve_item}>
<Image src={assets['rank.png'].u} className={styles.achieve_icon}></Image>
<View className={cs.flex__item}>
<View className={styles.main_text}>全市排名</View>
<View className={styles.tips_text}>恭喜你进入了全市前100名</View>
</View>
<View className={styles.rank_text}>89名</View>
</View>
{gameResult?.upGear && (
<View className={styles.achieve_item}>
<Image src={assets['upgear.png'].u} className={styles.achieve_icon}></Image>
<View className={cs.flex__item}>
<View className={styles.main_text}>升档成功</View>
<View className={styles.tips_text}>提升到50%-60%</View>
</View>
<View>
<Image src={require('../assets/bonus.png')} className={styles.bonus_icon}></Image>
<View className={styles.bonus_text}>+10</View>
</View>
</View>
)}
<View className={styles.gap}></View>
</View>
<View className={styles.footer}>
<View
className={styles.btn_continue}
hoverClass={styles.is_active}
>
继续
</View>
</View>
</>
)
}
export default GameCompleteAchieve
.head {
background-image: linear-gradient(to bottom, #B7CDEB 0%, #F1FAFF 87.0301573% , #FFFFFF 100%);
padding-bottom: 64px;
position: relative;
}
.bg {
width: 600px;
display: block;
margin: 0 auto;
height: 536px;
}
.tips {
position: absolute;
bottom: 158px;
left: 0;
right: 0;
text-align: center;
font-size: 48px;
line-height: 66px;
font-weight: bold;
}
.item_wrap {
padding: 0 70px;
display: flex;
align-items: center;
justify-content: space-between;
margin-top: -14px;
}
.item {
display: flex;
align-items: center;
justify-content: center;
}
.icon {
width: 60px;
height: 60px;
margin-right: 6px;
}
.item_text {
width: 96px;
font-size: 28px;
font-weight: 500;
color: #465164;
text-align: center;
line-height: 40px;
}
import { View, Image, Text } from '@tarojs/components'
import { useMemo } from 'react'
import { getMenuButtonBoundingClientRect } from '@tarojs/taro'
import assets from '@/assets/oss/assets-complete'
import { useFormatTick } from '@/hooks/use-format-tick'
import { StageLevel } from '@/api'
import { useStoreState } from '@/store/hooks'
import styles from './complete-head.module.scss'
const getLevelBigBg = (s?: StageLevel): string => {
switch (s) {
case StageLevel.S: {
return assets['level-big-s.png'].u
}
case StageLevel.A: {
return assets['level-big-a.png'].u
}
case StageLevel.B: {
return assets['level-big-b.png'].u
}
}
return assets['level-big-fail.png'].u
}
const getLevelText = (s?: StageLevel) => {
switch (s) {
case StageLevel.S: {
return {
text: '恭喜你闯关成功',
second: '刷新了你的最佳表现,棒',
color: '#FF7C3F'
}
}
case StageLevel.A: {
return {
text: '恭喜你闯关成功',
second: '刷新了你的最佳表现,棒',
color: '#7794BD'
}
}
case StageLevel.B: {
return {
text: '恭喜你闯关成功',
second: '刷新了你的最佳表现,棒',
color: '#AA561C'
}
}
}
return {
text: '闯关失败',
second: '闯关失败',
color: '#465164'
}
}
const GameCompleteHead = () => {
const nav = useMemo(getMenuButtonBoundingClientRect, [])
const gameResult = useStoreState(state => state.gameModel.gameResult)
const time = useFormatTick((gameResult?.resultTime ?? 0) * 1000)
const bg = useMemo(() => {
return getLevelBigBg(gameResult?.level)
}, [gameResult])
const text = useMemo(() => {
return getLevelText(gameResult?.level)
}, [gameResult])
const style = useMemo(() => {
return {
paddingTop: `${nav.top - 5}px`
}
}, [nav])
return (
<View style={style} className={styles.head}>
<Image src={bg} className={styles.bg}></Image>
<View style={{ color: text.color }} className={styles.tips}>{text.text}</View>
<View className={styles.item_wrap}>
<View className={styles.item}>
<Image src={require('../assets/bonus.png')} className={styles.icon}></Image>
<View className={styles.item_text}>+30</View>
</View>
<View className={styles.item}>
<Image src={require('../assets/right-count.png')} className={styles.icon}></Image>
<View className={styles.item_text}>全对</View>
</View>
<View className={styles.item}>
<Image src={require('../assets/time.png')} className={styles.icon}></Image>
<View className={styles.item_text}>{time.minutes}:{time.seconds}</View>
</View>
</View>
</View>
)
}
export default GameCompleteHead
export default definePageConfig({
navigationBarTitleText: 'pk-math',
navigationStyle: 'custom',
})
import GameCompleteHead from './components/complete-head'
import GameCompleteAchieve from './components/complete-achieve'
// import styles from './index.module.scss'
const GameComplete = () => {
return (
<>
<GameCompleteHead />
<GameCompleteAchieve />
</>
)
}
export default GameComplete
import { View, ScrollView, Button } from '@tarojs/components' import { View, ScrollView } from '@tarojs/components'
import { useStoreState, useStoreActions } from '@/store/hooks' import { useStoreState, useStoreActions } from '@/store/hooks'
import { useEffect } from 'react' import { useEffect } from 'react'
import { useRouter } from '@tarojs/taro' import { useRouter } from '@tarojs/taro'
...@@ -37,7 +37,6 @@ const GamePlay = () => { ...@@ -37,7 +37,6 @@ const GamePlay = () => {
{currentQuestion && ( {currentQuestion && (
<Question question={currentQuestion} /> <Question question={currentQuestion} />
)} )}
<Button onClick={actions.toggle}>23xxxxx4</Button>
</ScrollView> </ScrollView>
{currentQuestion && ( {currentQuestion && (
<> <>
......
import { action, Action, computed, Computed, State, Thunk, thunk } from 'easy-peasy' import { action, Action, computed, Computed, State, Thunk, thunk } from 'easy-peasy'
import { AppStoreModel } from '@/store/store-model' import { AppStoreModel } from '@/store/store-model'
import { getQuestionList, type StageDetail, getStageDetail, completeStage, StageType } from '@/api' import { getQuestionList, type StageDetail, getStageDetail, completeStage, StageType, type CompleteStageOut, StageLevel } from '@/api'
import { showLoading, hideLoading, showModal } from '@tarojs/taro' import { showLoading, hideLoading, showModal } from '@tarojs/taro'
import { import {
QuestionType, QuestionType,
...@@ -16,6 +16,7 @@ export interface GameModel { ...@@ -16,6 +16,7 @@ export interface GameModel {
/** 题目列表 */ /** 题目列表 */
questionList: QuestionType[]; questionList: QuestionType[];
stageDetail: StageDetail | null; stageDetail: StageDetail | null;
gameResult: CompleteStageOut | null;
gameStartTime: number; gameStartTime: number;
updateState: Action<GameModel, Partial<State<GameModel>>>; updateState: Action<GameModel, Partial<State<GameModel>>>;
/** 当前题目 */ /** 当前题目 */
...@@ -53,6 +54,32 @@ export interface GameModel { ...@@ -53,6 +54,32 @@ export interface GameModel {
const gameModel: GameModel = { const gameModel: GameModel = {
questionList: [], questionList: [],
gameResult: {
/** 单题耗时 */
averageTime: 4,
/** 排名档位 */
gear: 10,
/** 成就等级:SAB */
level: StageLevel.S,
/** 下一档位 */
nextGear: 10,
/** 下一档位时间 */
nextGearTime: 3,
/** 积分后 */
pointAfter: 80,
/** 积分前 */
pointBefore: 76,
/** 排名 */
ranks: [],
/** 正确率 */
rate: 80,
/** 耗时 */
resultTime: 60,
/** S时间 */
sLevelTime: 70,
/** 是否升档奖励 */
upGear: true
},
modalContinueVisible: false, modalContinueVisible: false,
gameStartTime: 0, gameStartTime: 0,
isSubmit: false, isSubmit: false,
...@@ -196,7 +223,8 @@ const gameModel: GameModel = { ...@@ -196,7 +223,8 @@ const gameModel: GameModel = {
}) })
actions.updateState({ isSubmit: true }) actions.updateState({ isSubmit: true })
const { questionList, gameStartTime, stageDetail } = helpers.getState() const { questionList, gameStartTime, stageDetail } = helpers.getState()
await completeStage(buildCompleteStageParam(questionList, stageDetail!, gameStartTime)) const { data: gameResult } = await completeStage(buildCompleteStageParam(questionList, stageDetail!, gameStartTime))
actions.updateState({ gameResult })
} catch (err) { } catch (err) {
showModal({ showModal({
title: '提示', title: '提示',
......
import assets from '@/assets/oss/assets-main' import assets from '@/assets/oss/assets-main'
import { createContext } from 'react' import { createContext } from 'react'
import { type Stage, StageStatus, StageLevel, StageType } from '@/api' import { type Stage, StageStatus, StageLevel, StageType } from '@/api'
import type { ImageSource } from '@/types'
export const SceneContext = createContext<{ ready: boolean }>({ ready: false }) export const SceneContext = createContext<{ ready: boolean }>({ ready: false })
export type ImageSource = {
w: number;
h: number;
u: string;
}
const PartBgPool = [ const PartBgPool = [
assets['part-bg-1.png'], assets['part-bg-1.png'],
assets['part-bg-2.png'], assets['part-bg-2.png'],
......
...@@ -3,7 +3,9 @@ import assets from '@/assets/oss/assets-round' ...@@ -3,7 +3,9 @@ import assets from '@/assets/oss/assets-round'
import classNames from 'classnames' import classNames from 'classnames'
import { cs } from '@/styles' import { cs } from '@/styles'
import { navigateTo } from '@tarojs/taro' import { navigateTo } from '@tarojs/taro'
import { type Stage, StageType, StageStatus, type ImageSource, StageLevel, CurrentRoundId, SceneContext } from './constants' import type { ImageSource } from '@/types'
import { type Stage, StageType, StageStatus, StageLevel, CurrentRoundId, SceneContext } from './constants'
import StageTag from './stage-tag' import StageTag from './stage-tag'
import styles from './stage.module.scss' import styles from './stage.module.scss'
......
...@@ -10,6 +10,12 @@ export type UserInfo = { ...@@ -10,6 +10,12 @@ export type UserInfo = {
export type RequestResultPagingLike<T> = RequestResult<PagingLike<T>> export type RequestResultPagingLike<T> = RequestResult<PagingLike<T>>
export type ImageSource = {
w: number;
h: number;
u: string;
}
export type PagingLike<T> = { export type PagingLike<T> = {
list: T[]; list: T[];
hasNextPage: boolean; hasNextPage: boolean;
......
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