formal.vue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174
  1. <template>
  2. <div class="app-container">
  3. <Header />
  4. <div class="main-container">
  5. <van-nav-bar :title="subjectInfo.name" left-arrow @click-left="goBack" />
  6. <div class="main-outline">
  7. <template v-if="!testFlag">
  8. <div class="main-text-div">
  9. <div id="left_top" class="flex-row">
  10. <div class="setting"></div>
  11. <div class="text" style="color: #57acbb">操作提示:</div>
  12. </div>
  13. <div class="left-desc-80" style="margin-top: 0.5rem">
  14. {{
  15. practiceFlag
  16. ? "请先练习测试,练习完成后,即将正式测试。"
  17. : "请开始正式测试!"
  18. }}
  19. </div>
  20. </div>
  21. <div class="btnArea">
  22. <van-button
  23. block
  24. class="start"
  25. round
  26. type="primary"
  27. @click="startTestFn()"
  28. >
  29. {{ practiceFlag ? "练习测试" : "正式测试" }}
  30. </van-button>
  31. </div>
  32. </template>
  33. <div v-if="running" class="activeTask txt-center">
  34. <!-- 练习阶段不显示游戏进度 -->
  35. <!-- <MainProgress v-show="!practiceFlag" :cur-percentage="percentage" />-->
  36. <div v-if="!practiceFlag" class="progress-content">
  37. <van-progress
  38. :percentage="(currentIndex / gradeList.length) * 100"
  39. color="#f2826a"
  40. pivot-text="任务进度"
  41. />
  42. </div>
  43. <div class="glass-speed-task" @click="userClickToStop">
  44. <!-- 倒计时 -->
  45. <p v-show="countDownShow" class="countdownStr">
  46. {{ countDownStr }}
  47. </p>
  48. <!-- 十字图标 -->
  49. <img
  50. v-show="showWhiteFlag"
  51. class="crossImg"
  52. src="../../../assets/congnitiveAblitity/whiteFlag-new.png"
  53. />
  54. <!-- 飞机 -->
  55. <SvgIcon
  56. v-show="planeAndCoveringVisible"
  57. ref="planeRef"
  58. :class="planeClass"
  59. color="#ffbb00"
  60. h="38"
  61. name="aircraft"
  62. w="38"
  63. />
  64. <!-- 遮挡物 -->
  65. <div v-show="planeAndCoveringVisible" :class="coveringClass">
  66. <div class="white-line"></div>
  67. </div>
  68. </div>
  69. </div>
  70. <div>
  71. <!-- <button v-show="quitFlag" @click="endTest">退出</button>-->
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. </template>
  77. <script>
  78. import Header from "@/components/header/index.vue";
  79. import { dateFormat } from "@/utils/utils";
  80. export default {
  81. name: "speedCognitive",
  82. components: { Header },
  83. data() {
  84. return {
  85. subjectInfo: "", //认知任务详情
  86. buttonName: "练习测试", // 正式测试 // 重新练习
  87. taskId: "", // 认知任务id
  88. testFlag: false, // 主逻辑显示标识
  89. // 是否是练习模式的标识,默认为 true
  90. practiceFlag: true,
  91. isPracticeEnd: true, // 是否完成练习
  92. //x轴坐标
  93. x: 0,
  94. //y轴坐标
  95. y: 80,
  96. // startPosition: 130,
  97. myBall: {},
  98. start: {},
  99. stopmove: {},
  100. //运动速度
  101. speed: 1,
  102. testState: false,
  103. oldSecond: 0, //定义时,分,秒,毫秒并初始化为0;
  104. oldMillSecond: 0,
  105. newSecond: 0,
  106. newMillSecond: 0, //秒
  107. //时间差
  108. second: 0,
  109. millSecond: 0,
  110. //时间差值
  111. time: 0,
  112. //游戏难度
  113. grade: 0,
  114. nextFlag: false,
  115. quitFlag: false,
  116. repeatFlag: false,
  117. //三个不同长度的长方形是否显示
  118. firstFlag: false,
  119. secondFlag: false,
  120. thirdFlag: false,
  121. //从上往下还是从下往上
  122. upToDown: false,
  123. downToUp: false,
  124. //倒计时
  125. countDownTime: 6, //开始前的倒计时
  126. countDownStr: "开始测试",
  127. countDownShow: true,
  128. //白色加号和测试物体是否显示
  129. showWhiteFlag: false,
  130. showDuckEgg: false,
  131. imgIndex: 0,
  132. userCanClick: false,
  133. recordedData: [
  134. // {
  135. // imgIndex: "",
  136. // speed: 0,
  137. // length: 0,
  138. // error: "NULL",
  139. // level: grade === 100 ? '' : grade + 1,
  140. // onceStartTime: dateFormat("YY-mm-dd HH:MM:SS", new Date(this.onceStartTime)),
  141. // onceEndTime: dateFormat("YY-mm-dd HH:MM:SS", new Date()),
  142. // responseTime: (performance.now() - this.responseStartTime).toFixed(5),
  143. // hasResponse: this.hasResponse,
  144. // }
  145. ],
  146. // 每个试次记录的数据
  147. record: null,
  148. userId: "",
  149. dex: 0,
  150. taskStartTime: 0, // 任务开始时间
  151. taskEndTime: 0, // 任务结束时间
  152. onceStartTime: 0,
  153. hasResponse: 0, // 用户是否反应标识 0 表示已反应,1 表示未反应
  154. responseStartTime: 0,
  155. tryStartTime: 0,
  156. // 飞机的移动方向,up 表示向上移动,down 表示向下移动
  157. direction: "down",
  158. // 飞机每次移动的间隔,单位毫秒
  159. interval: 20,
  160. // 游戏面板的宽度,单位像素
  161. with: 1248,
  162. // 游戏面板的高度,单位像素
  163. height: 2073,
  164. // 游戏是否开始
  165. running: false,
  166. // 游戏的当前试次
  167. currentIndex: 0,
  168. // 控制飞机和遮挡物显隐的标识
  169. planeAndCoveringVisible: false,
  170. // 飞机在垂直方向上的移动距离
  171. dy: 0,
  172. // 控制飞机移动的定时器
  173. moveTimer: null,
  174. // 控制倒计时的定时器
  175. myInterval: null,
  176. // 游戏最大等级
  177. maxLevel: 9,
  178. // 游戏等级权重
  179. gradeList: []
  180. };
  181. },
  182. computed: {
  183. /**
  184. * 计算游戏进度
  185. * @returns {number}
  186. */
  187. percentage() {
  188. return this.currentIndex / this.maxIndex;
  189. },
  190. /**
  191. * 飞机的类名
  192. * @returns {string}
  193. */
  194. planeClass() {
  195. return this.direction === "up" ? "plane-up" : "plane-down";
  196. },
  197. /**
  198. * 遮挡物的类名
  199. * @returns {string}
  200. */
  201. coveringClass() {
  202. if (this.grade > 6) {
  203. return this.direction === "down"
  204. ? "covering-long-down"
  205. : "covering-long-up";
  206. } else if (this.grade > 3) {
  207. return this.direction === "down"
  208. ? "covering-middle-down"
  209. : "covering-middle-up";
  210. } else {
  211. return this.direction === "down"
  212. ? "covering-short-down"
  213. : "covering-short-up";
  214. }
  215. },
  216. /**
  217. * 遮挡物的长度
  218. * @returns {number}
  219. */
  220. coveringLength() {
  221. if (this.grade > 6) {
  222. return 450;
  223. } else if (this.grade > 3) {
  224. return 330;
  225. } else {
  226. return 420;
  227. }
  228. },
  229. /**
  230. * 飞机的移动速度
  231. * @returns {number}
  232. */
  233. planeSpeed() {
  234. if ([3, 6, 9].includes(this.grade)) {
  235. return this.pxToRem(8);
  236. } else if ([2, 5, 8].includes(this.grade)) {
  237. return this.pxToRem(4);
  238. } else {
  239. return this.pxToRem(2);
  240. }
  241. },
  242. /**
  243. * 飞机从起始点移动到遮挡物边缘所需时长,单位毫秒
  244. * @returns {number}
  245. */
  246. duration() {
  247. console.log(this.planeSpeed, "飞机移动速度");
  248. if (this.grade > 6) {
  249. // 232 表示长遮挡物上边缘距离飞机起始点的长度,单位像素
  250. return (this.pxToRem(632) / this.planeSpeed) * this.interval;
  251. } else if (this.grade > 3) {
  252. // 282 表示短遮挡物上边缘距离飞机起始点的长度,单位像素
  253. return (this.pxToRem(682) / this.planeSpeed) * this.interval;
  254. } else {
  255. // 332 表示较短遮挡物上边缘距离飞机起始点的长度,单位像素
  256. return (this.pxToRem(732) / this.planeSpeed) * this.interval;
  257. }
  258. },
  259. /**
  260. * 飞机的起始位置
  261. * @returns {number}
  262. */
  263. startPosition() {
  264. if (this.direction === "down") {
  265. return this.pxToRem(-198);
  266. } else {
  267. return this.pxToRem(this.height);
  268. }
  269. },
  270. /**
  271. * 飞机从遮挡物上边缘到白线位置实际所需时间
  272. * @returns {number}
  273. */
  274. actualArrivalTime() {
  275. console.log(
  276. this.pxToRem(this.coveringLength),
  277. "this.pxToRem(this.coveringLength)"
  278. );
  279. console.log(this.planeSpeed, "this.planeSpeed");
  280. console.log(this.interval, "this.interval");
  281. console.log(
  282. (this.pxToRem(this.coveringLength) / this.planeSpeed) * this.interval,
  283. "this.pxToRem(this.coveringLength) / this.planeSpeed * this.interval"
  284. );
  285. return (
  286. (this.pxToRem(this.coveringLength) / this.planeSpeed) * this.interval
  287. );
  288. },
  289. /**
  290. * 游戏的最大试次
  291. * 练习阶段 6 次,测试阶段 36 次
  292. * @returns {number}
  293. */
  294. maxIndex() {
  295. if (this.practiceFlag) {
  296. return 6;
  297. } else {
  298. return this.gradeList.length;
  299. }
  300. }
  301. },
  302. created() {
  303. this.taskId = this.$route.query.taskId;
  304. console.log(this.$route, "this.$route");
  305. this.gradeList = this.gradeList.sort(() => Math.random() - 0.5);
  306. this.init(this.taskId);
  307. console.log(this.taskId, "this.taskId");
  308. // 初始化动态参数
  309. this.getParam();
  310. },
  311. mounted() {
  312. console.log("this.maxIndex: ", this.maxIndex);
  313. console.log("this.gradeList: ", this.gradeList);
  314. // this.getParam();
  315. document.addEventListener("keydown", this.onKeydown);
  316. },
  317. methods: {
  318. getParam() {
  319. this.$http.get(
  320. `/taskParam/getByTaskId?taskId=${this.taskId}`,
  321. {},
  322. msg => {
  323. console.log(msg, "msg");
  324. msg.data.forEach(item => {
  325. if (item.code === "SC_Try_Count") {
  326. let tryCount = Number(item.value);
  327. for (let i = 0; i < tryCount; i++) {
  328. this.gradeList = this.gradeList.concat([
  329. 1,
  330. 2,
  331. 3,
  332. 4,
  333. 5,
  334. 6,
  335. 7,
  336. 8,
  337. 9
  338. ]);
  339. console.log(
  340. this.gradeList,
  341. "this.gradeListthis.gradeListthis.gradeListthis.gradeList"
  342. );
  343. }
  344. }
  345. });
  346. }
  347. );
  348. },
  349. initRecord() {
  350. return {
  351. imgIndex: "",
  352. speed: 0,
  353. length: 0,
  354. error: "NULL",
  355. level: 0,
  356. onceStartTime: 0,
  357. onceEndTime: 0,
  358. responseTime: 0,
  359. hasResponse: 0,
  360. responseStartTime: 0, // 响应开始时间戳
  361. isValidResponse: 0 // 是否为有效响应
  362. };
  363. },
  364. /**
  365. * px to rem, 1 rem = 192px
  366. */
  367. pxToRem(px) {
  368. return px / 192;
  369. },
  370. onKeydown(e) {
  371. let key = e.keyCode;
  372. if (key === 122) {
  373. e.preventDefault();
  374. // screenfull.toggle()
  375. }
  376. if (32 === key) {
  377. this.userClickToStop();
  378. }
  379. },
  380. init() {
  381. // this.testPlanId = this.$route.query.testPlanId || ''
  382. this.userId = JSON.parse(sessionStorage.getItem("userInfo")).id;
  383. this.subjectInfo = JSON.parse(sessionStorage.getItem("subjectInfo"));
  384. // this.subjectInfo = JSON.parse(oSessionStorage.getItem("subjectInfo"))
  385. // this.userId = sessionStorage.getItem("b80bb7740288fda1f201890375a60c8f")
  386. },
  387. startTestFn() {
  388. // 显示游戏面板
  389. this.running = true;
  390. // 进入全屏
  391. this.screen();
  392. // 开始倒计时
  393. this.countDownTime = 6;
  394. this.countDownStr = "马上开始!";
  395. // 显示倒计时
  396. this.countDownShow = true;
  397. this.countDown();
  398. // 重置游戏的当前试次
  399. this.currentIndex = 0;
  400. // 清空游戏试次记录
  401. this.recordedData = [];
  402. // 记录游戏开始时间
  403. this.taskStartTime = dateFormat("YY-mm-dd HH:MM:SS", new Date());
  404. },
  405. //点击停止物体运动,并用来判断成绩
  406. userClickToStop() {
  407. this.record.hasResponse = 1; // 标记用户做出了反应
  408. console.log("进入stop方法, this.userCanClick: ", this.userCanClick);
  409. if (this.userCanClick) {
  410. // 按键锁,上锁
  411. this.userCanClick = false;
  412. // 记录当前试次的结束时间
  413. this.record.onceEndTime = dateFormat("YY-mm-dd HH:MM:SS", new Date());
  414. // 是否为有效响应
  415. this.record.isValidResponse = 1;
  416. // 记录响应时间
  417. this.record.responseTime = (
  418. performance.now() - this.tryStartTime
  419. ).toFixed(2);
  420. // 计算响应误差 = 实际应到达时间 - 响应时间,并取绝对值
  421. this.record.error = Math.abs(
  422. this.actualArrivalTime - this.record.responseTime
  423. ).toFixed(2);
  424. console.log(
  425. this.actualArrivalTime,
  426. "实际应到达时间",
  427. this.record.responseTime,
  428. "响应时间"
  429. );
  430. // 向数组中发送数据
  431. this.recordedData.push(this.record);
  432. // 停止控制飞机移动的定时器
  433. clearInterval(this.moveTimer);
  434. // 隐藏飞机和遮挡物
  435. this.planeAndCoveringVisible = false;
  436. // 试次数量加一
  437. this.currentIndex++;
  438. // 进入下一个试次
  439. this.nextOnce();
  440. } else {
  441. // 无效响应
  442. this.record.isValidResponse = 0;
  443. }
  444. },
  445. screen() {
  446. // screenfull.toggle()
  447. },
  448. screenExit() {
  449. // screenfull.exit()
  450. },
  451. countDown() {
  452. // 测试时间倒计时
  453. this.myInterval = setInterval(() => {
  454. this.countDownTime--;
  455. this.countDownStr = this.countDownTime;
  456. if (this.countDownTime === 0) {
  457. // 隐藏倒计时
  458. this.countDownShow = false;
  459. // 清除定时器
  460. clearInterval(this.myInterval);
  461. // 恢复倒计时次数
  462. this.countDownTime = 6;
  463. // 开始试次
  464. this.nextOnce();
  465. }
  466. }, 1000);
  467. },
  468. nextOnce() {
  469. console.log(this.currentIndex, "nextONce");
  470. // 试次数量大于或等于最大试次(36)时,游戏结束
  471. if (this.currentIndex >= this.maxIndex) {
  472. console.log("游戏结束");
  473. // 记录游戏结束时间
  474. this.taskEndTime = dateFormat("YY-mm-dd HH:MM:SS", new Date());
  475. this.screen();
  476. // 如果是正式测试,则提交数据
  477. if (this.practiceFlag) {
  478. // 将练习模式标识设置成 false
  479. this.practiceFlag = false;
  480. // 隐藏游戏界面
  481. this.running = false;
  482. } else {
  483. // 如果是正式测试,则提交数据
  484. this.sendData();
  485. // 将练习模式标识设置成 false
  486. this.practiceFlag = true;
  487. // 隐藏游戏界面
  488. this.running = false;
  489. }
  490. return;
  491. }
  492. // 初始化试次记录数据
  493. this.record = this.initRecord();
  494. // 每 4 个 试次,升一个等级(重构之前的方式)
  495. // if (this.currentIndex % 4 === 0) {
  496. // this.grade++
  497. // }
  498. // 难度等级要穿插着来,不要顺序呈现
  499. // this.grade = Math.floor(Math.random() * this.maxLevel)
  500. this.grade = this.gradeList[this.currentIndex];
  501. // this.grade = 7
  502. // 每 3 个试次换一次方向
  503. if (this.currentIndex % 3 === 0) {
  504. this.direction = this.direction === "down" ? "up" : "down";
  505. }
  506. // 记录数据
  507. this.record.imgIndex = this.currentIndex + 1;
  508. this.record.speed = Math.ceil(this.planeSpeed * 192); // rem to px
  509. this.record.length = this.coveringLength;
  510. this.record.level = this.grade;
  511. this.record.onceStartTime = dateFormat("YY-mm-dd HH:MM:SS", new Date());
  512. console.log("this.record: ", this.record);
  513. // 显示十字图标
  514. this.showWhiteFlag = true;
  515. // 飞机显示之前的空屏 2 秒
  516. setTimeout(() => {
  517. // 2s 之后隐藏十字图标
  518. this.showWhiteFlag = false;
  519. // 设置飞机移动的起始点
  520. this.dy =
  521. this.direction === "down"
  522. ? this.pxToRem(-198)
  523. : this.pxToRem(this.height);
  524. // this.dy = this.direction === 'down' ? -1 : 10.8
  525. console.log(this.dy, "飞机起始点");
  526. console.log(this.pxToRem(this.height), "飞机起始点上");
  527. console.log(this.pxToRem(-198), "飞机起始点下");
  528. // 显示飞机和遮挡物
  529. this.planeAndCoveringVisible = true;
  530. this.moveTimer = setInterval(() => {
  531. console.log(
  532. "this.grade: ",
  533. this.grade,
  534. " this.planeSpeed: ",
  535. this.planeSpeed
  536. );
  537. // 移动飞机
  538. if (this.direction === "down") {
  539. this.dy += this.planeSpeed;
  540. if (this.dy <= this.pxToRem(this.height)) {
  541. this.$refs.planeRef.$el.style.top = this.dy + "rem";
  542. } else {
  543. // 记录当前试次的结束时间
  544. this.record.onceEndTime = dateFormat(
  545. "YY-mm-dd HH:MM:SS",
  546. new Date()
  547. );
  548. this.record.error = (
  549. ((this.pxToRem(this.height + this.coveringLength) /
  550. this.planeSpeed) *
  551. this.interval) /
  552. 2
  553. ).toFixed(2);
  554. // 向记录数组中添加数据
  555. this.recordedData.push(this.record);
  556. // 关闭按键锁
  557. this.userCanClick = false;
  558. // 飞机移动出游戏边界时,停止控制飞机移动的定时器
  559. clearInterval(this.moveTimer);
  560. // 隐藏飞机和遮挡物
  561. this.planeAndCoveringVisible = false;
  562. // 试次数量加一
  563. this.currentIndex++;
  564. // 进入下一个试次
  565. this.nextOnce();
  566. }
  567. }
  568. if (this.direction === "up") {
  569. this.dy -= this.planeSpeed;
  570. if (this.dy >= 0) {
  571. this.$refs.planeRef.$el.style.top = this.dy + "rem";
  572. } else {
  573. // 记录当前试次的结束时间
  574. this.record.onceEndTime = dateFormat(
  575. "YY-mm-dd HH:MM:SS",
  576. new Date()
  577. );
  578. this.record.error = (
  579. ((this.pxToRem(this.height + this.coveringLength) /
  580. this.planeSpeed) *
  581. this.interval) /
  582. 2
  583. ).toFixed(2);
  584. // 向记录数组中添加数据
  585. this.recordedData.push(this.record);
  586. // 关闭按键锁
  587. this.userCanClick = false;
  588. // 飞机移动出游戏边界时,停止控制飞机移动的定时器
  589. clearInterval(this.moveTimer);
  590. // 隐藏飞机和遮挡物
  591. this.planeAndCoveringVisible = false;
  592. // 试次数量加一
  593. this.currentIndex++;
  594. // 进入下一个试次
  595. this.nextOnce();
  596. }
  597. }
  598. }, this.interval);
  599. // 飞机移动到遮挡物边缘时,开启按键锁
  600. console.log(this.duration, "到遮挡物所需要的时间");
  601. this.sleep(this.duration).then(() => {
  602. console.log("飞机进入了遮挡物,可以触发点击事件");
  603. // 记录当前试次的响应开始时间,用于计算响应时间
  604. this.record.responseStartTime = Date.now();
  605. this.tryStartTime = performance.now();
  606. // 打开按键锁
  607. this.userCanClick = true;
  608. });
  609. }, 2000);
  610. },
  611. sendData() {
  612. console.log("发送数据");
  613. let result = {
  614. userId: this.userId,
  615. results: this.recordedData,
  616. testPlanId: this.$route.query.testPlanId || "",
  617. taskStartTime: this.taskStartTime,
  618. taskEndTime: this.taskEndTime
  619. };
  620. console.log(result);
  621. // 退出全屏
  622. // this.screenExit()
  623. // this.$http.post(
  624. // "cognize/RDT",
  625. // {
  626. // userId: this.userId,
  627. // totalEarned: this.totalEarn,
  628. // rawData: this.userData,
  629. // testPlanId: this.$route.query.testPlanId || "",
  630. // totalAerated: this.totalAerated,
  631. // taskStartTime: dateFormat("YY-mm-dd HH:MM:SS", new Date(this.taskStartTime)),
  632. // taskEndTime: dateFormat("YY-mm-dd HH:MM:SS", new Date(this.taskEndTime)),
  633. // },
  634. // (response) => {
  635. // // this.showResult = true;
  636. // // this.drawLine1();
  637. // // this.drawLine2();
  638. // if (response && response.code == "200") {
  639. // //跳转新测试结果页面
  640. // this.goTestResult(response.data);
  641. // } else {
  642. // this.$toast.fail("获取数据失败!服务器异常");
  643. // }
  644. // }
  645. // );
  646. this.$http.post(`/cognize/speedCognitive`, result, response => {
  647. console.log("结果", response);
  648. if (response.code === "200") {
  649. // this.$message({
  650. // message: "测试结束!",
  651. // type: "success"
  652. // })
  653. sessionStorage.setItem("testResult", JSON.stringify(response.data));
  654. this.goTestResult(response.data);
  655. // this.$router.push({
  656. // name: "testResultNew",
  657. // params: {
  658. // title: '时间知觉能力测试',
  659. // come: 1, //1-来自测试列表,2-来自测试计划,3-来自测试记录列表
  660. // },
  661. // });
  662. } else {
  663. this.$message({
  664. message: "测试失败!服务器异常",
  665. type: "error"
  666. });
  667. this.$router.push({ name: "CognitiveAbility" });
  668. }
  669. });
  670. },
  671. sleep(time) {
  672. return new Promise(resolve => setTimeout(resolve, time));
  673. }
  674. },
  675. beforeDestroy() {
  676. // 清除控制飞机移动的定时器
  677. clearInterval(this.moveTimer);
  678. // 清除控制倒计时的定时器
  679. clearInterval(this.myInterval);
  680. document.removeEventListener("keydown", this.onKeydown);
  681. }
  682. };
  683. </script>
  684. <style lang="scss" scoped>
  685. .progress-content {
  686. position: absolute;
  687. width: 100%;
  688. height: 20px;
  689. left: 0;
  690. top: 60px;
  691. box-sizing: border-box;
  692. padding: 4px 10px;
  693. }
  694. .btnArea {
  695. width: 75%;
  696. margin: 60px auto 0;
  697. }
  698. .setting {
  699. background: url("../../../assets/9551.png");
  700. background-size: 100% 100%;
  701. margin-right: 5px;
  702. width: 20px;
  703. height: 20px;
  704. }
  705. .el-progress-bar__inner {
  706. position: absolute;
  707. left: 0;
  708. top: 0;
  709. height: 100%;
  710. background-color: #ff3c3c !important;
  711. text-align: right;
  712. border-radius: 100px;
  713. line-height: 1;
  714. white-space: nowrap;
  715. transition: width 0.6s ease;
  716. background-image: linear-gradient(to right, #ffd650, #ff8431) !important;
  717. }
  718. .activeTask {
  719. background: url(../../../assets/congnitiveAblitity/speed-bg.png) no-repeat
  720. center;
  721. background-size: cover;
  722. position: fixed;
  723. top: 0;
  724. left: 0;
  725. right: 0;
  726. bottom: 0;
  727. .glass-speed-task {
  728. width: 94%; // 1248px;
  729. height: 400px; // 864px;
  730. background: rgba(255, 255, 255, 0.39);
  731. border: 1px solid rgba(255, 255, 255, 0.6);
  732. box-shadow: 0 3px 6px rgba(0, 0, 0, 0.6);
  733. border-radius: 12px;
  734. position: absolute;
  735. top: 46%;
  736. left: 50%;
  737. transform: translate(-50%, -50%);
  738. overflow: hidden;
  739. }
  740. }
  741. .countdownStr {
  742. position: absolute;
  743. top: 50%;
  744. left: 50%;
  745. transform: translate(-50%, -50%);
  746. color: black;
  747. width: 60%;
  748. height: 0.3646rem;
  749. line-height: 0.3646rem;
  750. text-align: center;
  751. }
  752. .crossImg {
  753. position: absolute;
  754. top: 50%;
  755. left: 50%;
  756. transform: translate(-50%, -50%);
  757. width: 1.2646rem;
  758. height: 1.2646rem;
  759. }
  760. .covering-short-down {
  761. opacity: 1;
  762. border-radius: 8px;
  763. width: 1rem; // 50px;
  764. height: 4rem; // 180px;
  765. background-color: #40aaff;
  766. position: absolute;
  767. top: 40%;
  768. left: 50%;
  769. transform: translate(-50%, -0.5208rem); // -100px
  770. z-index: 2;
  771. .white-line {
  772. width: 100%; // 50px;
  773. height: 0.0604rem; // 2px;
  774. background-color: white;
  775. position: absolute;
  776. top: 2.208rem; // 100px;
  777. left: 0;
  778. z-index: 2;
  779. }
  780. }
  781. .covering-short-up {
  782. opacity: 1;
  783. border-radius: 8px;
  784. width: 1rem; // 50px;
  785. height: 4rem; // 180px;
  786. background-color: #40aaff;
  787. position: absolute;
  788. top: 35%;
  789. left: 50%;
  790. //transform-origin: 0.1302rem 0.5208rem; // 25px 100px;
  791. transform: translate(-50%, -0.5208rem) rotate(180deg);
  792. z-index: 2;
  793. .white-line {
  794. width: 100%; // 50px;
  795. height: 0.0604rem; // 2px;
  796. background-color: white;
  797. position: absolute;
  798. top: 2.208rem; // 100px;
  799. left: 0;
  800. z-index: 2;
  801. }
  802. }
  803. .covering-middle-down {
  804. opacity: 1;
  805. border-radius: 12px;
  806. width: 1rem; // 50px;
  807. height: 4.5rem; // 230px;
  808. background-color: #40aaff;
  809. position: absolute;
  810. top: 32%;
  811. left: 50%;
  812. transform: translate(-50%, -0.78125rem); // -150px
  813. z-index: 2;
  814. .white-line {
  815. width: 100%; // 50px;
  816. height: 0.06rem; // 2px;
  817. background-color: white;
  818. position: absolute;
  819. top: 2.69125rem; // 150px;
  820. left: 0;
  821. z-index: 2;
  822. }
  823. }
  824. .covering-middle-up {
  825. opacity: 1;
  826. border-radius: 12px;
  827. width: 1rem; // 50px;
  828. height: 4.5rem; // 230px;
  829. background-color: #40aaff;
  830. position: absolute;
  831. top: 35%;
  832. left: 50%;
  833. //transform-origin: 0.1302rem 0.78125rem; // 25px 150px;
  834. transform: translate(-50%, -0.78125rem) rotate(180deg);
  835. z-index: 2;
  836. .white-line {
  837. width: 100%; // 50px;
  838. height: 0.06rem; // 2px;
  839. background-color: white;
  840. position: absolute;
  841. top: 1.88125rem; // 150px;
  842. left: 0;
  843. z-index: 2;
  844. }
  845. }
  846. .covering-long-down {
  847. opacity: 1;
  848. border-radius: 12px;
  849. width: 1rem; // 50px;
  850. height: 4.5rem; // 280px;
  851. background-color: #40aaff;
  852. position: absolute;
  853. top: 40%;
  854. left: 50%;
  855. transform: translate(-50%, -1.0416rem); // -200px
  856. z-index: 2;
  857. .white-line {
  858. width: 100%; // 50px;
  859. height: 0.06rem; // 2px;
  860. background-color: white;
  861. position: absolute;
  862. top: 2.4416rem; // 200px;
  863. left: 0;
  864. z-index: 2;
  865. }
  866. }
  867. .covering-long-up {
  868. opacity: 1;
  869. border-radius: 12px;
  870. width: 1rem; // 50px;
  871. height: 4.5rem;
  872. background-color: #40aaff;
  873. position: absolute;
  874. top: 40%;
  875. left: 50%;
  876. //transform-origin: 0.1302rem 1.0417rem;// 25px 200px;
  877. transform: translate(-50%, -1.0416rem) rotate(180deg);
  878. z-index: 2;
  879. .white-line {
  880. width: 100%; // 50px;
  881. height: 0.06rem; // 2px;
  882. background-color: white;
  883. position: absolute;
  884. top: 2.4416rem; // 200px;
  885. left: 0;
  886. z-index: 2;
  887. }
  888. }
  889. .plane-down {
  890. background: transparent !important;
  891. position: absolute;
  892. width: -0.2604rem; // -50px;
  893. left: 50%;
  894. transform: translateX(-50%) rotate(180deg);
  895. z-index: 1;
  896. }
  897. .plane-up {
  898. background: transparent !important;
  899. position: absolute;
  900. top: 4.5rem;
  901. left: 50%;
  902. transform: translateX(-50%);
  903. z-index: 1;
  904. }
  905. #shelterRec1 {
  906. opacity: 1;
  907. /* border-radius: 12px; */
  908. border-top-left-radius: 8px;
  909. border-top-right-radius: 8px;
  910. width: 50px;
  911. height: 100px;
  912. background-color: #40aaff;
  913. position: absolute;
  914. margin-top: 200px;
  915. /* top: 50%;
  916. margin-top:-100px; */
  917. left: 50%;
  918. margin-left: -25px;
  919. /* margin-left:25px; */
  920. z-index: 2;
  921. }
  922. #myBall {
  923. position: absolute;
  924. margin-top: -50px;
  925. left: 50%;
  926. margin-left: -10px;
  927. z-index: 1;
  928. transform: rotate(180deg);
  929. background: transparent !important;
  930. }
  931. #shelterRec2 {
  932. opacity: 1;
  933. /* border-radius: 12px; */
  934. border-top-left-radius: 8px;
  935. border-top-right-radius: 8px;
  936. width: 50px;
  937. height: 150px;
  938. background-color: #40aaff;
  939. position: absolute;
  940. margin-top: 150px;
  941. left: 50%;
  942. margin-left: -25px;
  943. z-index: 2;
  944. }
  945. #shelterRec3 {
  946. opacity: 1;
  947. /* border-radius: 12px; */
  948. border-top-left-radius: 8px;
  949. border-top-right-radius: 8px;
  950. width: 50px;
  951. height: 200px;
  952. background-color: #40aaff;
  953. position: absolute;
  954. margin-top: 100px;
  955. left: 50%;
  956. margin-left: -25px;
  957. z-index: 2;
  958. }
  959. #targetRec {
  960. opacity: 1;
  961. border-bottom-left-radius: 8px;
  962. border-bottom-right-radius: 8px;
  963. /* border-radius: 12px; */
  964. width: 50px;
  965. height: 30px;
  966. background-color: #40aaff;
  967. position: absolute;
  968. margin-top: 300px;
  969. left: 50%;
  970. margin-left: -25px;
  971. z-index: 2;
  972. }
  973. #whiteLine {
  974. width: 50px;
  975. height: 20px;
  976. background-color: white;
  977. position: absolute;
  978. margin-top: 298px;
  979. left: 50%;
  980. margin-left: -25px;
  981. z-index: 2;
  982. }
  983. #BshelterRec1 {
  984. border-bottom-left-radius: 8px;
  985. border-bottom-right-radius: 8px;
  986. background-color: #40aaff;
  987. width: 50px;
  988. height: 100px;
  989. /* background-color: black; */
  990. position: absolute;
  991. margin-top: 240px;
  992. left: 50%;
  993. margin-left: -25px;
  994. z-index: 2;
  995. }
  996. #BmyBall {
  997. background: transparent !important;
  998. position: absolute;
  999. margin-top: 420px;
  1000. left: 50%;
  1001. margin-left: -10px;
  1002. z-index: 1;
  1003. }
  1004. #BshelterRec2 {
  1005. border-bottom-left-radius: 8px;
  1006. border-bottom-right-radius: 8px;
  1007. background-color: #40aaff;
  1008. width: 50px;
  1009. height: 150px;
  1010. /* background-color: black; */
  1011. position: absolute;
  1012. margin-top: 240px;
  1013. left: 50%;
  1014. margin-left: -25px;
  1015. z-index: 2;
  1016. }
  1017. #BshelterRec3 {
  1018. border-bottom-left-radius: 8px;
  1019. border-bottom-right-radius: 8px;
  1020. background-color: #40aaff;
  1021. width: 50px;
  1022. height: 200px;
  1023. /* background-color: black; */
  1024. position: absolute;
  1025. margin-top: 240px;
  1026. left: 50%;
  1027. margin-left: -25px;
  1028. z-index: 2;
  1029. }
  1030. #BtargetRec {
  1031. border-top-left-radius: 8px;
  1032. border-top-right-radius: 8px;
  1033. background-color: #40aaff;
  1034. width: 50px;
  1035. height: 30px;
  1036. /* background-color: black; */
  1037. position: absolute;
  1038. margin-top: 208px;
  1039. left: 50%;
  1040. margin-left: -25px;
  1041. z-index: 2;
  1042. }
  1043. #BwhiteLine {
  1044. width: 50px;
  1045. height: 2px;
  1046. background-color: white;
  1047. position: absolute;
  1048. margin-top: 238px;
  1049. left: 50%;
  1050. margin-left: -25px;
  1051. z-index: 2;
  1052. }
  1053. .glass {
  1054. width: 932px;
  1055. height: 593px;
  1056. background: rgba(255, 255, 255, 0.39);
  1057. border: 3px solid rgba(255, 255, 255, 0.6);
  1058. box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16);
  1059. border-radius: 12px;
  1060. margin: 5vh auto;
  1061. position: relative;
  1062. overflow: hidden;
  1063. }
  1064. /* .el-bg-inner-running .el-progress-bar__inner{
  1065. background-color:unset !important;
  1066. background-image:linear-gradient(to right,#FF3C3C,#6855ff) !important
  1067. } */
  1068. /*#targetRec2{*/
  1069. /* width: 20px;*/
  1070. /* height: 200px;*/
  1071. /* background-color: black;*/
  1072. /* position: absolute;*/
  1073. /* margin-top: 100px;*/
  1074. /* margin-left: 600px;*/
  1075. /*}*/
  1076. /*#targetRec3{*/
  1077. /* width: 20px;*/
  1078. /* height: 200px;*/
  1079. /* background-color: black;*/
  1080. /* position: absolute;*/
  1081. /* margin-top: 100px;*/
  1082. /* margin-left: 600px;*/
  1083. /*}*/
  1084. .testMainDivMove {
  1085. margin: 0 auto;
  1086. margin-top: 10px;
  1087. background: black;
  1088. background-size: cover;
  1089. /* text-align:center; */
  1090. width: 500px;
  1091. height: 300px;
  1092. /* object-fit:fill; */
  1093. }
  1094. </style>