|
@@ -4,10 +4,13 @@
|
|
|
<div
|
|
|
class="child-container bor-radius-8 bg-[#ffffff] w-[1960px] h-[960px] mt-[100px] flex flex-col justify-center items-center gap-y-[30px]"
|
|
|
>
|
|
|
- <div id="myButton" class="absolute top-[350px]">
|
|
|
+ <div id="myButton" class="absolute top-[110px]">
|
|
|
<div class="bg-1" v-if="divShow && !showAdd">
|
|
|
<img :src="onceData.question" alt="question" class="w-[460px] h-[460px]" />
|
|
|
</div>
|
|
|
+ <div class="bg-1" v-if="divShow && !showAdd">
|
|
|
+ <img :src="onceData.questions" alt="question" class="w-[460px] h-[460px]" />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- </div>-->
|
|
@@ -28,6 +31,8 @@ const $emits = defineEmits(['gameOver'])
|
|
|
interface LevelData {
|
|
|
level: number
|
|
|
correct: boolean
|
|
|
+ ifNeedClick: boolean
|
|
|
+ ifUserClick: boolean
|
|
|
score: number
|
|
|
responseStartTime: number
|
|
|
responseEndTime: number
|
|
@@ -35,8 +40,10 @@ interface LevelData {
|
|
|
|
|
|
interface OnceItem {
|
|
|
question: string
|
|
|
+ questions: string
|
|
|
choices: string[]
|
|
|
answer: string
|
|
|
+ answers: string
|
|
|
}
|
|
|
|
|
|
const openDialogRef = ref()
|
|
@@ -49,8 +56,10 @@ const fistOpen = ref(true) // 第一屏
|
|
|
const flage1 = ref(true) // 视觉模式选项
|
|
|
const flage2 = ref(false) // 听觉模式选项
|
|
|
const flage3 = ref(false) // 混合模式选项
|
|
|
-const next_stepFlag1 = ref(false) // 图片游戏开始
|
|
|
-const next_stepFlag2 = ref(false) // 数字模式开始
|
|
|
+const next_stepFlag1 = ref(false) // 视觉游戏开始
|
|
|
+const next_stepFlag2 = ref(false) // 听觉模式开始
|
|
|
+const next_stepFlag3 = ref(false) // 混合模式开始
|
|
|
+
|
|
|
// const next_stepflag = ref(true) // 第二屏
|
|
|
const countDownVal = ref(560) // 倒计时时间
|
|
|
const showAdd = ref(false)
|
|
@@ -80,7 +89,7 @@ const maxNumber = 9
|
|
|
let currentNumber = 0
|
|
|
// 响应开始时间戳
|
|
|
let responseStartTime = 0
|
|
|
-
|
|
|
+let currentLetterList = []
|
|
|
let timerId: any
|
|
|
let divShowInteval: any
|
|
|
let gameStartTime_record = 0
|
|
@@ -88,6 +97,11 @@ let gameStartTime_record = 0
|
|
|
const planInfo = ref<RTPlanMgrQuery>()
|
|
|
const instance = getCurrentInstance()
|
|
|
const userStore = useUserStore()
|
|
|
+function executeMethod() {
|
|
|
+ nextOnce()
|
|
|
+ console.log('执行此方法。')
|
|
|
+ // createCurrentLetterList(onceData.value)
|
|
|
+}
|
|
|
const setTimetiming = () => {
|
|
|
let elapsedSeconds = 0
|
|
|
function startTimer() {
|
|
@@ -97,7 +111,8 @@ const setTimetiming = () => {
|
|
|
// executeMethod()
|
|
|
elapsedSeconds = 0
|
|
|
showAdd.value = true
|
|
|
- nextOnce()
|
|
|
+ // nextOnce()
|
|
|
+ executeMethod()
|
|
|
}
|
|
|
}, 1000)
|
|
|
// if (elapsedSeconds >= 60) {
|
|
@@ -125,14 +140,20 @@ const chengFlagek = () => {
|
|
|
setTimetiming()
|
|
|
next_stepFlag1.value = true
|
|
|
next_stepFlag2.value = false
|
|
|
+ next_stepFlag3.value = false
|
|
|
fistOpen.value = false
|
|
|
countDownVisible.value = true
|
|
|
} else if (flage2.value) {
|
|
|
fistOpen.value = false
|
|
|
next_stepFlag2.value = true
|
|
|
next_stepFlag1.value = false
|
|
|
+ next_stepFlag3.value = false
|
|
|
// countDownVisible.value = true
|
|
|
} else {
|
|
|
+ fistOpen.value = false
|
|
|
+ next_stepFlag2.value = false
|
|
|
+ next_stepFlag1.value = false
|
|
|
+ next_stepFlag3.value = true
|
|
|
}
|
|
|
}
|
|
|
const chengFlage1 = (answer: string) => {
|
|
@@ -225,6 +246,7 @@ const nextOnce = () => {
|
|
|
} else {
|
|
|
// 游戏结束
|
|
|
console.log('游戏结束2')
|
|
|
+ console.log(gameList, '游戏数据')
|
|
|
clearInterval(timerId)
|
|
|
clearInterval(divShowInteval)
|
|
|
// sendData()
|
|
@@ -268,46 +290,52 @@ const setOnceData = () => {
|
|
|
responseStartTime = performance.now()
|
|
|
// console.log(currentNumber, 'currentNumber')
|
|
|
onceData.value = gameData.value[currentLevel][currentNumber]
|
|
|
- // timerId = setInterval(() => {
|
|
|
- // elapsedSeconds++
|
|
|
- // if (elapsedSeconds > 3) {
|
|
|
- // executeMethod()
|
|
|
- // elapsedSeconds = 0
|
|
|
- // }
|
|
|
- // }, 1000)
|
|
|
- // divShow.value = true
|
|
|
- //
|
|
|
- // divShowInteval = setInterval(() => {
|
|
|
- // showAdd.value = true
|
|
|
- // nextOnce()
|
|
|
- // }, 2000)
|
|
|
- // onceData.value.choices = shuffleArray(onceData.value.choices)
|
|
|
+ console.log(currentLevel, '当前游戏等级')
|
|
|
+ if (currentLevel == 0) {
|
|
|
+ gameList.push({
|
|
|
+ level: currentLevel,
|
|
|
+ correct: false,
|
|
|
+ score: 0,
|
|
|
+ ifNeedClick: gameData.value[currentLevel][0].answer === onceData.value.question,
|
|
|
+ ifUserClick: false,
|
|
|
+ responseEndTime: performance.now(),
|
|
|
+ responseStartTime: responseStartTime
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-const handleClick = (answer: string) => {
|
|
|
- const correct = onceData.value.answer === answer
|
|
|
- VoiceImpRef.value.videoPlay('click')
|
|
|
- setTimeout(() => {
|
|
|
- if (correct) {
|
|
|
- console.log(VoiceImpRef.value, 'hbbbbbbbbbbbbbbbbbbbbbbbbbdf=============>')
|
|
|
-
|
|
|
- VoiceImpRef.value.videoPlay('right')
|
|
|
- } else {
|
|
|
- VoiceImpRef.value.videoPlay('error')
|
|
|
- }
|
|
|
- }, 200)
|
|
|
- // 收集当前试次的用户操作数据
|
|
|
- gameList.push({
|
|
|
- level: currentLevel,
|
|
|
- correct: correct,
|
|
|
- score: correct ? scoreList[currentLevel] : 0,
|
|
|
- responseEndTime: performance.now(),
|
|
|
- responseStartTime: responseStartTime
|
|
|
- })
|
|
|
- console.log(gameList)
|
|
|
-
|
|
|
- // 开始下一次
|
|
|
- nextOnce()
|
|
|
+const handleKeyDown = (event: any) => {
|
|
|
+ console.log(event.button, '判断鼠标点击左键还是右键')
|
|
|
+ console.log(event.key, '判断鼠标点j还是f')
|
|
|
+ console.log(currentNumber, '当前试次', gameList, gameList[currentNumber])
|
|
|
+ if (event.key == 'f') {
|
|
|
+ gameList[currentNumber].ifUserClick = true
|
|
|
+ }
|
|
|
+ if (gameList[currentNumber].ifUserClick === gameList[currentNumber].ifNeedClick) {
|
|
|
+ gameList[currentNumber].correct = true
|
|
|
+ }
|
|
|
+ // }
|
|
|
+ // // VoiceImpRef.value.videoPlay('click')
|
|
|
+ // // setTimeout(() => {
|
|
|
+ // // if (correct) {
|
|
|
+ // // console.log(VoiceImpRef.value, 'hbbbbbbbbbbbbbbbbbbbbbbbbbdf=============>')
|
|
|
+ // //
|
|
|
+ // // VoiceImpRef.value.videoPlay('right')
|
|
|
+ // // } else {
|
|
|
+ // // VoiceImpRef.value.videoPlay('error')
|
|
|
+ // // }
|
|
|
+ // // }, 200)
|
|
|
+ // // 收集当前试次的用户操作数据
|
|
|
+ // // gameList.push({
|
|
|
+ // // level: currentLevel,
|
|
|
+ // // correct: correct,
|
|
|
+ // // score: correct ? scoreList[currentLevel] : 0,
|
|
|
+ // // responseEndTime: performance.now(),
|
|
|
+ // // responseStartTime: responseStartTime
|
|
|
+ // // })
|
|
|
+ // // 开始下一次
|
|
|
+ // // nextOnce()
|
|
|
+ // console.log(gameList, '当前试次用户操作数据')
|
|
|
}
|
|
|
|
|
|
// 发送请求
|
|
@@ -423,15 +451,9 @@ async function exec() {
|
|
|
onMounted(() => {
|
|
|
exec()
|
|
|
nextTick(() => {
|
|
|
+ window.addEventListener('keydown', handleKeyDown)
|
|
|
countDownVisible.value = true
|
|
|
setTimetiming()
|
|
|
- // console.log(onceData.value.choices, 'onceData392')
|
|
|
- // onceData.value = shuffleArray(onceData.value)
|
|
|
- // onceData.value.choices = shuffleArray(onceData.value.choices)
|
|
|
- // countDownVisible.value = true
|
|
|
- // 倒计时
|
|
|
- // getTime()
|
|
|
- // setTimetiming()
|
|
|
})
|
|
|
})
|
|
|
watchEffect(() => {
|
|
@@ -441,6 +463,7 @@ watchEffect(() => {
|
|
|
onUnmounted(() => {
|
|
|
clearInterval(timerId)
|
|
|
})
|
|
|
+// 添加键盘事件监听
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|