哈尔滨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'
},
hyd: {
title: '城市轨道交通实训平台',
title: '城市轨道交通综合行车模拟仿真系统',
loginPath: '/login'
},
designhyd: {

View File

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

View File

@ -28,6 +28,7 @@
// import { commitExam, getExamInfo, getUserExam, saveExamAnswer } from '@/api/exam.js';
// import WindowResizeHandler from '@/mixin/WindowResizeHandler';
import Question from './question';
import localStore from 'storejs';
import { postCompetitionTheory, getTheoryQuestion, quitCurrentRace } from '@/api/competition';
export default {
@ -52,6 +53,7 @@ export default {
},
examQuestions: [],
theoryAnswers: [],
theoryAnswersMap: {},
countdownTime: '00:00:00',
theoryExamTime: 0,
countdown: null
@ -100,8 +102,14 @@ export default {
},
methods: {
loadInitData() {
this.theoryAnswers = [];
// this.theoryAnswers = [];
this.theoryAnswersMap = {};
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) {
this.examQuestions = resp.data.questions.map((el, i) => {
el.index = i;
@ -109,6 +117,16 @@ export default {
});
this.theoryExamTime = resp.data.theoryExamTime * 60;
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(() => {
if (this.theoryExamTime <= 0) {
if (this.countdown) {
@ -166,11 +184,15 @@ export default {
});
},
onSave(data) {
// console.log(data, '');
this.theoryAnswers.push({
answerOptionId: data.answer,
questionId: data.userExamQuestionId
});
// this.theoryAnswers.push({
// answerOptionId: data.answer,
// 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) {
let hours = Math.floor(time / 3600);

View File

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