提交 81f1098d authored 作者: lihuihui's avatar lihuihui

updata

上级 8f215059
...@@ -90,7 +90,7 @@ export default class API { ...@@ -90,7 +90,7 @@ export default class API {
if (res.response.data) { if (res.response.data) {
res.response.data.code === 0 ? err = res.response.data : new Error(JSON.stringify(res.response)) res.response.data.code === 0 ? err = res.response.data : new Error(JSON.stringify(res.response))
} else if (res.response.status === 500) { } else if (res.response.status === 500) {
err = new Error('网络超时,请稍后重试') err = new Error('error:网络超时,请稍后重试')
} else { } else {
new Error(JSON.stringify(res.response)) new Error(JSON.stringify(res.response))
} }
......
...@@ -174,6 +174,7 @@ export default { ...@@ -174,6 +174,7 @@ export default {
} }
} }
} }
console.log(this.countQuetion)
Bus.$emit('monitoringChanges') Bus.$emit('monitoringChanges')
this.$forceUpdate() this.$forceUpdate()
}, },
...@@ -183,17 +184,17 @@ export default { ...@@ -183,17 +184,17 @@ export default {
} }
action.Exam.setCache(this.$route.params.examId, param).then(res => { action.Exam.setCache(this.$route.params.examId, param).then(res => {
}).catch(err => { }).catch(err => {
if (err.message === '网络超时,请稍后重试') { if (err.message.indexOf('error') !== -1) {
this.$confirm('网络异常,请保持网络通畅', '提示', { this.$confirm('网络异常,请保持网络通畅', '提示', {
confirmButtonText: '重新提交', confirmButtonText: '退出考试',
cancelButtonText: '退出考试', cancelButtonText: '重新提交',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.setCache()
}).catch(() => {
this.$router.replace({ this.$router.replace({
path: `/login/${JSON.parse(window.sessionStorage.getItem('examInfo')).exam_id}` path: `/login/${JSON.parse(window.localStorage.getItem('examInfo')).exam_id}`
}) })
}).catch(() => {
this.endExamRequest()
}) })
} else { } else {
this.$alert(err.message, { this.$alert(err.message, {
......
...@@ -38,11 +38,11 @@ ...@@ -38,11 +38,11 @@
</div> </div>
<div class="rigth-btn"> <div class="rigth-btn">
<div class="sign" @click="signHandle"> <div class="sign" @click="signHandle">
<div class="icon"></div> <div :class="itemSign ? 'icon active' : 'icon'"></div>
<div class="txt">{{ itemSign ? '取消标记' : '标记' }}</div> <div class="txt">{{ itemSign ? '取消标记' : '标记' }}</div>
</div> </div>
<div class="end-exam-btn"> <div class="end-exam-btn">
<div class="btn" @click="endExam">结束考试</div> <div class="btn" @click="endExam(2)">结束考试</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -72,8 +72,8 @@ export default { ...@@ -72,8 +72,8 @@ export default {
itemSign: false, itemSign: false,
examTime: '00:00:00 倒计时', examTime: '00:00:00 倒计时',
clearTime: null, clearTime: null,
sInfo: JSON.parse(window.sessionStorage.getItem('studentInfo')), sInfo: JSON.parse(window.localStorage.getItem('studentInfo')),
examInfo: JSON.parse(window.sessionStorage.getItem('examInfo')), examInfo: JSON.parse(window.localStorage.getItem('examInfo')),
title: '提示', title: '提示',
prompt: '确定后要结束本次考试?还有作答时间,结束考试后,将不能返回本次考试!', prompt: '确定后要结束本次考试?还有作答时间,结束考试后,将不能返回本次考试!',
isPopup: false, isPopup: false,
...@@ -105,10 +105,42 @@ export default { ...@@ -105,10 +105,42 @@ export default {
console.log(value) console.log(value)
}, },
// 提交考试 // 提交考试
endExam() { endExam(n) {
this.isExamTimeDate if (n === 1) {
? this.isPopup = true this.$alert('考试时间到', {
: this.endExamRequest() confirmButtonText: '确定',
callback: action => {
this.endExamRequest()
}
})
} else {
const count = parseInt(this.questionParams.question.total_question_count) - parseInt(this.countAnswer())
if (count === 0) {
this.endExamRequest()
} else {
this.$confirm(`确定要结束本次考试?还有${count}题未答,结束考试后,将不能反悔本次考试`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.endExamRequest()
}).catch(() => {
})
}
}
},
countAnswer() {
let countNum = 0
const data = this.questionParams.answerRecord
for (const item in data) {
const list = Object.values(data[item])
for (let i = 0; i < list.length; i++) {
if (list[i].answer.length) {
countNum++
}
}
}
return countNum
}, },
endExamRequest() { endExamRequest() {
const param = { const param = {
...@@ -116,25 +148,22 @@ export default { ...@@ -116,25 +148,22 @@ export default {
} }
action.Exam.endExam(this.$route.params.examId, param).then(res => { action.Exam.endExam(this.$route.params.examId, param).then(res => {
clearInterval(this.clearTime) clearInterval(this.clearTime)
// this.$router.push({
// path: '/examEnd'
// })
this.$router.replace({ this.$router.replace({
path: '/examEnd' path: '/examEnd'
}) })
window.sessionStorage.setItem('showflag', 'true') window.localStorage.setItem('showflag', 'true')
}).catch(err => { }).catch(err => {
if (err.message === '网络超时,请稍后重试') { if (err.message.indexOf('error') !== -1) {
this.$confirm('网络异常,请保持网络通畅', '提示', { this.$confirm('网络异常,请保持网络通畅', '提示', {
confirmButtonText: '重新提交', confirmButtonText: '退出考试',
cancelButtonText: '退出考试', cancelButtonText: '重新提交',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.endExamRequest()
}).catch(() => {
this.$router.replace({ this.$router.replace({
path: `/login/${JSON.parse(window.sessionStorage.getItem('examInfo')).exam_id}` path: `/login/${JSON.parse(window.localStorage.getItem('examInfo')).exam_id}`
}) })
}).catch(() => {
this.endExamRequest()
}) })
} else { } else {
this.$alert(err.message, { this.$alert(err.message, {
...@@ -159,7 +188,7 @@ export default { ...@@ -159,7 +188,7 @@ export default {
this.isExamTimeDate = false this.isExamTimeDate = false
clearInterval(this.clearTime) clearInterval(this.clearTime)
this.examTime = '00:00:00 倒计时' this.examTime = '00:00:00 倒计时'
this.endExam() this.endExam(1)
} else { } else {
this.countDown(countTime) this.countDown(countTime)
} }
...@@ -196,12 +225,28 @@ export default { ...@@ -196,12 +225,28 @@ export default {
const data = JSON.parse(res.answer) const data = JSON.parse(res.answer)
if (data !== null && data !== 'null') { if (data !== null && data !== 'null') {
this.questionParams.answerRecord = data this.questionParams.answerRecord = data
this.getSignStu()
} }
}).catch(err => { }).catch(err => {
this.$alert(err.message, { this.$alert(err.message, {
callback: action => {} callback: action => {}
}) })
}) })
},
getSignStu() {
this.questionParams.question.question_items.map((item, index) => {
const currentItem = item.question_list.find(items => {
return items.q_order === this.questionParams.questionIndex + 1
})
if (currentItem) {
const data = this.questionParams.answerRecord
if (data[currentItem.question_item_id]) {
if (data[currentItem.question_item_id][currentItem.id]) {
this.itemSign = data[currentItem.question_item_id][currentItem.id].sign
}
}
}
})
} }
} }
} }
...@@ -336,6 +381,10 @@ export default { ...@@ -336,6 +381,10 @@ export default {
height: 24px; height: 24px;
background: url(../../assets/images/sign.png); background: url(../../assets/images/sign.png);
background-size:100% 100%; background-size:100% 100%;
&.active{
background: url(../../assets/images/sign2.png);
background-size:100% 100%;
}
} }
.txt{ .txt{
font-size: 14px; font-size: 14px;
......
...@@ -20,7 +20,7 @@ export default { ...@@ -20,7 +20,7 @@ export default {
return { return {
width: '', width: '',
ispop: '', ispop: '',
examInfo: JSON.parse(window.sessionStorage.getItem('examInfo')) examInfo: JSON.parse(window.localStorage.getItem('examInfo'))
} }
}, },
created() { created() {
...@@ -28,7 +28,7 @@ export default { ...@@ -28,7 +28,7 @@ export default {
}, },
methods: { methods: {
getsess() { getsess() {
this.ispop = Boolean(window.sessionStorage.getItem('showflag')) this.ispop = Boolean(window.localStorage.getItem('showflag'))
console.log(111 + this.ispop) console.log(111 + this.ispop)
} }
}, },
...@@ -38,8 +38,13 @@ export default { ...@@ -38,8 +38,13 @@ export default {
// this.ispop = 'true' // this.ispop = 'true'
}, 1000) }, 1000)
setTimeout(() => { setTimeout(() => {
this.ispop = false // this.ispop = false
window.sessionStorage.removeItem('showflag') window.localStorage.removeItem('showflag')
setTimeout(() => {
this.$router.replace({
path: '/'
})
}, 2000)
}, 4000) }, 4000)
} }
} }
......
...@@ -35,8 +35,8 @@ export default { ...@@ -35,8 +35,8 @@ export default {
}, },
methods: { methods: {
countDown() { countDown() {
// const date = JSON.parse(window.sessionStorage.getItem('examInfo')).start_time // const date = JSON.parse(window.localStorage.getItem('examInfo')).start_time
const date = JSON.parse(window.sessionStorage.getItem('examInfo')).start_time const date = JSON.parse(window.localStorage.getItem('examInfo')).start_time
const nowtime = new Date() const nowtime = new Date()
const endtime = new Date(date) const endtime = new Date(date)
const lefttime = parseInt((endtime.getTime() - nowtime.getTime()) / 1000) const lefttime = parseInt((endtime.getTime() - nowtime.getTime()) / 1000)
...@@ -49,11 +49,11 @@ export default { ...@@ -49,11 +49,11 @@ export default {
num4: '0' num4: '0'
} }
// this.$router.push({ // this.$router.push({
// path: `/examAnswer/${JSON.parse(window.sessionStorage.getItem('examInfo')).exam_id}`, // path: `/examAnswer/${JSON.parse(window.localStorage.getItem('examInfo')).exam_id}`,
// replace: true // replace: true
// }) // })
this.$router.replace({ this.$router.replace({
path: `/examAnswer/${JSON.parse(window.sessionStorage.getItem('examInfo')).exam_id}` path: `/examAnswer/${JSON.parse(window.localStorage.getItem('examInfo')).exam_id}`
}) })
} }
const td = `${this.addZero(parseInt(lefttime / 60 % 60))}${this.addZero(parseInt(lefttime % 60))}` const td = `${this.addZero(parseInt(lefttime / 60 % 60))}${this.addZero(parseInt(lefttime % 60))}`
......
...@@ -68,8 +68,8 @@ import action from '@action' ...@@ -68,8 +68,8 @@ import action from '@action'
export default { export default {
data() { data() {
return { return {
sInfo: JSON.parse(window.sessionStorage.getItem('studentInfo')), sInfo: JSON.parse(window.localStorage.getItem('studentInfo')),
examInfo: JSON.parse(window.sessionStorage.getItem('examInfo')), examInfo: JSON.parse(window.localStorage.getItem('examInfo')),
form: { form: {
educational_background: '' educational_background: ''
}, },
...@@ -212,6 +212,19 @@ export default { ...@@ -212,6 +212,19 @@ export default {
if (this.form[this.allForm[i].key] === '') { if (this.form[this.allForm[i].key] === '') {
this.$alert('请完善信息') this.$alert('请完善信息')
return false return false
} else {
if (this.allForm[i].key === 'mobile') {
if (!(/^1[3456789]\d{9}$/.test(this.form.mobile))) {
this.$alert('手机号不正确')
return false
}
}
if (this.allForm[i].key === 'email') {
if (!(/^([a-zA-Z\d])(\w)+@[a-zA-Z\d]+\.[a-zA-Z]{2,4}$/.test(this.form.email))) {
this.$alert('邮箱不正确')
return false
}
}
} }
} }
} }
......
...@@ -52,7 +52,7 @@ export default { ...@@ -52,7 +52,7 @@ export default {
}, },
mounted() { mounted() {
action.Login.getExamInfo(this.$route.params.examId).then(res => { action.Login.getExamInfo(this.$route.params.examId).then(res => {
window.sessionStorage.setItem('examInfo', JSON.stringify(res)) window.localStorage.setItem('examInfo', JSON.stringify(res))
this.data = res this.data = res
if (this.getEnabledTime() < 0) { if (this.getEnabledTime() < 0) {
this.examTimeInit() this.examTimeInit()
...@@ -138,7 +138,7 @@ export default { ...@@ -138,7 +138,7 @@ export default {
return false return false
} }
action.Login.userLogin(this.data.exam_id, { examinee_number: this.examineeNumber }).then(res => { action.Login.userLogin(this.data.exam_id, { examinee_number: this.examineeNumber }).then(res => {
window.sessionStorage.setItem('studentInfo', JSON.stringify(res)) window.localStorage.setItem('studentInfo', JSON.stringify(res))
const status = parseInt(res.sheet_status) const status = parseInt(res.sheet_status)
if (status === 0) { if (status === 0) {
this.$router.replace({ this.$router.replace({
......
export default [ export default [
{ path: '/', redirect: '/login/1' }, { path: '/', redirect: `/login/${JSON.parse(window.localStorage.getItem('examInfo')) ? JSON.parse(window.localStorage.getItem('examInfo')).exam_id : '*'}` },
/* 测试页面 */ /* 测试页面 */
{ path: '/test', name: 'test', component: () => import('../pages/test.vue') }, { path: '/test', name: 'test', component: () => import('../pages/test.vue') },
/* 登录页面 */ /* 登录页面 */
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论