提交 cb6821b7 authored 作者: 王鹏飞's avatar 王鹏飞

chore: 优化代码

上级 80eb10b1
-----BEGIN RSA PRIVATE KEY----- -----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAn0EINdIXTDCzmR7J5FOjOV+PbXt7GNO6fanoCGe2O0CPRlNf MIIEpAIBAAKCAQEAucCbdPPyAp6vmnr5XObuPsctUhVLyXwqbIpgI5jWzjG7wmk8
2Ea/wv6SlRtJPd0ohmnKqZdUbBpAsiV4ggOdOqeEB6utVYQWY/zhXRKYeRjN/iDu V6z8WJKPO9KZM6D9ejtN/bbbd3j1cRiw7NSl8AUykiVHJWz9TXAflET2EpILLera
WCRY5S+eRVkSzVOJP9DlBn6dnHSsWj55h1PrkIac8B862F/cVno/Wk5dqU55ZUoN I1B2XAcBsc8dZBGGJD/LT97ZvNLYzuQOr7R1wytWH1uisAK5ClzgnSptMenXFyhw
wHGw5Goz3R37w+Q0C9HRS5mrmPqI+Ogy8TJrIRxw9YAj5OlvuqBAeYAW1sNdEfsi 5Xw0Lm3zoeeqYF/KMQ1McAYMGxgu6s6dxXKiA0BcgWQ31yZey0c4HhCt7T7sA/UN
mMB0H2fbbXqEL4AsipE5ppP7Ij3vxVpxvmnl/SO7N6+Fit6r25VeFSvplK+PIV3c ahUsxtCcSNSvdgXay5Pu/l3N88TwW2QzaCzrueILHWRFwkREhpqyrwjN3gkaa+1T
UsK3PCKV2sOo0BDWtWFQh5hW3fK5RYjLpNDHCwIDAQABAoIBAEkiBDMzF5/VfaSD jLxzCsk/pTnPccxlFwc3YQ3hYLMl36NJ/OIpHwIDAQABAoIBACuMmaXYz6OHmroI
jxNblUlzqNoOKqlsEehDblrtxbHQI/uXrhwT4VwarBXtQeU2+rU/P+JBrHM4Wx10 HNCIH9E+F0UIUyVg4/1gj9uoqKvdAx04WPphRyRo8AXhgSOWmfb/UnCqX1fqVvj2
N7L9FecppmgfXqo2zlF8f8HOGFcEHRTm6o1vo6McCwKttQS1qAG2XHZvDtIag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wTfmV74szsEDcFkg038zQ6Q4c8iiurYp29nwEM7/mayBGOcv /Fw4rTMwT59VSWJdv8BPznV7Gk7p17fcXM55iJxxu65r3ZuOXjQSGA==
-----END RSA PRIVATE KEY----- -----END RSA PRIVATE KEY-----
\ No newline at end of file
差异被折叠。
...@@ -5,13 +5,13 @@ export default class ExamAPI extends BaseAPI { ...@@ -5,13 +5,13 @@ export default class ExamAPI extends BaseAPI {
* 获取考试信息 * 获取考试信息
* @param {[string]} examId resource_id * @param {[string]} examId resource_id
*/ */
getTopic = (examId) => this.get(`/xexam/v1/exam/sheet/${examId}`, {}) getTopic = examId => this.get(`/xexam/v1/exam/sheet/${examId}`, {})
/* 缓存考试 */ /* 缓存考试 */
setCache = (examId = {}, obj = {}) => this.post(`/xexam/v1/exam/cache/${examId}`, obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }) setCache = (examId = '', obj = {}) => this.post(`/xexam/v1/exam/cache/${examId}`, obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/* 获取缓存 */ /* 获取缓存 */
getCache = (examId) => this.get(`/xexam/v1/exam/cache/${examId}`, {}) getCache = examId => this.get(`/xexam/v1/exam/cache/${examId}`, {})
/* 缓存考试 */ /* 缓存考试 */
endExam = (examId = {}, obj = {}) => this.post(`/xexam/v1/exam/sheet/${examId}`, obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }) endExam = (examId = '', obj = {}) => this.post(`/xexam/v1/exam/sheet/${examId}`, obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/** /**
* 进入考试 * 进入考试
*/ */
......
...@@ -5,7 +5,7 @@ export default class TestAPI extends BaseAPI { ...@@ -5,7 +5,7 @@ export default class TestAPI extends BaseAPI {
* 获取考试信息 * 获取考试信息
* @param {[string]} examId resource_id * @param {[string]} examId resource_id
*/ */
getExamInfo = (examId) => this.get(`/xexam/v1/exam/view/${examId}`, {}) getExamInfo = examId => this.get(`/xexam/v1/exam/view/${examId}`, {})
/** /**
* 进入考试 * 进入考试
*/ */
......
...@@ -5,14 +5,14 @@ export default class TestAPI extends BaseAPI { ...@@ -5,14 +5,14 @@ export default class TestAPI extends BaseAPI {
* get传输方式 * get传输方式
* @param {[string]} id resource_id * @param {[string]} id resource_id
*/ */
getTest = (id) => this.get(`/vue-client/get/${id}`, {}) getTest = id => this.get(`/vue-client/get/${id}`, {})
/** /**
* post传输方式 * post传输方式
* @param {[object]} obj * @param {[object]} obj
*/ */
postTest = (obj = {}) => this.post('/passport/rest/login', obj, { headers: { 'Content-Type': 'multipart/form-data' } }) postTest = (obj = {}) => this.post('/passport/rest/login', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/** /**
* 当前登录用户,检测是否该系统有权限 * 当前登录用户,检测是否该系统有权限
*/ */
getInfo = () => this.post('/user_center/get_user_info', {}, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }) getInfo = () => this.post('/user_center/get_user_info', {}, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
} }
...@@ -3,14 +3,7 @@ ...@@ -3,14 +3,7 @@
<div ref="wrapper"> <div ref="wrapper">
<div class="info"> <div class="info">
<div class="shape"> <div class="shape">
<img <img :src="info.id_photo ? info.id_photo : 'https://zws-imgs-pub.ezijing.com/static/public/e0c63e4d4554f0852e1558426aad20d1.png'" />
:src="
info.id_photo
? info.id_photo
: 'https://zws-imgs-pub.ezijing.com/static/public/e0c63e4d4554f0852e1558426aad20d1.png'
"
alt=""
/>
</div> </div>
<div class="right"> <div class="right">
<div class="name">{{ info.name }}</div> <div class="name">{{ info.name }}</div>
...@@ -132,8 +125,7 @@ export default { ...@@ -132,8 +125,7 @@ export default {
info: { type: Object, default: () => {} } info: { type: Object, default: () => {} }
}, },
data() { data() {
return { return {}
}
}, },
mounted() { mounted() {
if (!this.isMobile()) { if (!this.isMobile()) {
...@@ -196,7 +188,7 @@ export default { ...@@ -196,7 +188,7 @@ export default {
} }
} }
} }
.order-scroll{ .order-scroll {
// max-height: 100px; // max-height: 100px;
// overflow-y: scroll; // overflow-y: scroll;
} }
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<!-- <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> --> <!-- <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> -->
<!-- <meta http-equiv="Pragma" content="no-cache" /> --> <!-- <meta http-equiv="Pragma" content="no-cache" /> -->
<!-- <meta http-equiv="Expires" content="0" /> --> <!-- <meta http-equiv="Expires" content="0" /> -->
<title>标题</title> <title></title>
<meta name="viewport" id="viewport" content="initial-scale=-1,maximum-scale=1,shrink-to-fit=no,user-scalable=no" /> <meta name="viewport" id="viewport" content="initial-scale=-1,maximum-scale=1,shrink-to-fit=no,user-scalable=no" />
</head> </head>
<body> <body>
......
...@@ -25,12 +25,7 @@ ...@@ -25,12 +25,7 @@
</div> </div>
</div> </div>
<div :class="isMobile() ? 'right scroll' : 'right hidden'" ref="wrapper"> <div :class="isMobile() ? 'right scroll' : 'right hidden'" ref="wrapper">
<answer-card <answer-card :questionParams="questionParams" :changeTime="changeTime" :info="studentInfo" @switchQuestion="switchQuestion"></answer-card>
:questionParams="questionParams"
:changeTime="changeTime"
:info="sInfo.info"
@switchQuestion="switchQuestion"
></answer-card>
</div> </div>
<ul class="flag-tips"> <ul class="flag-tips">
<li> <li>
...@@ -56,10 +51,7 @@ ...@@ -56,10 +51,7 @@
<div @click="changeIndex('prev')" :class="this.questionParams.questionIndex !== 0 ? 'active' : ''"> <div @click="changeIndex('prev')" :class="this.questionParams.questionIndex !== 0 ? 'active' : ''">
上一题 上一题
</div> </div>
<div <div :class="questionParams.questionIndex + 1 !== questionParams.question.total_question_count ? 'active' : ''" @click="changeIndex('next')">
:class="questionParams.questionIndex + 1 !== questionParams.question.total_question_count ? 'active' : ''"
@click="changeIndex('next')"
>
下一题 下一题
</div> </div>
</div> </div>
...@@ -91,7 +83,7 @@ import BScroll from 'better-scroll' ...@@ -91,7 +83,7 @@ import BScroll from 'better-scroll'
export default { export default {
metaInfo() { metaInfo() {
return { return {
title: JSON.parse(window.localStorage.getItem('examInfo')).name || '' title: this.examInfo.name || ''
} }
}, },
components: { components: {
...@@ -100,14 +92,23 @@ export default { ...@@ -100,14 +92,23 @@ export default {
'my-dia': dialogComponent 'my-dia': dialogComponent
}, },
data() { data() {
let studentInfo = {}
let examInfo = {}
try {
studentInfo = JSON.parse(window.localStorage.getItem('studentInfo'))
examInfo = JSON.parse(window.localStorage.getItem('examInfo'))
} catch (error) {
console.log(error)
}
return { return {
isExamEnd: false, isExamEnd: false,
isExamTimeDate: true, isExamTimeDate: true,
itemSign: false, itemSign: false,
examTime: '00:00:00 倒计时', examTime: '00:00:00 倒计时',
clearTime: null, clearTime: null,
sInfo: JSON.parse(window.localStorage.getItem('studentInfo')), studentInfo,
examInfo: JSON.parse(window.localStorage.getItem('examInfo')), examInfo,
title: '提示', title: '提示',
prompt: '确定后要结束本次考试?还有作答时间,结束考试后,将不能返回本次考试!', prompt: '确定后要结束本次考试?还有作答时间,结束考试后,将不能返回本次考试!',
isPopup: false, isPopup: false,
...@@ -125,6 +126,20 @@ export default { ...@@ -125,6 +126,20 @@ export default {
} }
} }
}, },
computed: {
examId() {
return this.$route.params.examId || this.examInfo.exam_id
},
changeQuestionIndex() {
return this.questionParams.questionIndex
}
},
watch: {
changeQuestionIndex(newV, oldV) {
this.refreshBscroll()
}
},
mounted() { mounted() {
// this.sendExamInfo(3) // this.sendExamInfo(3)
this.setTick() this.setTick()
...@@ -149,8 +164,8 @@ export default { ...@@ -149,8 +164,8 @@ export default {
}, },
sendExamInfo(status) { sendExamInfo(status) {
const param = { const param = {
student_id: this.sInfo.info.student_id, student_id: this.studentInfo.student_id,
exam_id: this.examInfo.exam_id, exam_id: this.examId,
status: status status: status
} }
action.Login.sendExamInfo(param) action.Login.sendExamInfo(param)
...@@ -160,9 +175,7 @@ export default { ...@@ -160,9 +175,7 @@ export default {
}) })
}, },
countHeight() { countHeight() {
this.contentHeight = parseInt( this.contentHeight = parseInt(document.body.clientHeight - (this.getDom('head-h').offsetHeight + this.getDom('foot-h').offsetHeight))
document.body.clientHeight - (this.getDom('head-h').offsetHeight + this.getDom('foot-h').offsetHeight)
)
}, },
// 标记 // 标记
signHandle() { signHandle() {
...@@ -178,12 +191,7 @@ export default { ...@@ -178,12 +191,7 @@ export default {
this.$alert('考试时间到', { this.$alert('考试时间到', {
confirmButtonText: '确定', confirmButtonText: '确定',
callback: action => { callback: action => {
this.$router.replace({ this.$router.replace({ path: '/examEnd', query: { id: this.examId } })
path: '/examEnd',
query: {
id: JSON.parse(window.localStorage.getItem('examInfo')).exam_id
}
})
} }
}) })
} else { } else {
...@@ -229,7 +237,7 @@ export default { ...@@ -229,7 +237,7 @@ export default {
const param = { const param = {
answer: JSON.stringify(this.questionParams.answerRecord) answer: JSON.stringify(this.questionParams.answerRecord)
} }
action.Exam.endExam(this.$route.params.examId, param).then(res => { action.Exam.endExam(this.examId, param).then(res => {
if (!n) { if (!n) {
clearInterval(this.clearTime) clearInterval(this.clearTime)
this.$router.replace({ this.$router.replace({
...@@ -249,7 +257,7 @@ export default { ...@@ -249,7 +257,7 @@ export default {
// }) // })
// .then(() => { // .then(() => {
// this.$router.replace({ // this.$router.replace({
// path: `/login/${JSON.parse(window.localStorage.getItem('examInfo')).exam_id}` // path: `/login/${this.examId}`
// }) // })
// }) // })
// .catch(action => { // .catch(action => {
...@@ -263,18 +271,18 @@ export default { ...@@ -263,18 +271,18 @@ export default {
// }) // })
}, },
countDown(time) { countDown(time) {
const lefttime = parseInt(time / 1000) const leftTime = parseInt(time / 1000)
const h = this.addZero(parseInt((lefttime / (60 * 60)) % 24)) const h = this.addZero(parseInt((leftTime / (60 * 60)) % 24))
const m = this.addZero(parseInt((lefttime / 60) % 60)) const m = this.addZero(parseInt((leftTime / 60) % 60))
const s = this.addZero(parseInt(lefttime % 60)) const s = this.addZero(parseInt(leftTime % 60))
this.examTime = `${h} : ${m} : ${s} 倒计时` this.examTime = `${h} : ${m} : ${s} 倒计时`
}, },
setTick() { setTick() {
let flag = true let flag = true
this.clearTime = setInterval(() => { this.clearTime = setInterval(() => {
const nowtime = new Date() const nowTime = new Date()
const endtime = new Date(this.examInfo.end_time.replace(/-/g, '/')) const endTime = new Date(this.examInfo.end_time.replace(/-/g, '/'))
const countTime = endtime.getTime() - nowtime.getTime() const countTime = endTime.getTime() - nowTime.getTime()
if (countTime <= 0) { if (countTime <= 0) {
this.isExamTimeDate = false this.isExamTimeDate = false
clearInterval(this.clearTime) clearInterval(this.clearTime)
...@@ -305,8 +313,7 @@ export default { ...@@ -305,8 +313,7 @@ export default {
if (type === 'prev') { if (type === 'prev') {
this.questionParams.questionIndex > 0 && this.questionParams.questionIndex-- this.questionParams.questionIndex > 0 && this.questionParams.questionIndex--
} else { } else {
this.questionParams.questionIndex + 1 !== this.questionParams.question.total_question_count && this.questionParams.questionIndex + 1 !== this.questionParams.question.total_question_count && this.questionParams.questionIndex++
this.questionParams.questionIndex++
} }
this.refreshBscroll() this.refreshBscroll()
}, },
...@@ -322,7 +329,7 @@ export default { ...@@ -322,7 +329,7 @@ export default {
this.refreshBscroll() this.refreshBscroll()
}, },
getTopic() { getTopic() {
action.Exam.getTopic(this.$route.params.examId) action.Exam.getTopic(this.examId)
.then(res => { .then(res => {
this.questionParams.question = res this.questionParams.question = res
this.getCache() this.getCache()
...@@ -333,8 +340,8 @@ export default { ...@@ -333,8 +340,8 @@ export default {
}) })
}, },
getCache() { getCache() {
if (this.$route.params.examId) { if (this.examId) {
action.Exam.getCache(this.$route.params.examId) action.Exam.getCache(this.examId)
.then(res => { .then(res => {
const data = JSON.parse(res.answer) const data = JSON.parse(res.answer)
if (data !== null && data !== 'null') { if (data !== null && data !== 'null') {
...@@ -371,16 +378,6 @@ export default { ...@@ -371,16 +378,6 @@ export default {
const isPc = !isPhone && !isAndroid && !isSymbian const isPc = !isPhone && !isAndroid && !isSymbian
return isPc return isPc
} }
},
computed: {
changeQuestionIndex() {
return this.questionParams.questionIndex
}
},
watch: {
changeQuestionIndex(newV, oldV) {
this.refreshBscroll()
}
} }
} }
</script> </script>
......
...@@ -13,20 +13,8 @@ ...@@ -13,20 +13,8 @@
<div :class="loginParam.is ? 'form prohibit' : 'form'"> <div :class="loginParam.is ? 'form prohibit' : 'form'">
<div class="tips">{{ tips }}</div> <div class="tips">{{ tips }}</div>
<!-- 您登录的次数已超过最大限制 --> <!-- 您登录的次数已超过最大限制 -->
<input <input type="text" v-model="examineeNumber" placeholder="请输入准考证号" v-show="!loginParam.is" @keydown="keydown($event)" />
type="text" <input type="text" placeholder="请输入准考证号" readonly="readonly" class="prohibit" v-show="loginParam.is" />
v-model="examineeNumber"
placeholder="请输入准考证号"
v-show="!loginParam.is"
@keydown="keydown($event)"
/>
<input
type="text"
placeholder="请输入准考证号"
readonly="readonly"
class="prohibit"
v-show="loginParam.is"
/>
<div class="btn" @click="login">登录</div> <div class="btn" @click="login">登录</div>
<!-- <div class="btn prohibit">登录</div> --> <!-- <div class="btn prohibit">登录</div> -->
<div class="time-tips" v-show="loginParam.is">{{ loginParam.countTimeText }}</div> <div class="time-tips" v-show="loginParam.is">{{ loginParam.countTimeText }}</div>
...@@ -34,7 +22,7 @@ ...@@ -34,7 +22,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="welcome-msg mian-cont900" v-if="data" v-html="data.config.welcome_message"></div> <div class="welcome-msg mian-cont900" v-if="data && data.config" v-html="data.config.welcome_message"></div>
</div> </div>
</template> </template>
<script> <script>
...@@ -46,16 +34,16 @@ export default { ...@@ -46,16 +34,16 @@ export default {
}, },
metaInfo() { metaInfo() {
return { return {
title: JSON.parse(window.localStorage.getItem('examInfo')).name || '' title: this.data.name
} }
}, },
data() { data() {
return { return {
tips: '', tips: '',
claerExamTime: null, clearExamTime: null,
title: '提示', title: '提示',
prompt: '不能退出全屏', prompt: '不能退出全屏',
data: '', data: {},
examineeNumber: '', examineeNumber: '',
isPopup: false, isPopup: false,
loginParam: { loginParam: {
...@@ -65,6 +53,11 @@ export default { ...@@ -65,6 +53,11 @@ export default {
} }
} }
}, },
computed: {
examId() {
return this.$route.params.examId
}
},
mounted() { mounted() {
this.getExamInfo() this.getExamInfo()
this.tipsMobileAngle() this.tipsMobileAngle()
...@@ -78,10 +71,7 @@ export default { ...@@ -78,10 +71,7 @@ export default {
const winWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || 0 const winWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || 0
const winHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0 const winHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0
if (winHeight > winWidth) { if (winHeight > winWidth) {
this.$message({ this.$message({ message: '请横屏预览', type: 'warning' })
message: '请横屏预览',
type: 'warning'
})
} }
} }
}, },
...@@ -89,19 +79,19 @@ export default { ...@@ -89,19 +79,19 @@ export default {
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
}, },
getExamInfo() { getExamInfo() {
action.Login.getExamInfo(this.$route.params.examId).then(res => { action.Login.getExamInfo(this.examId).then(res => {
window.localStorage.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()
} else { } else {
let claearTimes = null let clearTimes = null
claearTimes = setInterval(() => { clearTimes = setInterval(() => {
// console.log(this.getAfterTime()) // console.log(this.getAfterTime())
if (this.getAfterTime() <= 0) { if (this.getAfterTime() <= 0) {
this.tips = '超过登录时间' this.tips = '超过登录时间'
this.loginParam.is = true this.loginParam.is = true
clearInterval(claearTimes) clearInterval(clearTimes)
} }
}, 1000) }, 1000)
this.loginParam.is = false this.loginParam.is = false
...@@ -109,11 +99,7 @@ export default { ...@@ -109,11 +99,7 @@ export default {
}) })
}, },
sendExamInfo(studentId) { sendExamInfo(studentId) {
const param = { const param = { student_id: studentId, exam_id: this.examId, status: 2 }
student_id: studentId,
exam_id: this.data.exam_id,
status: 2
}
action.Login.sendExamInfo(param) action.Login.sendExamInfo(param)
.then(res => {}) .then(res => {})
.catch(err => { .catch(err => {
...@@ -126,25 +112,23 @@ export default { ...@@ -126,25 +112,23 @@ export default {
}, },
getAfterTime() { getAfterTime() {
const curTime = new Date() const curTime = new Date()
const endtTime = new Date(this.data.end_time) const endTime = new Date(this.data.end_time)
const countTime = endtTime.getTime() - curTime.getTime() const countTime = endTime.getTime() - curTime.getTime()
return countTime return countTime
}, },
getEnabledTime() { getEnabledTime() {
const curTime = new Date() const curTime = new Date()
const setCurTime = this.data.config.enabled_before const setCurTime = this.data.config.enabled_before ? new Date(curTime.setMinutes(curTime.getMinutes() + this.data.config.before_login)) : curTime
? new Date(curTime.setMinutes(curTime.getMinutes() + this.data.config.before_login))
: curTime
const startTime = new Date(this.data.start_time) const startTime = new Date(this.data.start_time)
const countTime = setCurTime.getTime() - startTime.getTime() const countTime = setCurTime.getTime() - startTime.getTime()
return countTime return countTime
}, },
examTimeInit() { examTimeInit() {
this.loginParam.is = true this.loginParam.is = true
this.claerExamTime = setInterval(() => { this.clearExamTime = setInterval(() => {
const date = this.getEnabledTime() const date = this.getEnabledTime()
if (date >= 0) { if (date >= 0) {
clearInterval(this.claerExamTime) clearInterval(this.clearExamTime)
this.loginParam.is = false this.loginParam.is = false
} else { } else {
this.countDown(Math.abs(date)) this.countDown(Math.abs(date))
...@@ -156,21 +140,23 @@ export default { ...@@ -156,21 +140,23 @@ export default {
}, },
// 倒计时 // 倒计时
countDown(time) { countDown(time) {
const lefttime = parseInt(time / 1000) const leftTime = parseInt(time / 1000)
const datSec = 24 * 60 * 60 const datSec = 24 * 60 * 60
const hourSer = 60 * 60 const hourSer = 60 * 60
const minuteSec = 60 const minuteSec = 60
const dd = Math.floor(lefttime / datSec) const dd = Math.floor(leftTime / datSec)
const hh = Math.floor((lefttime % datSec) / hourSer) const hh = Math.floor((leftTime % datSec) / hourSer)
const mm = Math.floor((lefttime % hourSer) / minuteSec) const mm = Math.floor((leftTime % hourSer) / minuteSec)
const ss = lefttime % minuteSec const ss = leftTime % minuteSec
this.loginParam.countTimeText = dd > 0 ? `距离开考还有: ${dd}${this.addZero(hh)}${this.addZero(mm)}${this.addZero(ss)}秒` : `距离开考还有: ${this.addZero(hh)}${this.addZero(mm)}${this.addZero(ss)}秒` this.loginParam.countTimeText =
dd > 0
? `距离开考还有: ${dd}${this.addZero(hh)}${this.addZero(mm)}${this.addZero(ss)}秒`
: `距离开考还有: ${this.addZero(hh)}${this.addZero(mm)}${this.addZero(ss)}秒`
}, },
// 开启全屏 // 开启全屏
fullScreen() { fullScreen() {
const el = document.documentElement const el = document.documentElement
const rfs = const rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullscreen
el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullscreen
if (typeof rfs !== 'undefined' && rfs) { if (typeof rfs !== 'undefined' && rfs) {
rfs.call(el) rfs.call(el)
} }
...@@ -189,17 +175,16 @@ export default { ...@@ -189,17 +175,16 @@ export default {
this.$alert('请输入准考证号') this.$alert('请输入准考证号')
return false return false
} }
action.Login.userLogin(this.data.exam_id, { examinee_number: this.examineeNumber }) action.Login.userLogin(this.examId, { examinee_number: this.examineeNumber })
.then(res => { .then(res => {
window.localStorage.setItem('studentInfo', JSON.stringify(res)) window.localStorage.setItem('studentInfo', JSON.stringify(res.info))
const status = parseInt(res.sheet_status) const status = parseInt(res.sheet_status)
// this.sendExamInfo(res.info.student_id) // this.sendExamInfo(res.info.student_id)
if (status === 0) { if (status === 0) {
this.$router.replace({ this.$router.push({ name: 'confirmInfo', params: { examId: this.examId } })
name: 'confirmInfo' } else if (status === 1) {
}) this.$alert('已提交考卷')
} }
status === 1 && this.$alert('已提交考卷')
}) })
.catch(err => { .catch(err => {
if (err.message.indexOf('error') !== -1) { if (err.message.indexOf('error') !== -1) {
...@@ -232,7 +217,7 @@ export default { ...@@ -232,7 +217,7 @@ export default {
position: absolute; position: absolute;
bottom: 0; bottom: 0;
left: 50%; left: 50%;
-webkit-transform: translateX(-50%); transform: translateX(-50%);
margin-bottom: -115px; margin-bottom: -115px;
} }
} }
...@@ -335,6 +320,7 @@ export default { ...@@ -335,6 +320,7 @@ export default {
line-height: 40px; line-height: 40px;
text-align: center; text-align: center;
font-style: normal; font-style: normal;
cursor: pointer;
&.prohibit { &.prohibit {
color: #ccc; color: #ccc;
background: #eee; background: #eee;
......
export default [ export default [
{ path: '/', redirect: '*' }, { path: '/', redirect: '*' },
/* 测试页面 */ /* 测试页面 */
...@@ -6,7 +5,7 @@ export default [ ...@@ -6,7 +5,7 @@ export default [
/* 登录页面 */ /* 登录页面 */
{ path: '/login/:examId', component: () => import('../pages/login/index.vue') }, { path: '/login/:examId', component: () => import('../pages/login/index.vue') },
/* 确认信息 */ /* 确认信息 */
{ path: '/confirmInfo', name: 'confirmInfo', component: () => import('../pages/login/confirmInfo.vue') }, { path: '/confirmInfo/:examId', name: 'confirmInfo', component: () => import('../pages/login/confirmInfo.vue') },
/* 考试倒计时 */ /* 考试倒计时 */
{ path: '/examTime', name: 'examTime', component: () => import('../pages/exam/examTime.vue') }, { path: '/examTime', name: 'examTime', component: () => import('../pages/exam/examTime.vue') },
/* 答题 */ /* 答题 */
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论