123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- <template>
- <view class="content" v-if="checkData">
- <uni-card :title="checkData.title">
- <view v-if="checkData.content">{{checkData.content}}</view>
- <view style="color: #666;">
- <view>考试时长:{{checkData.totalTime}}分钟</view>
- <view>试卷总分:{{checkData.totalScore}}</view>
- <view>及格分数:{{checkData.qualifyScore}}</view>
- <view>关联培训:
- <text v-if="checkData.associate === 1" style="color: rgb(24, 144, 255)" @click="funJumpCourse">是</text>
- <text v-if="checkData.associate !== 1">否</text>
- </view>
- </view>
- </uni-card>
- <view v-if="checkData.answerDevice === 1" class="empty">
- 当前考试只能使用电脑端答题!
- <view>
- <button type="primary" @tap="backList">返回</button>
- </view>
- </view>
- <view v-else>
- <view v-if="checkData.late" class="empty">
- <view>您已经迟到超过{{checkData.lateMax}}分钟,不允许进入考试!</view>
- <view>
- <button type="primary" @tap="backList">返回</button>
- </view>
- </view>
- <view v-else-if="checkData.overTime" class="empty">
- <view>考试未开始或已结束!</view>
- <button type="primary" @tap="backList">返回</button>
- </view>
- <view v-else-if="checkData.chance>0 && checkData.examCount>=checkData.chance" class="empty">
- <view>开始次数超限,总共有{{checkData.chance}}次考试机会!</view>
- <button type="primary" @tap="backList">返回</button>
- </view>
- <view v-else>
- <uni-card title="考试密码" v-if="checkData.openType ===9 ">
- <uni-easyinput v-model="password" placeholder="请输入密码" type="password" />
- </uni-card>
- <view style="padding: 20px;">
- <button type="primary" @tap="startExam">开始考试</button>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- checkInfo,
- createPaper,
- checkProcess
- } from '@/api/exam.js'
- import {
- quickReg
- } from '@/api/user.js'
- export default {
- data() {
- return {
- examId: '',
- password: '',
- checkData: {}
- }
- },
- onLoad: function(option) {
- this.examId = option.id;
- this.fetchExamDetail();
- // 支付成功刷新页面
- uni.$on('paySuccess', () => {
- this.fetchExamDetail()
- });
- },
- methods: {
- // 加载考试列表
- fetchExamDetail() {
- uni.showLoading({
- title: '加载中...'
- });
- checkInfo(this.examId).then(data => {
- this.checkData = data
- uni.hideLoading();
- })
- },
- startExam() {
- let that = this
- // 如果要人脸识别
- if (this.checkData.faceOn) {
- //打印请求返回的数据
- uni.navigateTo({
- url: '/pages/exam/face?examId=' + this.examId + '&password=' + this.password
- });
- return;
- }
- uni.showLoading({
- title: '创建试卷...'
- });
- const data = {
- examId: this.examId,
- password: this.password,
- }
- createPaper(data).then(data => {
- // 关闭加载
- uni.hideLoading();
- //打印请求返回的数据
- uni.navigateTo({
- url: '/pages/exam/exam?id=' + data.id
- });
- }).catch(err => {
- // 有正在进行的考试
- if (err && err.code === 20010002) {
- uni.showModal({
- title: '提示信息',
- content: '您有其它正在进行的考试,是否继续进入该考试?',
- success: function(res) {
- if (res.confirm) {
- that.backExam()
- }
- }
- });
- }
- })
- },
- backList() {
- uni.navigateBack()
- },
- backExam() {
- checkProcess().then(data => {
- if (data && data.id) {
- this.continueExam(data.id)
- }
- })
- },
-
- funJumpCourse(){
- uni.navigateTo({
- url:'/pages/course/detail?id='+ this.checkData.courseId
- })
- },
- // 继续考试
- continueExam(id) {
- uni.redirectTo({
- url: '/pages/exam/exam?id=' + id
- });
- },
- },
- onUnload() {
- uni.$off('paySuccess');
- }
- }
- </script>
- <style scoped>
- </style>
|