Commit cc815f9a authored by hewenhao's avatar hewenhao

feat: update

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