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

updata

上级 8f215059
......@@ -90,7 +90,7 @@ export default class API {
if (res.response.data) {
res.response.data.code === 0 ? err = res.response.data : new Error(JSON.stringify(res.response))
} else if (res.response.status === 500) {
err = new Error('网络超时,请稍后重试')
err = new Error('error:网络超时,请稍后重试')
} else {
new Error(JSON.stringify(res.response))
}
......
......@@ -174,6 +174,7 @@ export default {
}
}
}
console.log(this.countQuetion)
Bus.$emit('monitoringChanges')
this.$forceUpdate()
},
......@@ -183,17 +184,17 @@ export default {
}
action.Exam.setCache(this.$route.params.examId, param).then(res => {
}).catch(err => {
if (err.message === '网络超时,请稍后重试') {
if (err.message.indexOf('error') !== -1) {
this.$confirm('网络异常,请保持网络通畅', '提示', {
confirmButtonText: '重新提交',
cancelButtonText: '退出考试',
confirmButtonText: '退出考试',
cancelButtonText: '重新提交',
type: 'warning'
}).then(() => {
this.setCache()
}).catch(() => {
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 {
this.$alert(err.message, {
......
......@@ -38,11 +38,11 @@
</div>
<div class="rigth-btn">
<div class="sign" @click="signHandle">
<div class="icon"></div>
<div :class="itemSign ? 'icon active' : 'icon'"></div>
<div class="txt">{{ itemSign ? '取消标记' : '标记' }}</div>
</div>
<div class="end-exam-btn">
<div class="btn" @click="endExam">结束考试</div>
<div class="btn" @click="endExam(2)">结束考试</div>
</div>
</div>
</div>
......@@ -72,8 +72,8 @@ export default {
itemSign: false,
examTime: '00:00:00 倒计时',
clearTime: null,
sInfo: JSON.parse(window.sessionStorage.getItem('studentInfo')),
examInfo: JSON.parse(window.sessionStorage.getItem('examInfo')),
sInfo: JSON.parse(window.localStorage.getItem('studentInfo')),
examInfo: JSON.parse(window.localStorage.getItem('examInfo')),
title: '提示',
prompt: '确定后要结束本次考试?还有作答时间,结束考试后,将不能返回本次考试!',
isPopup: false,
......@@ -105,10 +105,42 @@ export default {
console.log(value)
},
// 提交考试
endExam() {
this.isExamTimeDate
? this.isPopup = true
: this.endExamRequest()
endExam(n) {
if (n === 1) {
this.$alert('考试时间到', {
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() {
const param = {
......@@ -116,25 +148,22 @@ export default {
}
action.Exam.endExam(this.$route.params.examId, param).then(res => {
clearInterval(this.clearTime)
// this.$router.push({
// path: '/examEnd'
// })
this.$router.replace({
path: '/examEnd'
})
window.sessionStorage.setItem('showflag', 'true')
window.localStorage.setItem('showflag', 'true')
}).catch(err => {
if (err.message === '网络超时,请稍后重试') {
if (err.message.indexOf('error') !== -1) {
this.$confirm('网络异常,请保持网络通畅', '提示', {
confirmButtonText: '重新提交',
cancelButtonText: '退出考试',
confirmButtonText: '退出考试',
cancelButtonText: '重新提交',
type: 'warning'
}).then(() => {
this.endExamRequest()
}).catch(() => {
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 {
this.$alert(err.message, {
......@@ -159,7 +188,7 @@ export default {
this.isExamTimeDate = false
clearInterval(this.clearTime)
this.examTime = '00:00:00 倒计时'
this.endExam()
this.endExam(1)
} else {
this.countDown(countTime)
}
......@@ -196,12 +225,28 @@ export default {
const data = JSON.parse(res.answer)
if (data !== null && data !== 'null') {
this.questionParams.answerRecord = data
this.getSignStu()
}
}).catch(err => {
this.$alert(err.message, {
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 {
height: 24px;
background: url(../../assets/images/sign.png);
background-size:100% 100%;
&.active{
background: url(../../assets/images/sign2.png);
background-size:100% 100%;
}
}
.txt{
font-size: 14px;
......
......@@ -20,7 +20,7 @@ export default {
return {
width: '',
ispop: '',
examInfo: JSON.parse(window.sessionStorage.getItem('examInfo'))
examInfo: JSON.parse(window.localStorage.getItem('examInfo'))
}
},
created() {
......@@ -28,7 +28,7 @@ export default {
},
methods: {
getsess() {
this.ispop = Boolean(window.sessionStorage.getItem('showflag'))
this.ispop = Boolean(window.localStorage.getItem('showflag'))
console.log(111 + this.ispop)
}
},
......@@ -38,8 +38,13 @@ export default {
// this.ispop = 'true'
}, 1000)
setTimeout(() => {
this.ispop = false
window.sessionStorage.removeItem('showflag')
// this.ispop = false
window.localStorage.removeItem('showflag')
setTimeout(() => {
this.$router.replace({
path: '/'
})
}, 2000)
}, 4000)
}
}
......
......@@ -35,8 +35,8 @@ export default {
},
methods: {
countDown() {
// const date = JSON.parse(window.sessionStorage.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 date = JSON.parse(window.localStorage.getItem('examInfo')).start_time
const nowtime = new Date()
const endtime = new Date(date)
const lefttime = parseInt((endtime.getTime() - nowtime.getTime()) / 1000)
......@@ -49,11 +49,11 @@ export default {
num4: '0'
}
// 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
// })
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))}`
......
......@@ -68,8 +68,8 @@ import action from '@action'
export default {
data() {
return {
sInfo: JSON.parse(window.sessionStorage.getItem('studentInfo')),
examInfo: JSON.parse(window.sessionStorage.getItem('examInfo')),
sInfo: JSON.parse(window.localStorage.getItem('studentInfo')),
examInfo: JSON.parse(window.localStorage.getItem('examInfo')),
form: {
educational_background: ''
},
......@@ -212,6 +212,19 @@ export default {
if (this.form[this.allForm[i].key] === '') {
this.$alert('请完善信息')
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 {
},
mounted() {
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
if (this.getEnabledTime() < 0) {
this.examTimeInit()
......@@ -138,7 +138,7 @@ export default {
return false
}
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)
if (status === 0) {
this.$router.replace({
......
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') },
/* 登录页面 */
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论