Commit 8c96aec7 authored by raca's avatar raca

feat: pk战报pk弹窗

parent 31a1d45a
...@@ -16,3 +16,4 @@ _testing ...@@ -16,3 +16,4 @@ _testing
/qr_output /qr_output
/gen-mini-qr.js /gen-mini-qr.js
.prettierrc
{
"prettier.singleQuote": true,
"prettier.semi": false
}
\ No newline at end of file
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
export default { export default {
pages: [ pages: [
'pages/main/main', 'pages/main/main',
'pages/pk/index', 'pages/battles/index',
'pages/prepare/index', 'pages/prepare/index',
'pages/group/index', 'pages/group/index',
'pages/market/index', 'pages/market/index',
......
.wrapper { .wrapper {
position: fixed; position: fixed;
text-align: center;
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
...@@ -29,7 +30,6 @@ ...@@ -29,7 +30,6 @@
.header { .header {
border-radius: 32px 32px 0px 0px; border-radius: 32px 32px 0px 0px;
background-color: #465164; background-color: #465164;
text-align: center;
height: 88px; height: 88px;
line-height: 88px; line-height: 88px;
position: relative; position: relative;
......
...@@ -5,7 +5,7 @@ import EyeProtectionView from '../EyeProtectionView' ...@@ -5,7 +5,7 @@ import EyeProtectionView from '../EyeProtectionView'
import styles from './index.module.scss' import styles from './index.module.scss'
interface ModalProps { interface ModalProps {
tilte?: string; tilte?: string | React.ReactNode;
isVisible: boolean; isVisible: boolean;
wrapClassName?: string; wrapClassName?: string;
bodyClassName?: string; bodyClassName?: string;
......
.modalWrap {
text-align: left;
}
.modalBody {
background-color: #465164;
margin-top: -32px;
border-bottom-left-radius: 32px;
border-bottom-right-radius: 32px;
}
.inner {
background: #FFFFFF;
border-radius: 24px;
padding: 24px 20px;
}
.badgeIcon {
width: 240px;
height: 240px;
}
.badgeText {
font-weight: 600;
}
.badgeBar {
display: flex;
gap: 3PX;
.badgeBarItem {
width: 80px;
height: 20px;
background-color: #F0F2F9;
border-radius: 16px;
}
.active {
background-color: #FFC056;
}
}
.details {
display: flex;
gap: 32px;
padding: 0 24px;
align-items: center;
}
.detailsRight {
display: flex;
flex-direction: column;
gap: 16px;
justify-content: center;
}
.header {
display: flex;
justify-content: center;
align-items: center;
gap: 8px;
}
.line {
display: flex;
gap: 4PX;
flex-direction: column;
.lineLong, .lineShort {
height: 3PX;
background: #D9E3F3;
border-radius: 2PX;
}
.lineLong {
width: 132px;
}
.lineShort {
width: 32px;
}
}
.gameResult {
display: flex;
flex-direction: column;
gap: 16px;
max-height: 500px;
overflow: auto;
padding-right: 24px;
}
.gameBody {
background-color: #fff;
}
.playerSection {
display: flex;
align-items: center;
position: relative;
.userInfo:first-child {
border-bottom-left-radius: 20px;
}
.userInfo:last-child {
border-bottom-right-radius: 20px;
}
}
.userInfo {
flex: 1;
padding: 24px 30px;
}
.win {
background-color: #E5F4FE;
}
.lose {
background-color: #FEEDED;
}
\ No newline at end of file
import { View, Text, Image } from '@tarojs/components'
import classNames from 'classnames'
import Modal from '@/components/Modal'
import { useStoreState, useStoreActions } from '@/store/hooks'
import assets from '@/assets/oss/assets-pk'
import { badgeImages } from '../const'
import { UserInfo, GameResultProps } from './game-result'
import styles from './battles-modal.module.scss'
import gameResultStyles from './game-result.module.scss'
const BattlesModal = () => {
const isVisible = useStoreState(state => state.battlesModel.modalIsVisible)
const setModalIsVisible = useStoreActions(actions => actions.battlesModel.setModalIsVisible)
const levelInfo = {
name: '关卡',
result: true,
date: '9月22日 12:22',
}
const levelInfo2 = {
name: '关卡名称关卡名称',
result: false,
date: '9月22日 12:22',
}
const players = [
{
name: '用户名称用',
icon: 'string',
level: '青铜Ⅰ',
},
{
name: '用户2',
icon: 'string',
level: '青铜Ⅰ',
},
]
return (
<Modal
isVisible={isVisible}
wrapClassName={styles.modalWrap}
bodyClassName={styles.modalBody}
onClose={() => setModalIsVisible(false)}
tilte={<Text style={{ marginLeft: 10 }}>· PK 战报</Text>}
>
<View className={styles.inner}>
<View className={styles.header}>
<View className={styles.line} style={{ alignItems: 'flex-end' }}>
<Text className={styles.lineLong}></Text>
<Text className={styles.lineShort}></Text>
</View>
<Text>当前段位</Text>
<View className={styles.line}>
<Text className={styles.lineLong}></Text>
<Text className={styles.lineShort}></Text>
</View>
</View>
<View className={styles.details}>
<Image
src={assets[badgeImages.bronze.default].u}
className={styles.badgeIcon}
/>
<View className={styles.detailsRight}>
<Text className={styles.badgeText}>青铜 1</Text>
<View className={styles.badgeBar}>
<Text
className={classNames(styles.badgeBarItem, styles.active)}
></Text>
<Text className={classNames(styles.badgeBarItem)}></Text>
<Text className={classNames(styles.badgeBarItem)}></Text>
</View>
</View>
</View>
<View className={styles.gameResult}>
<GameResult levelInfo={levelInfo} players={players} />
<GameResult levelInfo={levelInfo2} players={players} />
<GameResult levelInfo={levelInfo} players={players} />
<GameResult levelInfo={levelInfo2} players={players} />
<GameResult levelInfo={levelInfo} players={players} />
</View>
</View>
</Modal>
)
}
const GameResult = ({ players, levelInfo }: GameResultProps) => {
return (
<View className={gameResultStyles.gameResult}>
<View
className={classNames(
gameResultStyles.levelInfo,
levelInfo.result ? gameResultStyles.win : gameResultStyles.lose
)}
>
<Text className={gameResultStyles.levelName}>{levelInfo.name}</Text>
<Image
mode="widthFix"
src={levelInfo.result ? assets['win.png'].u : assets['lose.png'].u}
className={gameResultStyles.levelResult}
/>
<Text className={gameResultStyles.levelDate}>{levelInfo.date}</Text>
</View>
<View className={styles.gameBody}>
<View className={styles.playerSection}>
<View className={classNames(styles.userInfo, levelInfo.result ? styles.win : styles.lose)}>
<UserInfo {...players[0]} />
</View>
<Image className={gameResultStyles.vs} src={assets['vs.png'].u} />
<View className={classNames(styles.userInfo, !levelInfo.result ? styles.win : styles.lose)}>
<UserInfo style={{ alignItems: 'flex-end' }} {...players[1]} />
</View>
</View>
</View>
</View>
)
}
export default BattlesModal
...@@ -84,56 +84,57 @@ ...@@ -84,56 +84,57 @@
.gameStats { .gameStats {
display: flex; display: flex;
gap: 12px;
margin-top: 20px; margin-top: 20px;
flex-direction: column;
} }
.statsRow { .stats {
display: flex;
position: relative; position: relative;
justify-content: space-between; display: flex;
flex-direction: column;
flex: 1;
gap: 16px;
.value {
height: 46px; height: 46px;
line-height: 46px; line-height: 46px;
}
.score {
color: #FE4E52;
font-weight: 500;
flex: 1; flex: 1;
font-size: 14PX; font-weight: 500;
text-align: center; text-align: center;
background-color: #FEEDED; font-size: 28px;
} display: flex;
align-items: center;
justify-content: center;
gap: 6px;
}
.label { &:nth-child(2) {
z-index: 2;
position: absolute; position: absolute;
left: 50%; left: 50%;
font-size: 24px;
transform: translateX(-50%); transform: translateX(-50%);
text-align: center;
width: 112px;
.value {
font-size: 24px;
color: #fff;
background: #93A0B7; background: #93A0B7;
border-radius: 24px; border-radius: 24px;
width: 112px; }
text-align: center; }
} }
.value { .statsWin .value {
flex: 1;
font-weight: 500;
text-align: center;
font-size: 28px;
color: #009AFB; color: #009AFB;
background-color: #E5F4FE; background-color: #E5F4FE;
} }
.statsLose .value {
color: #FE4E52;
background-color: #FEEDED;
}
.diamond { .diamond {
width: 30px; width: 30px;
height: 30px; height: 30px;
} }
\ No newline at end of file
.flex {
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
}
\ No newline at end of file
...@@ -7,7 +7,7 @@ import assets2 from '@/assets/oss/assets-prepare' ...@@ -7,7 +7,7 @@ import assets2 from '@/assets/oss/assets-prepare'
import { badgeImages } from '../const' import { badgeImages } from '../const'
import styles from './game-result.module.scss' import styles from './game-result.module.scss'
interface LevelInfo { export interface LevelInfo {
name: string; name: string;
result: boolean; result: boolean;
date: string; date: string;
...@@ -25,7 +25,7 @@ interface Stat { ...@@ -25,7 +25,7 @@ interface Stat {
value: string; value: string;
} }
interface GameResultProps { export interface GameResultProps {
levelInfo: LevelInfo; levelInfo: LevelInfo;
players: Player[]; players: Player[];
gameStats?: Stat[]; gameStats?: Stat[];
...@@ -36,7 +36,7 @@ const GameResult = ({ players, levelInfo }: GameResultProps) => { ...@@ -36,7 +36,7 @@ const GameResult = ({ players, levelInfo }: GameResultProps) => {
<View className={styles.gameResult}> <View className={styles.gameResult}>
<View className={classNames(styles.levelInfo, levelInfo.result ? styles.win : styles.lose)}> <View className={classNames(styles.levelInfo, levelInfo.result ? styles.win : styles.lose)}>
<Text className={styles.levelName}>{levelInfo.name}</Text> <Text className={styles.levelName}>{levelInfo.name}</Text>
<Image mode="widthFix" src={levelInfo.result ? assets['win.png'].u : assets['lose.png'].u} className={styles.levelResult} /> <Image mode="widthFix" src={assets[levelInfo.result ? 'win.png' : 'lose.png'].u} className={styles.levelResult} />
<Text className={styles.levelDate}>{levelInfo.date}</Text> <Text className={styles.levelDate}>{levelInfo.date}</Text>
</View> </View>
...@@ -46,13 +46,13 @@ const GameResult = ({ players, levelInfo }: GameResultProps) => { ...@@ -46,13 +46,13 @@ const GameResult = ({ players, levelInfo }: GameResultProps) => {
<Image className={styles.vs} src={assets['vs.png'].u} /> <Image className={styles.vs} src={assets['vs.png'].u} />
<UserInfo style={{ alignItems: 'flex-end' }} {...players[1]} /> <UserInfo style={{ alignItems: 'flex-end' }} {...players[1]} />
</View> </View>
<GameStats /> <GameStats result={levelInfo.result} />
</View> </View>
</View> </View>
) )
} }
const UserInfo = (player: Player & { style?: CSSProperties }) => ( export const UserInfo = (player: Player & { style?: CSSProperties }) => (
<View style={player.style} className={styles.userInfo}> <View style={player.style} className={styles.userInfo}>
<Text className={styles.userName}>{player.name}</Text> <Text className={styles.userName}>{player.name}</Text>
<View className={styles.userBadge}> <View className={styles.userBadge}>
...@@ -62,30 +62,32 @@ const UserInfo = (player: Player & { style?: CSSProperties }) => ( ...@@ -62,30 +62,32 @@ const UserInfo = (player: Player & { style?: CSSProperties }) => (
</View> </View>
) )
const GameStats = () => ( const GameStats = ({ result }: { result: boolean }) => {
return (
<View className={styles.gameStats}> <View className={styles.gameStats}>
<View className={styles.statsRow}> <View className={classNames(styles.stats, result ? styles.statsWin : styles.statsLose)}>
<Text className={styles.score}>错2题</Text>
<Text className={styles.label}>答题对错</Text>
<Text className={styles.value}>全队</Text> <Text className={styles.value}>全队</Text>
</View> <Text className={styles.value}>13.2s</Text>
<View className={styles.statsRow}> <View className={classNames(styles.value)}>
<Text className={styles.score}>13.2s</Text>
<Text className={styles.label}>答题用时</Text>
<Text className={styles.value}>21.3s</Text>
</View>
<View className={styles.statsRow}>
<View className={classNames(styles.score, styles.flex)}>
<Image className={styles.diamond} src={assets2['diamond.png'].u} /> <Image className={styles.diamond} src={assets2['diamond.png'].u} />
<Text>+10</Text> <Text>+10</Text>
</View> </View>
<Text className={styles.label}>PK奖励</Text> </View>
<View className={classNames(styles.value, styles.flex)}> <View className={classNames(styles.stats)}>
<Text className={styles.value}>答题对错</Text>
<Text className={styles.value}>答题用时</Text>
<Text className={styles.value}>PK奖励</Text>
</View>
<View className={classNames(styles.stats, !result ? styles.statsWin : styles.statsLose)}>
<Text className={styles.value}>错2题</Text>
<Text className={styles.value}>23.2s</Text>
<View className={styles.value}>
<Image className={styles.diamond} src={assets2['diamond.png'].u} /> <Image className={styles.diamond} src={assets2['diamond.png'].u} />
<Text>+5</Text> <Text>+15</Text>
</View> </View>
</View> </View>
</View> </View>
) )
}
export default GameResult export default GameResult
...@@ -5,20 +5,20 @@ ...@@ -5,20 +5,20 @@
align-items: center; align-items: center;
gap: 16px; gap: 16px;
.pkLine { .line {
display: flex; display: flex;
gap: 4PX; gap: 4PX;
flex-direction: column; flex-direction: column;
.pkLineLong, .pkLineShort { .lineLong, .lineShort {
height: 3PX; height: 3PX;
background: #D9E3F3; background: #D9E3F3;
border-radius: 2PX; border-radius: 2PX;
} }
.pkLineLong { .lineLong {
width: 132px; width: 132px;
} }
.pkLineShort { .lineShort {
width: 32px; width: 32px;
} }
} }
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
.bottom { .bottom {
position: fixed; position: fixed;
z-index: 999;
bottom: 0; bottom: 0;
display: flex; display: flex;
align-items: center; align-items: center;
......
...@@ -34,7 +34,7 @@ const players = [ ...@@ -34,7 +34,7 @@ const players = [
} }
] ]
const Pk = () => { const Battles = () => {
const nav = useMemo(getMenuButtonBoundingClientRect, []) const nav = useMemo(getMenuButtonBoundingClientRect, [])
return ( return (
<View style={{ backgroundColor: '#F0F2F9' }}> <View style={{ backgroundColor: '#F0F2F9' }}>
...@@ -43,14 +43,14 @@ const Pk = () => { ...@@ -43,14 +43,14 @@ const Pk = () => {
<PlayerDetails /> <PlayerDetails />
<View className={styles.pk}> <View className={styles.pk}>
<View className={styles.pkLine} style={{ alignItems: 'flex-end' }}> <View className={styles.line} style={{ alignItems: 'flex-end' }}>
<Text className={styles.pkLineLong}></Text> <Text className={styles.lineLong}></Text>
<Text className={styles.pkLineShort}></Text> <Text className={styles.lineShort}></Text>
</View> </View>
<Text className={styles.pkTitle}>PK记录</Text> <Text className={styles.pkTitle}>PK记录</Text>
<View className={styles.pkLine}> <View className={styles.line}>
<Text className={styles.pkLineLong}></Text> <Text className={styles.lineLong}></Text>
<Text className={styles.pkLineShort}></Text> <Text className={styles.lineShort}></Text>
</View> </View>
</View> </View>
...@@ -68,4 +68,4 @@ const Pk = () => { ...@@ -68,4 +68,4 @@ const Pk = () => {
) )
} }
export default Pk export default Battles
import { Action, action } from 'easy-peasy'
interface BattlesModel {
modalIsVisible: boolean;
setModalIsVisible: Action<BattlesModel, boolean>;
}
const battlesModel: BattlesModel = {
modalIsVisible: true,
setModalIsVisible: action((state, payload) => {
state.modalIsVisible = payload
})
}
export default battlesModel
...@@ -9,6 +9,7 @@ import { useMemo, useCallback, useEffect } from 'react' ...@@ -9,6 +9,7 @@ import { useMemo, useCallback, useEffect } from 'react'
import { useStoreActions, useStoreState } from '@/store/hooks' import { useStoreActions, useStoreState } from '@/store/hooks'
import { useFocus } from '@/hooks/use-focus' import { useFocus } from '@/hooks/use-focus'
import { EyeProtectionView } from '@/components' import { EyeProtectionView } from '@/components'
import BattlesModal from '@/pages/battles/components/battles-modal'
import Tutorial from '../components/tutorial' import Tutorial from '../components/tutorial'
import type { TabbarRef } from '../../../custom-tab-bar/index' import type { TabbarRef } from '../../../custom-tab-bar/index'
...@@ -128,6 +129,7 @@ const MainPage = () => { ...@@ -128,6 +129,7 @@ const MainPage = () => {
)} )}
<ShareModal /> <ShareModal />
<Tutorial /> <Tutorial />
<BattlesModal />
</> </>
) )
} }
......
...@@ -2,6 +2,7 @@ import gameModel from '@/pages/game/play/model' ...@@ -2,6 +2,7 @@ import gameModel from '@/pages/game/play/model'
import mainModel from '@/pages/main/model' import mainModel from '@/pages/main/model'
import groupModel from '@/pages/group/model' import groupModel from '@/pages/group/model'
import prepareModel from '@/pages/prepare/model' import prepareModel from '@/pages/prepare/model'
import battlesModel from '@/pages/battles/model'
import userModel from './modules/user' import userModel from './modules/user'
import guideModel from './modules/guide' import guideModel from './modules/guide'
...@@ -11,7 +12,8 @@ const appStoreModel = { ...@@ -11,7 +12,8 @@ const appStoreModel = {
mainModel, mainModel,
userModel, userModel,
groupModel, groupModel,
guideModel guideModel,
battlesModel
} }
export default appStoreModel export default appStoreModel
......
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