哈尔滨title调整&理论考试缓存调整

This commit is contained in:
fan 2020-05-29 11:08:38 +08:00
parent e5467af549
commit f21751fcd3
4 changed files with 44 additions and 18 deletions

View File

@ -32,7 +32,7 @@ export const loginInfo = { // 页面title & 退出登录跳转路径
loginPath: '/designgzb/login' loginPath: '/designgzb/login'
}, },
hyd: { hyd: {
title: '城市轨道交通实训平台', title: '城市轨道交通综合行车模拟仿真系统',
loginPath: '/login' loginPath: '/login'
}, },
designhyd: { designhyd: {

View File

@ -15,6 +15,7 @@
</div> </div>
<div class="lcd_content_box"> <div class="lcd_content_box">
<div>
<div style="display: inline-block;"> <div style="display: inline-block;">
<div class="lcd_content_box_left_title">车站</div> <div class="lcd_content_box_left_title">车站</div>
<div class="lcd_content_box_left_title">选择</div> <div class="lcd_content_box_left_title">选择</div>
@ -27,6 +28,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</template> </template>
<script> <script>
export default { export default {

View File

@ -28,6 +28,7 @@
// import { commitExam, getExamInfo, getUserExam, saveExamAnswer } from '@/api/exam.js'; // import { commitExam, getExamInfo, getUserExam, saveExamAnswer } from '@/api/exam.js';
// import WindowResizeHandler from '@/mixin/WindowResizeHandler'; // import WindowResizeHandler from '@/mixin/WindowResizeHandler';
import Question from './question'; import Question from './question';
import localStore from 'storejs';
import { postCompetitionTheory, getTheoryQuestion, quitCurrentRace } from '@/api/competition'; import { postCompetitionTheory, getTheoryQuestion, quitCurrentRace } from '@/api/competition';
export default { export default {
@ -52,6 +53,7 @@ export default {
}, },
examQuestions: [], examQuestions: [],
theoryAnswers: [], theoryAnswers: [],
theoryAnswersMap: {},
countdownTime: '00:00:00', countdownTime: '00:00:00',
theoryExamTime: 0, theoryExamTime: 0,
countdown: null countdown: null
@ -100,8 +102,14 @@ export default {
}, },
methods: { methods: {
loadInitData() { loadInitData() {
this.theoryAnswers = []; // this.theoryAnswers = [];
this.theoryAnswersMap = {};
getTheoryQuestion(this.$route.query.raceId).then((resp)=>{ getTheoryQuestion(this.$route.query.raceId).then((resp)=>{
const storeAnswersKey = this.$store.state.user.id + '' + this.$route.query.raceId + 'theoryAnswers';
const storeAnswers = localStore.get(storeAnswersKey);
if (storeAnswers) {
this.theoryAnswersMap = storeAnswers;
}
if (resp.data) { if (resp.data) {
this.examQuestions = resp.data.questions.map((el, i) => { this.examQuestions = resp.data.questions.map((el, i) => {
el.index = i; el.index = i;
@ -109,6 +117,16 @@ export default {
}); });
this.theoryExamTime = resp.data.theoryExamTime * 60; this.theoryExamTime = resp.data.theoryExamTime * 60;
this.countdownTime = this.computationTime(this.theoryExamTime); this.countdownTime = this.computationTime(this.theoryExamTime);
const storeKey = this.$store.state.user.id + '' + this.$route.query.raceId + 'theory';
const startTime = localStore.get(storeKey);
if (startTime) {
const dt = new Date().getTime() - startTime;
this.theoryExamTime = resp.data.theoryExamTime * 60 - Math.floor(dt / 1000);
} else {
const storeValue = new Date().getTime();
localStore.set(storeKey, storeValue);
}
this.countdown = setInterval(() => { this.countdown = setInterval(() => {
if (this.theoryExamTime <= 0) { if (this.theoryExamTime <= 0) {
if (this.countdown) { if (this.countdown) {
@ -166,11 +184,15 @@ export default {
}); });
}, },
onSave(data) { onSave(data) {
// console.log(data, ''); // this.theoryAnswers.push({
this.theoryAnswers.push({ // answerOptionId: data.answer,
answerOptionId: data.answer, // questionId: data.userExamQuestionId
questionId: data.userExamQuestionId // });
}); this.theoryAnswersMap[data.userExamQuestionId] = data.answer;
// console.log(data, '', this.theoryAnswers, this.theoryAnswersMap);
const storeKey = this.$store.state.user.id + '' + this.$route.query.raceId + 'theoryAnswers';
localStore.set(storeKey, this.theoryAnswersMap);
}, },
computationTime(time) { computationTime(time) {
let hours = Math.floor(time / 3600); let hours = Math.floor(time / 3600);

View File

@ -69,7 +69,7 @@ import { setSessionStorage, removeSessionStorage } from '@/utils/auth';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import md5 from 'js-md5'; import md5 from 'js-md5';
import { UrlConfig } from '@/scripts/ConstDic'; import { UrlConfig } from '@/scripts/ConstDic';
import { ProjectIcon } from '@/scripts/ProjectConfig'; import { loginInfo, ProjectIcon } from '@/scripts/ProjectConfig';
import { removeToken } from '@/utils/auth'; import { removeToken } from '@/utils/auth';
import LangStorage from '@/utils/lang'; import LangStorage from '@/utils/lang';
import logoImgHyd from '@/assets/project_icon/logo_hyd.png'; import logoImgHyd from '@/assets/project_icon/logo_hyd.png';
@ -121,7 +121,7 @@ export default {
lang: 'zh', lang: 'zh',
language: '中文', language: '中文',
logoImg: logoImgHyd, logoImg: logoImgHyd,
title: '城市轨道交通实训平台' title: ''
}; };
}, },
computed: { computed: {
@ -151,7 +151,9 @@ export default {
}, },
mounted() { mounted() {
if (this.project.startsWith('design')) { if (this.project.startsWith('design')) {
this.title = '城市轨道交通设计平台'; this.title = loginInfo['designhyd'].title;
} else {
this.title = loginInfo['hyd'].title;
} }
document.title = this.title; document.title = this.title;
}, },