Commit cc815f9a authored by hewenhao's avatar hewenhao

feat: update

parent 165d1ca6
...@@ -19,9 +19,11 @@ const randomPick = (arr: string[]) => { ...@@ -19,9 +19,11 @@ const randomPick = (arr: string[]) => {
const ModalName = ({ const ModalName = ({
isVisible, isVisible,
onClose, onClose,
onFinish,
}: { }: {
isVisible: boolean isVisible: boolean
onClose: () => void onClose: () => void;
onFinish: () => void;
}) => { }) => {
const [name, setName] = useState('小明') const [name, setName] = useState('小明')
const [generating, { setTrue, setFalse }] = useBoolean(false) const [generating, { setTrue, setFalse }] = useBoolean(false)
...@@ -90,6 +92,7 @@ const ModalName = ({ ...@@ -90,6 +92,7 @@ const ModalName = ({
size="large" size="large"
image={styles.footerButton} image={styles.footerButton}
hoverImage={styles.footerHoverButton} hoverImage={styles.footerHoverButton}
onClick={onFinish}
> >
确定 确定
</Button> </Button>
......
import { useDidShow, useRouter } from '@tarojs/taro' import { useDidShow, useRouter, navigateTo } from '@tarojs/taro'
import { View, Image, Text } from '@tarojs/components' import { View, Image, Text } from '@tarojs/components'
import { useBoolean } from '@/hooks' import { useBoolean } from '@/hooks'
import { useStoreState, useStoreActions } from '@/store/hooks' import { useStoreState, useStoreActions } from '@/store/hooks'
...@@ -14,6 +14,8 @@ const AcceptPk = () => { ...@@ -14,6 +14,8 @@ const AcceptPk = () => {
const router = useRouter<{ initiator?: string; stageId?: string }>() const router = useRouter<{ initiator?: string; stageId?: string }>()
const details = useStoreState((state) => state.battlesModel.details) const details = useStoreState((state) => state.battlesModel.details)
const userInfo = useStoreState((state) => state.userModel.userInfo)
const fetchUserDetails = useStoreActions( const fetchUserDetails = useStoreActions(
(actions) => actions.battlesModel.fetchUserDetails (actions) => actions.battlesModel.fetchUserDetails
) )
...@@ -27,6 +29,20 @@ const AcceptPk = () => { ...@@ -27,6 +29,20 @@ const AcceptPk = () => {
} }
}) })
const toGame = () => {
navigateTo({
url: `/pages/game/play/index?id=${router.params.stageId}`
})
}
const handleClick = () => {
if (!userInfo.nickName) {
setTrue()
} else {
toGame()
}
}
return ( return (
<View className={styles.container}> <View className={styles.container}>
<TopHeader /> <TopHeader />
...@@ -94,13 +110,13 @@ const AcceptPk = () => { ...@@ -94,13 +110,13 @@ const AcceptPk = () => {
<View className={styles.bottom}> <View className={styles.bottom}>
<Image <Image
className={styles.clickImage} className={styles.clickImage}
onClick={setTrue} onClick={handleClick}
src={assetsPk['accept-click.png'].u} src={assetsPk['accept-click.png'].u}
/> />
</View> </View>
</View> </View>
<ModalName isVisible={isVisible} onClose={setFalse} /> <ModalName isVisible={isVisible} onClose={setFalse} onFinish={toGame} />
</View> </View>
) )
} }
......
...@@ -23,7 +23,7 @@ const CountUp = (props: CountUpProps) => { ...@@ -23,7 +23,7 @@ const CountUp = (props: CountUpProps) => {
const questionList = useStoreState(state => state.gameModel.questionList) const questionList = useStoreState(state => state.gameModel.questionList)
const isSubmit = useStoreState(state => state.gameModel.isSubmit) const isSubmit = useStoreState(state => state.gameModel.isSubmit)
const submit = useStoreActions(actions => actions.gameModel.submit) const submit = useStoreActions(actions => actions.gameModel.submit)
const pkDetail = useStoreState(state => state.gameModel.pkDetail) const pkDetail = useStoreState(state => state.battlesModel.details)
const [isExceed, exceedActions] = useBoolean(false) const [isExceed, exceedActions] = useBoolean(false)
const [isStarted, startActions] = useBoolean(false) const [isStarted, startActions] = useBoolean(false)
......
...@@ -35,7 +35,6 @@ const stopCounter = () => getCounter()?.stop() ...@@ -35,7 +35,6 @@ const stopCounter = () => getCounter()?.stop()
const startCounter = () => getCounter()?.start() const startCounter = () => getCounter()?.start()
const gameModel: GameModel = { const gameModel: GameModel = {
pkDetail: null,
counterId: COUNTER_ID, counterId: COUNTER_ID,
questionList: [], questionList: [],
errList: [], errList: [],
...@@ -59,13 +58,6 @@ const gameModel: GameModel = { ...@@ -59,13 +58,6 @@ const gameModel: GameModel = {
upGear: true upGear: true
}, },
getPkDetail: thunk(async (actions, payload) => {
try {
const { data } = await fetchUserDetails(payload)
actions.updateState({ pkDetail: data })
} catch (err) {}
}),
bornTimes: 3, bornTimes: 3,
modalContinueVisible: false, modalContinueVisible: false,
gameStartTime: 0, gameStartTime: 0,
......
...@@ -2,7 +2,7 @@ import { Action, Computed, Thunk } from 'easy-peasy' ...@@ -2,7 +2,7 @@ import { Action, Computed, Thunk } from 'easy-peasy'
import { AppStoreModel } from '@/store/store-model' import { AppStoreModel } from '@/store/store-model'
import { import {
type StageDetail, type StageDetail,
type CompleteStageOut, PkDetails type CompleteStageOut
} from '@/api' } from '@/api'
import { import {
QuestionType, QuestionType,
...@@ -39,8 +39,6 @@ export interface GameModelState { ...@@ -39,8 +39,6 @@ export interface GameModelState {
counterId: string; counterId: string;
rightIcon: string | null; rightIcon: string | null;
pkDetail: PkDetails | null;
} }
export interface GameModel extends GameModelState { export interface GameModel extends GameModelState {
...@@ -71,6 +69,4 @@ export interface GameModel extends GameModelState { ...@@ -71,6 +69,4 @@ export interface GameModel extends GameModelState {
submit: Thunk<GameModel, void, void, AppStoreModel>; submit: Thunk<GameModel, void, void, AppStoreModel>;
reborn: Thunk<GameModel, void, void, AppStoreModel>; reborn: Thunk<GameModel, void, void, AppStoreModel>;
getPkDetail: Thunk<GameModel, { userId: number; stageId: number }, void, AppStoreModel>;
} }
...@@ -131,7 +131,7 @@ const Prepare = () => { ...@@ -131,7 +131,7 @@ const Prepare = () => {
getQuestionList(+router.params.id || 1).then(() => { getQuestionList(+router.params.id || 1).then(() => {
isClickRef.current = false isClickRef.current = false
navigateTo({ navigateTo({
url: `/pages/game/play/index?id=${router.params.id}&isBattle=true&initiatorTime=30` url: `/pages/game/play/index?id=${router.params.id}`
}) })
}) })
} }
......
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