formal.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805
  1. <template>
  2. <div class="content-container">
  3. <div class="content-outline" v-if="!running">
  4. <div class="left_part">
  5. <div id="left_top" class="flex-row">
  6. <el-image class="setting" :src="require('@/assets/9551.png')" fit="cover" />
  7. <div class="text"> 操作提示:</div>
  8. </div>
  9. <div class="left-desc-80">
  10. {{ practiceFlag ? '请先练习测试,练习完成后,即将正式测试。' : '请开始正式测试!' }}
  11. </div>
  12. </div>
  13. <div
  14. class="right_part"
  15. :style="{
  16. background:
  17. 'url(' + require('../../../assets/page' + taskId + '.png') + ')',
  18. 'background-size': '100% 100%',
  19. }"
  20. >
  21. <div id="title">
  22. <span>{{ subjectInfo.name }}</span>
  23. </div>
  24. <div
  25. style="
  26. position: absolute;
  27. bottom: 0.156rem;
  28. left: 50%;
  29. transform: translateX(-50%);
  30. "
  31. >
  32. <el-button type="primary" class="start" @click="startTest()">
  33. {{ practiceFlag ? '练习测试' : '正式测试' }}
  34. </el-button>
  35. </div>
  36. </div>
  37. </div>
  38. <div v-if="running" class="activeTask" >
  39. <MainProgress v-if="!practiceFlag" :cur-percentage="(currentIndex / collectedDataArray.length)" />
  40. <div class="taskHead">
  41. <div class="scale" @click.stop="screen">
  42. <img src="@/assets/small-big.png" alt="" />
  43. </div>
  44. </div>
  45. <div id="game">
  46. <img v-if="showPic" ref="missile" id="missile" :src="collectedDataArray[currentIndex].leftImg" alt="" draggable="false">
  47. <img v-if="showPic" ref="compass" id="compass" :src="collectedDataArray[currentIndex].rightImg" alt="" draggable="false">
  48. </div>
  49. <div id="tip" v-if="false">
  50. <img id="arrow" v-if="currentArrowImg" :src="currentArrowImg" alt="">
  51. </div>
  52. </div>
  53. <!-- <pre>{{ practiceMaps }}</pre>-->
  54. <go-back />
  55. </div>
  56. </template>
  57. <script>
  58. import screenfull from "screenfull";
  59. import { oSessionStorage, dateFormat } from "@/utils/utils";
  60. import GoBack from "@/components/goBack/index.vue"
  61. import MainProgress from "@/components/MainProgress/index.vue"
  62. import { generateRandomRangeNumbers } from "../../../utils/utils";
  63. export default {
  64. name: "prospectiveMemoryAbility",
  65. components: { GoBack, MainProgress },
  66. data() {
  67. return {
  68. subjectInfo: "", //认知任务详情
  69. taskId: "", // 认知任务id
  70. userId: '',
  71. disabled: true, // 是否处于注视点时长内,如果是,在不响应任何按键
  72. running: false, // 游戏是否开始
  73. practiceFlag: true, // 是否处于练习模式,默认是练习模式
  74. currentIndex: 0,
  75. selectedDirection: '', // 用户选择的方向,left 或 right
  76. selectedKey: '', // 用户当前选择的按键,用于阻止重复选择
  77. pseudoRandomArray: [
  78. // 伪随机数组,前72个是主任务,后8个是前瞻性任务
  79. // 第1-12个是左键-A键, 第13-24个是左键-S键, 第25-36个是左键-D键, 第37-48个是右键-A键, 第49-60个是右键-S键, 第61-72个是右键-D键, 第73-80个是空格键
  80. { index: 0, missile: 'm1s0', compass: 'tjq3dc', taskType: '1' },
  81. { index: 1, missile: 'm1s1', compass: 'tjq3dc', taskType: '1' },
  82. { index: 2, missile: 'm1s2', compass: 'tjq3dc', taskType: '1' },
  83. { index: 3, missile: 'm2s0', compass: 'tjq3dc', taskType: '1' },
  84. { index: 4, missile: 'm2s1', compass: 'tjq3dc', taskType: '1' },
  85. { index: 5, missile: 'm2s2', compass: 'tjq3dc', taskType: '1' },
  86. { index: 6, missile: 'm1s0', compass: 'tjq2dc', taskType: '1' },
  87. { index: 7, missile: 'm1s1', compass: 'tjq2dc', taskType: '1' },
  88. { index: 8, missile: 'm1s2', compass: 'tjq2dc', taskType: '1' },
  89. { index: 9, missile: 'm2s0', compass: 'tjq2dc', taskType: '1' },
  90. { index: 10, missile: 'm2s1', compass: 'tjq2dc', taskType: '1' },
  91. { index: 11, missile: 'm2s2', compass: 'tjq2dc', taskType: '1' },
  92. { index: 12, missile: 'm1s0', compass: 'tjq1dc', taskType: '1' },
  93. { index: 13, missile: 'm1s1', compass: 'tjq1dc', taskType: '1' },
  94. { index: 14, missile: 'm1s2', compass: 'tjq1dc', taskType: '1' },
  95. { index: 15, missile: 'm2s0', compass: 'tjq1dc', taskType: '1' },
  96. { index: 16, missile: 'm2s1', compass: 'tjq1dc', taskType: '1' },
  97. { index: 17, missile: 'm2s2', compass: 'tjq1dc', taskType: '1' },
  98. { index: 18, missile: 'm1s0', compass: 'tjq4dc', taskType: '1' },
  99. { index: 19, missile: 'm1s1', compass: 'tjq4dc', taskType: '1' },
  100. { index: 20, missile: 'm1s2', compass: 'tjq4dc', taskType: '1' },
  101. { index: 21, missile: 'm2s0', compass: 'tjq4dc', taskType: '1' },
  102. { index: 22, missile: 'm2s1', compass: 'tjq4dc', taskType: '1' },
  103. { index: 23, missile: 'm2s2', compass: 'tjq4dc', taskType: '1' },
  104. { index: 24, missile: 'm0s1', compass: 'tjq3di', taskType: '1' },
  105. { index: 25, missile: 'm1s1', compass: 'tjq3di', taskType: '1' },
  106. { index: 26, missile: 'm2s1', compass: 'tjq3di', taskType: '1' },
  107. { index: 27, missile: 'm0s2', compass: 'tjq3di', taskType: '1' },
  108. { index: 28, missile: 'm1s2', compass: 'tjq3di', taskType: '1' },
  109. { index: 29, missile: 'm2s2', compass: 'tjq3di', taskType: '1' },
  110. { index: 30, missile: 'm0s1', compass: 'tjq2di', taskType: '1' },
  111. { index: 31, missile: 'm1s1', compass: 'tjq2di', taskType: '1' },
  112. { index: 32, missile: 'm2s1', compass: 'tjq2di', taskType: '1' },
  113. { index: 33, missile: 'm0s2', compass: 'tjq2di', taskType: '1' },
  114. { index: 34, missile: 'm1s2', compass: 'tjq2di', taskType: '1' },
  115. { index: 35, missile: 'm2s2', compass: 'tjq2di', taskType: '1' },
  116. { index: 36, missile: 'm0s1', compass: 'tjq1di', taskType: '1' },
  117. { index: 37, missile: 'm1s1', compass: 'tjq1di', taskType: '1' },
  118. { index: 38, missile: 'm2s1', compass: 'tjq1di', taskType: '1' },
  119. { index: 39, missile: 'm0s2', compass: 'tjq1di', taskType: '1' },
  120. { index: 40, missile: 'm1s2', compass: 'tjq1di', taskType: '1' },
  121. { index: 41, missile: 'm2s2', compass: 'tjq1di', taskType: '1' },
  122. { index: 42, missile: 'm0s1', compass: 'tjq4di', taskType: '1' },
  123. { index: 43, missile: 'm1s1', compass: 'tjq4di', taskType: '1' },
  124. { index: 44, missile: 'm2s1', compass: 'tjq4di', taskType: '1' },
  125. { index: 45, missile: 'm0s2', compass: 'tjq4di', taskType: '1' },
  126. { index: 46, missile: 'm1s2', compass: 'tjq4di', taskType: '1' },
  127. { index: 47, missile: 'm2s2', compass: 'tjq4di', taskType: '1' },
  128. { index: 48, missile: 'm0s0', compass: 'tyq2di', taskType: '1' },
  129. { index: 49, missile: 'm0s1', compass: 'tyq3di', taskType: '1' },
  130. { index: 50, missile: 'm0s2', compass: 'tyq2dc', taskType: '1' },
  131. { index: 51, missile: 'm1s0', compass: 'tyq3dc', taskType: '1' },
  132. { index: 52, missile: 'm1s1', compass: 'tyq2do', taskType: '1' },
  133. { index: 53, missile: 'm1s2', compass: 'tyq3do', taskType: '1' },
  134. { index: 54, missile: 'm2s0', compass: 'tyq2di', taskType: '1' },
  135. { index: 55, missile: 'm2s1', compass: 'tyq3di', taskType: '1' },
  136. { index: 56, missile: 'm2s2', compass: 'tyq2dc', taskType: '1' },
  137. { index: 57, missile: 'm0s1', compass: 'tyq3dc', taskType: '1' },
  138. { index: 58, missile: 'm1s2', compass: 'tyq2do', taskType: '1' },
  139. { index: 59, missile: 'm2s0', compass: 'tyq3do', taskType: '1' },
  140. { index: 60, missile: 'm0s0', compass: 'tyq1di', taskType: '1' },
  141. { index: 61, missile: 'm0s1', compass: 'tyq4di', taskType: '1' },
  142. { index: 62, missile: 'm0s2', compass: 'tyq1dc', taskType: '1' },
  143. { index: 63, missile: 'm1s0', compass: 'tyq4dc', taskType: '1' },
  144. { index: 64, missile: 'm1s1', compass: 'tyq1do', taskType: '1' },
  145. { index: 65, missile: 'm1s2', compass: 'tyq4do', taskType: '1' },
  146. { index: 66, missile: 'm2s0', compass: 'tyq1di', taskType: '1' },
  147. { index: 67, missile: 'm2s1', compass: 'tyq4di', taskType: '1' },
  148. { index: 68, missile: 'm2s2', compass: 'tyq1dc', taskType: '1' },
  149. { index: 69, missile: 'm0s1', compass: 'tyq4dc', taskType: '1' },
  150. { index: 70, missile: 'm1s2', compass: 'tyq1do', taskType: '1' },
  151. { index: 71, missile: 'm2s0', compass: 'tyq4do', taskType: '1' },
  152. { index: 72, missile: 'm2s1', compass: 'tnq1di', taskType: '2' },
  153. { index: 73, missile: 'm2s2', compass: 'tnq2dc', taskType: '2' },
  154. { index: 74, missile: 'm0s1', compass: 'tnq3do', taskType: '2' },
  155. { index: 75, missile: 'm1s2', compass: 'tnq4dc', taskType: '2' },
  156. { index: 76, missile: 'm1s0', compass: 'tjq1do', taskType: '2' },
  157. { index: 77, missile: 'm0s1', compass: 'tjq2dc', taskType: '2' },
  158. { index: 78, missile: 'm1s2', compass: 'tjq3do', taskType: '2' },
  159. { index: 79, missile: 'm0s0', compass: 'tjq4di', taskType: '2' }
  160. ],
  161. currentMap: null,
  162. collectedDataArray: [
  163. // {
  164. // id: 1,
  165. // name: '1',
  166. // startTime: '',
  167. // missile: '',
  168. // compass: '',
  169. // taskType: '1', // 1 主任务,2 前瞻性任务
  170. // mainTaskDirectionReactionTime: '', // 主任务的方向选择反应时间
  171. // mainTaskMissileReactionTime: '', // 主任务的挂载反应时间
  172. // mainTaskDirectionCorrection: '', // 主任务的方向选择是否正确
  173. // mainTaskMissileCorrection: '', // 主任务的挂载选择是否正确
  174. // prospectiveTaskReactionTime: '', // 主任务的反应时间
  175. // prospectiveTaskCorrection: '', // 主任务的反应是否正确
  176. // }
  177. ],
  178. collectedData: null,
  179. directionKey: '',
  180. missileKey: '',
  181. prospectiveKey: '',
  182. taskStartTime: 0, // 任务开始时间
  183. taskEndTime: 0, // 任务结束时间
  184. showPic: false,
  185. showCurrentMissile: false, // 隐藏图片
  186. showCurrentCompass: false // 隐藏图片
  187. };
  188. },
  189. computed: { },
  190. created() {
  191. this.taskId = this.$route.query.taskId;
  192. this.subjectInfo = JSON.parse(oSessionStorage.getItem("subjectInfo"));
  193. this.userId = sessionStorage.getItem("b80bb7740288fda1f201890375a60c8f");
  194. this.createData()
  195. },
  196. watch: { },
  197. methods: {
  198. screen() {
  199. screenfull.toggle()
  200. },
  201. createData() {
  202. this.pseudoRandomArray = this.pseudoRandomArray.map((item, index) => {
  203. let newItem = {
  204. id: 1,
  205. leftImg: `/static/flying/${item.missile}.png`,
  206. rightImg: `/static/flying/${item.compass}.png`,
  207. startTime: '', // 本局开始时间
  208. endTime: '', // 本局结束时间
  209. onceStartTime: '',
  210. onceEndTime: '',
  211. mainTaskDirectionReactionTime: '', // 主任务的方向选择反应时间
  212. mainTaskDirectionCorrection: '', // 主任务的方向选择是否正确
  213. mainTaskDirectionStartTime: '', // 主任务方向选择的开始时间
  214. mainTaskDirectionEndTime: '', // 主任务方向选择的结束时间
  215. mainTaskDirectionCorrectionResponse: '', // 主任务方向正确反应 ['ArrowLeft' | 'ArrowRight' | '']
  216. mainTaskDirectionActualResponse: '', // 主任务方向实际反应 ['ArrowLeft' | 'ArrowRight' | '其他任意按键' | '']
  217. mainTaskMissileReactionTime: '', // 主任务的挂载反应时间
  218. mainTaskMissileCorrection: '', // 主任务的挂载选择是否正确
  219. mainTaskMissileStartTime: '', // 主任务武器选择的开始时间
  220. mainTaskMissileEndTime: '', // 主任务武器选择的结束时间
  221. mainTaskMissileCorrectionResponse: '', // 主任务挂载正确反应 ['KeyA' | 'KeyS' | 'KeyD' | '']
  222. mainTaskMissileActualResponse: '', // 主任务挂载实际反应 ['KeyA' | 'KeyS' | 'KeyD' | '其他任意按键' | '']
  223. prospectiveTaskReactionTime: '', // 前瞻性记忆任务的反应时间
  224. prospectiveTaskCorrection: '', // 前瞻性记忆任务的反应是否正确
  225. prospectiveTaskStartTime: '', // 前瞻性记忆任务反应的开始时间
  226. prospectiveTaskEndTime: '', // 前瞻性记忆任务反应的结束时间
  227. prospectiveTaskCorrectionResponse: '', // 前瞻性记忆任务正确反应 ['Space' | '']
  228. prospectiveTaskActualResponse: '', // 前瞻性记忆任务实际反应 ['Space' | 'ArrowLeft' | 'ArrowRight' | '其他任意按键' | '']
  229. }
  230. // 第1-12个是左键-A键,
  231. // 第13-24个是右键-A键,
  232. // 第25-36个是左键-S键,
  233. // 第37-48个是右键-S键,
  234. // 第49-60个是左键-D键,
  235. // 第61-72个是右键-D键,
  236. // 第73-80个是空格键
  237. if(index < 12) {
  238. newItem.mainTaskDirectionCorrectionResponse = 'ArrowLeft'
  239. newItem.mainTaskMissileCorrectionResponse = 'KeyA'
  240. } else if (index >= 12 && index < 24) {
  241. newItem.mainTaskDirectionCorrectionResponse = 'ArrowRight'
  242. newItem.mainTaskMissileCorrectionResponse = 'KeyA'
  243. } else if (index >= 24 && index < 36) {
  244. newItem.mainTaskDirectionCorrectionResponse = 'ArrowLeft'
  245. newItem.mainTaskMissileCorrectionResponse = 'KeyS'
  246. } else if(index >= 36 && index < 48) {
  247. newItem.mainTaskDirectionCorrectionResponse = 'ArrowRight'
  248. newItem.mainTaskMissileCorrectionResponse = 'KeyS'
  249. } else if (index >= 48 && index < 60) {
  250. newItem.mainTaskDirectionCorrectionResponse = 'ArrowLeft'
  251. newItem.mainTaskMissileCorrectionResponse = 'KeyD'
  252. } else if (index >= 60 && index < 72) {
  253. newItem.mainTaskDirectionCorrectionResponse = 'ArrowRight'
  254. newItem.mainTaskMissileCorrectionResponse = 'KeyD'
  255. } else {
  256. newItem.prospectiveTaskCorrectionResponse = 'Space'
  257. }
  258. return { ...item, ...newItem }
  259. })
  260. },
  261. startTest() {
  262. // 进入全屏
  263. this.currentIndex = 0
  264. this.running = true
  265. this.screen()
  266. if (this.practiceFlag) {
  267. let tempArray = generateRandomRangeNumbers(1, 72, 6)
  268. this.collectedDataArray = tempArray.map(index => {
  269. return this.pseudoRandomArray[index - 1]
  270. })
  271. let tempArray_1 = generateRandomRangeNumbers(72, 80, 1)
  272. this.collectedDataArray.push(this.pseudoRandomArray[tempArray_1[0] - 1])
  273. } else {
  274. this.taskStartTime = Date.now()
  275. this.collectedDataArray = this.pseudoRandomArray
  276. }
  277. console.log('this.collectedDataArray: ', this.collectedDataArray)
  278. this.collectedDataArray = this.collectedDataArray.sort(() => Math.random() - 0.5)
  279. this.next()
  280. },
  281. next() {
  282. if (this.currentIndex < this.collectedDataArray.length) {
  283. console.log(' ------------------------------------------ ')
  284. console.log(' ---- current: ', this.collectedDataArray[this.currentIndex])
  285. console.log(' ------------------------------------------ ')
  286. setTimeout(() => {
  287. // 注视点时长300-500之间
  288. setTimeout(() => this.disabled = false, Math.floor(Math.random() * 200 + 300))
  289. this.collectedDataArray[this.currentIndex].startTime = performance.now()
  290. this.collectedDataArray[this.currentIndex].onceStartTime = Date.now()
  291. this.collectedDataArray[this.currentIndex].mainTaskDirectionStartTime = performance.now()
  292. this.collectedDataArray[this.currentIndex].mainTaskMissileStartTime = performance.now()
  293. this.collectedDataArray[this.currentIndex].prospectiveTaskStartTime = performance.now()
  294. this.showPic = true
  295. }, 240) // 空屏 500 毫秒
  296. this.disabled = true // 开启注视点时长控制
  297. } else {
  298. // 结束游戏
  299. if (this.practiceFlag) {
  300. // 游戏结束时,如果是练习模式,则不发送数据,,,并且
  301. this.running = false // 退出游戏
  302. this.screen() // 退出全屏
  303. this.collectedDataArray = [] // 清理数据
  304. // 否则进入正式测试模式
  305. this.practiceFlag = false // 将练习标识改成 false,下次开始游戏时,则为正式测试
  306. } else {
  307. // 如果不是测试模式,则发送,发送完成后,退出游戏,退出全屏,清理数据
  308. this.sendCollectedData()
  309. }
  310. }
  311. },
  312. sendCollectedData() {
  313. // 计算各种反应时间,单位秒,保留两位小数
  314. const result = this.collectedDataArray.map(data => {
  315. return {
  316. ...data,
  317. startTime: dateFormat("YY-mm-dd HH:MM:SS", new Date(data.onceStartTime)),
  318. endTime: dateFormat("YY-mm-dd HH:MM:SS", new Date(data.onceEndTime)),
  319. onceStartTime: dateFormat("YY-mm-dd HH:MM:SS", new Date(data.onceStartTime)),
  320. onceEndTime: dateFormat("YY-mm-dd HH:MM:SS", new Date(data.onceEndTime)),
  321. responseTime: (data.endTime - data.startTime).toFixed(2),
  322. }
  323. })
  324. // 计算各种成绩和准确率
  325. const {
  326. prospectiveTaskScore,
  327. prospectiveTaskCount,
  328. prospectiveTaskRight,
  329. mainTaskDirectionScore,
  330. mainTaskDirectionCount,
  331. mainTaskDirectionRight,
  332. mainTaskMissileScore,
  333. mainTaskMissileCount,
  334. mainTaskMissileRight
  335. } = result.reduce((obj, task) => {
  336. if (task.taskType === '1') {
  337. if (task.mainTaskDirectionCorrection === '1') {
  338. obj.mainTaskDirectionScore++
  339. obj.mainTaskDirectionRight++
  340. }
  341. obj.mainTaskDirectionCount++
  342. if (task.mainTaskDirectionCorrection === '1') {
  343. obj.mainTaskMissileScore++
  344. obj.mainTaskMissileRight++
  345. }
  346. obj.mainTaskMissileCount++
  347. } else {
  348. if (task.prospectiveTaskCorrection === '1') {
  349. obj.prospectiveTaskScore++
  350. obj.prospectiveTaskRight++
  351. }
  352. obj.prospectiveTaskCount++
  353. }
  354. return obj
  355. }, {
  356. prospectiveTaskScore: 0, // 前瞻性任务成绩
  357. prospectiveTaskCount: 0, // 前瞻性任务数量
  358. prospectiveTaskRight: 0, // 前瞻性任务正确数量
  359. mainTaskDirectionScore: 0, // 主任务方向选择成绩
  360. mainTaskDirectionCount: 0, // 主任务方向选择数量
  361. mainTaskDirectionRight: 0, // 主任务方向选择正确数量
  362. mainTaskMissileScore: 0, // 主任务子弹选择成绩
  363. mainTaskMissileCount: 0, // 主任务子弹选择数量
  364. mainTaskMissileRight: 0, // 主任务子弹选择正确数量
  365. })
  366. const prospectiveTaskAccuracy = (prospectiveTaskRight / prospectiveTaskCount).toFixed(4)
  367. const mainTaskDirectionAccuracy = (mainTaskDirectionRight / mainTaskDirectionCount).toFixed(4)
  368. const mainTaskMissileAccuracy = (mainTaskMissileRight / mainTaskMissileCount).toFixed(4)
  369. this.taskEndTime = Date.now()
  370. console.log('xxx前瞻性记忆任务:', this.taskEndTime - this.taskStartTime + 'ms');
  371. const data = {
  372. userId: this.userId,
  373. testPlanId: this.$route.query.testPlanId || '',
  374. prospectiveTaskScore, // 前瞻性任务成绩
  375. prospectiveTaskAccuracy, // 前瞻性任务平均准确率
  376. mainTaskDirectionScore, // 主任务方向选择成绩
  377. mainTaskDirectionAccuracy, // 主任务方向选择平均准确率
  378. mainTaskMissileScore, // 主任务子弹选择成绩
  379. mainTaskMissileAccuracy, // 主任务子弹选择准确率
  380. result,
  381. taskStartTime: dateFormat("YY-mm-dd HH:MM:SS", new Date(this.taskStartTime)),
  382. taskEndTime: dateFormat("YY-mm-dd HH:MM:SS", new Date(this.taskEndTime)),
  383. }
  384. console.log(' ------ 前瞻性任务提交数据:', data)
  385. console.log(' ------ 前瞻性任务提交数据:', data.result.filter(item => item.taskType === '1').length)
  386. if (
  387. sessionStorage.getItem("b80bb7740288fda1f201890375a60c8f") === "" ||
  388. sessionStorage.getItem("b80bb7740288fda1f201890375a60c8f") == null
  389. ) {
  390. alert("请先登录!");
  391. return;
  392. } else {
  393. this.$http.post("/cognize/ProspectiveMemory", data, (res) => {
  394. console.log(res)
  395. if (parseInt(res.code) === 200) {
  396. this.$message({
  397. message: "数据提交成功",
  398. type: "success",
  399. });
  400. if(res.data && res.data != null){
  401. //跳转测试结果页
  402. this.goTestResult(res.data);
  403. }else {
  404. //跳转列表选择页
  405. this.$message({
  406. message: res.msg,
  407. type: "error",
  408. });
  409. }
  410. } else {
  411. this.$message({
  412. message: "服务器内部故障,请联系管理员",
  413. type: "error",
  414. });
  415. }
  416. // 退出游戏
  417. this.running = false
  418. // 退出全屏
  419. this.screen()
  420. // 发送数据之后,清理数据
  421. this.collectedDataArray = []
  422. this.maps.forEach(map => map.count = 0)
  423. });
  424. }
  425. },
  426. onKeyDown(e) {
  427. if (this.disabled) {
  428. console.log('注视点时长内不响应任何按键')
  429. return
  430. } // 注视点时长内不响应任何按键
  431. this.disabled = true
  432. if (this.collectedDataArray[this.currentIndex].taskType === '1') {
  433. // 主任务
  434. console.log('主任务')
  435. // 先选择方向
  436. if (this.collectedDataArray[this.currentIndex].mainTaskDirectionActualResponse === '') {
  437. // 主任务方向的实际反应
  438. // 记录主任务的方向选择按键
  439. this.collectedDataArray[this.currentIndex].mainTaskDirectionActualResponse = e.code
  440. // 记录主任务的方向选择反应时间
  441. this.collectedDataArray[this.currentIndex].mainTaskDirectionEndTime = performance.now()
  442. // 记录主任务的方向选择按键
  443. this.collectedDataArray[this.currentIndex].mainTaskDirectionReactionTime = (this.collectedDataArray[this.currentIndex].mainTaskDirectionEndTime - this.collectedDataArray[this.currentIndex].mainTaskDirectionStartTime).toFixed(2)
  444. // 判断主任务方向反应是否正确 ‘1’:正确 '0':错误
  445. if (this.collectedDataArray[this.currentIndex].mainTaskDirectionActualResponse === this.collectedDataArray[this.currentIndex].mainTaskDirectionCorrectionResponse) {
  446. this.collectedDataArray[this.currentIndex].mainTaskDirectionCorrection = '1'
  447. console.log('方向选择正确')
  448. if (this.practiceFlag) {
  449. this.$message({
  450. message: '方向反应正确',
  451. type: 'success',
  452. })
  453. }
  454. this.disabled = false
  455. } else {
  456. this.collectedDataArray[this.currentIndex].mainTaskDirectionCorrection = '0'
  457. if (e.code === 'Space') {
  458. console.log('主任务不可以点击空格键')
  459. if (this.practiceFlag) {
  460. this.$message({
  461. message: '方向反应错误,主任务不可以点击空格键',
  462. type: 'error',
  463. })
  464. }
  465. this.collectedDataArray[this.currentIndex].mainTaskMissileCorrection = '0'
  466. this.collectedDataArray[this.currentIndex].endTime = performance.now() // 记录本局结束时间
  467. this.collectedDataArray[this.currentIndex].onceEndTime = Date.now() // 记录本试次结束时间
  468. setTimeout(() => {
  469. this.disabled = false
  470. this.showPic = false
  471. // 本次主任务结束,进入下一次
  472. this.currentIndex++
  473. this.next()
  474. }, 500)
  475. } else {
  476. this.disabled = false
  477. console.log('方向反应错误')
  478. if (this.practiceFlag) {
  479. this.$message({
  480. message: '方向反应错误',
  481. type: 'error',
  482. })
  483. }
  484. }
  485. }
  486. } else {
  487. // 如果方向键已经选择过,说明本次按键是为了选择武器挂载的
  488. // 主任务挂载的实际反应
  489. if (this.collectedDataArray[this.currentIndex].mainTaskMissileActualResponse === '') {
  490. // 记录主任务的武器选择按键
  491. this.collectedDataArray[this.currentIndex].mainTaskMissileActualResponse = e.code
  492. // 记录主任务的武器选择反应时间
  493. this.collectedDataArray[this.currentIndex].mainTaskMissileEndTime = performance.now()
  494. // 记录主任务的武器选择按键
  495. this.collectedDataArray[this.currentIndex].mainTaskMissileReactionTime = (this.collectedDataArray[this.currentIndex].mainTaskMissileEndTime - this.collectedDataArray[this.currentIndex].mainTaskMissileStartTime).toFixed(2)
  496. // 判断主任务挂载反应是否正确 ‘1’:正确 '2':错误
  497. if (this.collectedDataArray[this.currentIndex].mainTaskMissileActualResponse === this.collectedDataArray[this.currentIndex].mainTaskMissileCorrectionResponse) {
  498. this.collectedDataArray[this.currentIndex].mainTaskMissileCorrection = '1'
  499. console.log('武器选择正确')
  500. if (this.practiceFlag) {
  501. this.$message({
  502. message: '挂载反应正确',
  503. type: 'success',
  504. })
  505. }
  506. } else {
  507. this.collectedDataArray[this.currentIndex].mainTaskMissileCorrection = '0'
  508. console.log('武器选择错误')
  509. if (this.practiceFlag) {
  510. this.$message({
  511. message: e.code === 'Space' ? '挂载反应错误,主任务不可以点击空格键' : '挂载反应错误',
  512. type: 'error',
  513. })
  514. }
  515. }
  516. } else {
  517. console.log('按键错误')
  518. }
  519. this.collectedDataArray[this.currentIndex].endTime = performance.now() // 记录本局结束时间
  520. this.collectedDataArray[this.currentIndex].onceEndTime = Date.now() // 记录本试次结束时间
  521. setTimeout(() => {
  522. this.disabled = false
  523. this.showPic = false
  524. // 本次主任务结束,进入下一次
  525. this.currentIndex++
  526. this.next()
  527. }, 500)
  528. }
  529. } else {
  530. // 前瞻性记忆任务
  531. console.log('前瞻性记忆任务')
  532. // 前瞻性记忆任务的实际反应
  533. if (this.collectedDataArray[this.currentIndex].prospectiveTaskActualResponse === '') {
  534. // 前瞻性记忆任务选择按键
  535. this.collectedDataArray[this.currentIndex].prospectiveTaskActualResponse = e.code
  536. // 前瞻性记忆任务结束时间
  537. this.collectedDataArray[this.currentIndex].prospectiveTaskEndTime = performance.now()
  538. // 前瞻性记忆任务反应时间
  539. this.collectedDataArray[this.currentIndex].prospectiveTaskReactionTime = (this.collectedDataArray[this.currentIndex].prospectiveTaskEndTime - this.collectedDataArray[this.currentIndex].prospectiveTaskStartTime).toFixed(2)
  540. // 判断主任务挂载反应是否正确 ‘1’:正确 '2':错误
  541. if (this.collectedDataArray[this.currentIndex].prospectiveTaskActualResponse === this.collectedDataArray[this.currentIndex].prospectiveTaskCorrectionResponse) {
  542. this.collectedDataArray[this.currentIndex].prospectiveTaskCorrection = '1'
  543. console.log('前瞻性记忆任务选择正确')
  544. if (this.practiceFlag) {
  545. this.$message({
  546. message: '前瞻性记忆任务反应正确',
  547. type: 'success',
  548. })
  549. }
  550. } else {
  551. this.collectedDataArray[this.currentIndex].prospectiveTaskCorrection = '0'
  552. console.log('前瞻性记忆任务选择错误')
  553. if (this.practiceFlag) {
  554. this.$message({
  555. message: '前瞻性记忆任务反应错误',
  556. type: 'error',
  557. })
  558. }
  559. }
  560. this.collectedDataArray[this.currentIndex].endTime = performance.now() // 记录本局结束时间
  561. this.collectedDataArray[this.currentIndex].onceEndTime = Date.now() // 记录本试次结束时间
  562. setTimeout(() => {
  563. this.disabled = false
  564. this.showPic = false
  565. // 本次前瞻性记忆任务结束,进入下一次
  566. this.currentIndex++
  567. this.next()
  568. }, 500)
  569. } else {
  570. this.disabled = false
  571. this.showPic = false
  572. // 本次前瞻性记忆任务结束,进入下一次
  573. this.currentIndex++
  574. this.next()
  575. }
  576. }
  577. }
  578. },
  579. mounted() {
  580. window.addEventListener('keydown', this.onKeyDown)
  581. },
  582. destroyed() {
  583. window.removeEventListener('keydown', this.onKeyDown)
  584. }
  585. }
  586. </script>
  587. <style lang="scss" scoped>
  588. $sizeModifier: 2.1;
  589. .bTitle {
  590. font-size: 24px;
  591. color: #333333;
  592. text-align: left;
  593. text-indent: 20px;
  594. }
  595. #t1 {
  596. font-size: 18px;
  597. height: 36px;
  598. line-height: 36px;
  599. background: rgba(0, 0, 0, 0.39);
  600. border-radius: 24px;
  601. color: #ffffff;
  602. margin-left: 240px;
  603. text-align: center;
  604. }
  605. .pd-r16 {
  606. padding-top: 8px;
  607. padding-right: 16px;
  608. }
  609. #body2 {
  610. margin-top: 65px;
  611. }
  612. .item {
  613. width: 200px;
  614. height: 210px;
  615. margin-top: 20px;
  616. margin-right: 10px;
  617. float: left;
  618. }
  619. .el-image {
  620. width: 100%;
  621. height: 100%;
  622. }
  623. .btn {
  624. margin-top: 60px;
  625. margin-left: -10%;
  626. }
  627. .pbg {
  628. position: fixed;
  629. left: 0;
  630. top: 0;
  631. right: 0;
  632. bottom: 0;
  633. z-index: 100;
  634. background: rgba(0, 0, 0, 0.7);
  635. }
  636. .mainbody {
  637. height: 550px;
  638. width: 500px;
  639. border: 2px solid black;
  640. border-radius: 12px;
  641. background: #ffffff;
  642. }
  643. /*居中效果*/
  644. .middle {
  645. /*使左上角对应到父元素的中心*/
  646. top: 50%;
  647. left: 50%;
  648. position: absolute;
  649. /*向左向上偏移50%*/
  650. transform: translate(-50%, -50%);
  651. }
  652. .activeTask {
  653. background: url(/static/flying/bg_game.png) no-repeat center;
  654. background-size: cover;
  655. /* background: black; */
  656. position: fixed;
  657. top: 0;
  658. left: 0;
  659. right: 0;
  660. bottom: 0;
  661. }
  662. .activeTask3 {
  663. background: url(../../../assets/congnitiveAblitity/zhixing.png) no-repeat center;
  664. background-size: cover;
  665. /* background: black; */
  666. /* position: fixed;
  667. top: 0;
  668. left: 0;
  669. right: 0;
  670. bottom: 0; */
  671. }
  672. .glass {
  673. width: 932px;
  674. height: 720px;
  675. background: rgba(255, 255, 255, 0.39);
  676. border: 1px solid rgba(255, 255, 255, 0.6);
  677. box-shadow: 0 3px 6px rgba(0, 0, 0, 0.6);
  678. border-radius: 12px;
  679. position: absolute;
  680. top: 46%;
  681. left: 50%;
  682. transform: translate(-50%, -50%);
  683. .opt-outline {
  684. width: 70%;
  685. height: 400px;
  686. border: solid;
  687. margin-left: 15%;
  688. }
  689. .opt-div {
  690. width: 50%;
  691. height: 400px;
  692. float: right;
  693. border-left: solid;
  694. justify-content: space-around;
  695. .start-bb {
  696. width: 120px;
  697. height: 42px;
  698. border: 2px solid rgba(255, 255, 255, 0.8);
  699. box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16);
  700. opacity: 1;
  701. border-radius: 39px;
  702. color: white;
  703. }
  704. }
  705. }
  706. .opt-tips {
  707. font-size: 13px;
  708. text-align: left;
  709. text-indent: 2em;
  710. }
  711. #game {
  712. width: 100%;
  713. height: 100%;
  714. position: absolute;
  715. top: 0;
  716. left: 0;
  717. //border: 1px solid black;
  718. background-image: url("/static/flying/dashboard.png");
  719. background-repeat: no-repeat;
  720. background-size: 95% 90%;
  721. background-position: center;
  722. display: flex;
  723. flex-direction: row;
  724. align-items: center;
  725. justify-content: space-around;
  726. }
  727. #missile {
  728. width: 359.5px * $sizeModifier;
  729. height: 359.5px * $sizeModifier;
  730. }
  731. #compass {
  732. width: 359.5px * $sizeModifier;
  733. height: 359.5px * $sizeModifier;
  734. }
  735. #tip {
  736. width: 809px;
  737. height: 100px;
  738. position: absolute;
  739. left: 50%;
  740. top: 800px;
  741. transform: translateX(-50%);
  742. background-color: #0abdc4;
  743. }
  744. #arrow {
  745. width: 32px;
  746. height: 32px;
  747. }
  748. </style>