2024-08-14 18:55:18 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<view>
|
|
|
|
|
|
<u-navbar leftIcon="" title="考试" :placeholder="true" />
|
|
|
|
|
|
<div class="content">
|
|
|
|
|
|
<div class="top-content">
|
|
|
|
|
|
<div class="top-wrapper">
|
|
|
|
|
|
<div class="time">
|
|
|
|
|
|
<div>距离考试结束:</div>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<u-count-down
|
|
|
|
|
|
class="count-down"
|
|
|
|
|
|
ref="countDown"
|
|
|
|
|
|
:autoStart="false"
|
|
|
|
|
|
:time="time"
|
|
|
|
|
|
@change="changeCountDown"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
第
|
|
|
|
|
|
<span style="color: #1989fa">{{ currentIndex + 1 }}</span>
|
|
|
|
|
|
/{{ questionList.length }}题
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="center-wrapper">
|
|
|
|
|
|
<div class="answer-wrapper">
|
|
|
|
|
|
<div
|
|
|
|
|
|
class="item-wrapper"
|
|
|
|
|
|
v-for="(item, index) in questionList"
|
|
|
|
|
|
:key="index"
|
|
|
|
|
|
v-show="item.isShow"
|
|
|
|
|
|
@click="handleQuestionNumber(item, index)"
|
|
|
|
|
|
>
|
2024-08-23 16:00:43 +08:00
|
|
|
|
<div class="answer-item" :class="{ isActive: item.isActive, currentActive: currentIndex == index }">
|
|
|
|
|
|
{{ index + 1 }}
|
|
|
|
|
|
</div>
|
2024-08-14 18:55:18 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="unfold" @click="handleUnfold">
|
|
|
|
|
|
{{ isRotating ? '收起' : '展开' }}
|
|
|
|
|
|
<u-icon v-if="!this.isRotating" name="arrow-down-fill" size="10" />
|
|
|
|
|
|
<u-icon v-else name="arrow-up-fill" size="10" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 题目 -->
|
|
|
|
|
|
<div class="question-wrapper" v-for="(item, index) in questionList" :key="index" v-show="index == currentIndex">
|
|
|
|
|
|
<div class="question-type-wrapper">
|
|
|
|
|
|
<div class="line" />
|
|
|
|
|
|
<div class="question-type">
|
2024-08-23 16:00:43 +08:00
|
|
|
|
<div v-if="item.examType == 1">单选题({{ item.questionScore }}分)</div>
|
|
|
|
|
|
<div v-if="item.examType == 2">多选题({{ item.questionScore }}分)</div>
|
|
|
|
|
|
<div v-if="item.examType == 3">判断题({{ item.questionScore }}分)</div>
|
2024-08-14 18:55:18 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2024-08-23 16:00:43 +08:00
|
|
|
|
<div class="question">{{ currentIndex + 1 }}. {{ item.examTopic }}</div>
|
2024-08-26 21:46:08 +08:00
|
|
|
|
<u--image
|
|
|
|
|
|
v-if="item.examTopicUrl"
|
|
|
|
|
|
:showLoading="true"
|
|
|
|
|
|
:src="fileUrl + item.examTopicUrl || ''"
|
|
|
|
|
|
width="60px"
|
|
|
|
|
|
height="60px"
|
|
|
|
|
|
style="margin-bottom: 10px"
|
|
|
|
|
|
@click="clickImg(fileUrl + item.examTopicUrl)"
|
|
|
|
|
|
/>
|
2024-08-14 18:55:18 +08:00
|
|
|
|
<div class="options">
|
2024-09-04 15:18:01 +08:00
|
|
|
|
<div class="option-wrapper" v-for="(option, optionIndex) in item.listOption" :key="optionIndex">
|
|
|
|
|
|
<div
|
|
|
|
|
|
class="option"
|
|
|
|
|
|
:class="{ isActive: option.isActive }"
|
|
|
|
|
|
@click="handleSelectOption(item, index, option, optionIndex)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div class="option-item">{{ option.optionIdent }}.</div>
|
|
|
|
|
|
<div class="option-content">{{ option.optionContent }}</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<u--image
|
|
|
|
|
|
v-if="option.optionUrl"
|
|
|
|
|
|
:showLoading="true"
|
|
|
|
|
|
:src="fileUrl + option.optionUrl || ''"
|
|
|
|
|
|
width="60px"
|
|
|
|
|
|
height="60px"
|
|
|
|
|
|
style="margin-bottom: 10px"
|
|
|
|
|
|
@click="clickImg(fileUrl + option.optionUrl)"
|
|
|
|
|
|
/>
|
2024-08-14 18:55:18 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 底部按钮 -->
|
|
|
|
|
|
<div class="bottom-btn">
|
|
|
|
|
|
<div class="btn" v-show="currentIndex != 0">
|
|
|
|
|
|
<u-button size="small" shape="circle" text="上一题" @click="currentIndex--" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="btn" v-if="currentIndex !== questionList.length - 1">
|
|
|
|
|
|
<u-button type="primary" size="small" shape="circle" text="下一题" @click="currentIndex++" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="btn" v-else>
|
|
|
|
|
|
<u-button type="primary" size="small" shape="circle" text="交 卷" @click="openConfirmModal" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 提交弹框 -->
|
|
|
|
|
|
<u-modal
|
|
|
|
|
|
:show="showConfirmModal"
|
|
|
|
|
|
title="提示"
|
|
|
|
|
|
showCancelButton
|
|
|
|
|
|
@cancel="showConfirmModal = false"
|
|
|
|
|
|
@confirm="handleConfirmSubmit"
|
|
|
|
|
|
>
|
|
|
|
|
|
<view class="slot-content">
|
|
|
|
|
|
<view v-if="unDoCount > 0">
|
|
|
|
|
|
本场考试还有
|
|
|
|
|
|
<span style="color: #1989fa; margin: 0 5px">{{ unDoCount }}</span>
|
|
|
|
|
|
题尚未完成
|
|
|
|
|
|
</view>
|
2024-08-15 17:47:52 +08:00
|
|
|
|
<view style="text-align: center">确定交卷?</view>
|
2024-08-14 18:55:18 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</u-modal>
|
2024-08-15 17:47:52 +08:00
|
|
|
|
|
|
|
|
|
|
<u-toast ref="uToast"></u-toast>
|
2024-08-14 18:55:18 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2024-08-30 17:35:33 +08:00
|
|
|
|
import { pathToBase64, base64ToPath } from 'image-tools'
|
2024-08-28 17:23:03 +08:00
|
|
|
|
import face from '@/uni_modules/mcc-face/index.js'
|
2024-08-26 21:46:08 +08:00
|
|
|
|
import {
|
|
|
|
|
|
getExamQuestionList,
|
|
|
|
|
|
insertQuestionAnswerById,
|
|
|
|
|
|
commitExamByRecordId,
|
|
|
|
|
|
getFaceRecognition,
|
|
|
|
|
|
updStudyDurationExamPractice
|
|
|
|
|
|
} from '@/api/eduApp'
|
2024-08-28 09:51:05 +08:00
|
|
|
|
import config from '@/config'
|
2024-08-15 17:47:52 +08:00
|
|
|
|
|
2024-08-14 18:55:18 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
2024-09-04 19:20:45 +08:00
|
|
|
|
isLoading: false,
|
2024-08-23 16:00:43 +08:00
|
|
|
|
// 考试id
|
|
|
|
|
|
examId: '',
|
|
|
|
|
|
// 考试记录id
|
|
|
|
|
|
recordId: '',
|
2024-08-15 17:47:52 +08:00
|
|
|
|
// 切屏次数
|
|
|
|
|
|
screenCount: 0,
|
2024-08-23 16:00:43 +08:00
|
|
|
|
// 允许切屏次数
|
|
|
|
|
|
switchCount: 0,
|
2024-08-14 18:55:18 +08:00
|
|
|
|
showConfirmModal: false,
|
2024-08-23 16:00:43 +08:00
|
|
|
|
// 考试时间
|
|
|
|
|
|
time: 0,
|
|
|
|
|
|
examTime: 0,
|
2024-08-15 17:47:52 +08:00
|
|
|
|
random1: 0,
|
|
|
|
|
|
random2: 0,
|
2024-08-20 17:44:53 +08:00
|
|
|
|
hasScanned: false,
|
2024-08-14 18:55:18 +08:00
|
|
|
|
// 答题时间
|
|
|
|
|
|
answerTime: 0,
|
|
|
|
|
|
currentIndex: 0,
|
|
|
|
|
|
// 是否展开
|
|
|
|
|
|
isRotating: false,
|
|
|
|
|
|
// 未做题目数
|
|
|
|
|
|
unDoCount: 0,
|
2024-08-23 16:00:43 +08:00
|
|
|
|
examNum: 0, // 考试次数
|
|
|
|
|
|
examCount: 1, // 1: 不限次 2: 及格终止 3: 自定义
|
|
|
|
|
|
examCustom: 0, // 自定义次数
|
|
|
|
|
|
results: 0, // 考试结果
|
2024-08-26 21:46:08 +08:00
|
|
|
|
studyId: '', // 学习id
|
2024-08-14 18:55:18 +08:00
|
|
|
|
// 题目列表
|
2024-08-26 21:46:08 +08:00
|
|
|
|
questionList: [],
|
2024-08-28 09:51:05 +08:00
|
|
|
|
fileUrl: config.fileUrl,
|
|
|
|
|
|
score: 0,
|
2024-08-30 17:35:33 +08:00
|
|
|
|
passScore: 0,
|
|
|
|
|
|
isHide: false
|
2024-08-14 18:55:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2024-08-23 16:00:43 +08:00
|
|
|
|
onLoad(opt) {
|
|
|
|
|
|
opt = JSON.parse(opt.params)
|
2024-08-28 09:51:05 +08:00
|
|
|
|
console.log('🚀 ~ onLoad ~ opt考试中--:', opt)
|
2024-08-23 16:00:43 +08:00
|
|
|
|
this.examId = opt.examId
|
|
|
|
|
|
this.switchCount = Number(opt.switchCount)
|
|
|
|
|
|
this.examNum = opt.examNum
|
|
|
|
|
|
this.examCount = opt.examCount
|
|
|
|
|
|
this.examCustom = opt.examCustom
|
2024-08-26 21:46:08 +08:00
|
|
|
|
this.studyId = opt.studyId || ''
|
2024-08-28 09:51:05 +08:00
|
|
|
|
this.score = opt.score
|
|
|
|
|
|
this.passScore = opt.passScore
|
2024-08-15 17:47:52 +08:00
|
|
|
|
},
|
2024-08-30 17:35:33 +08:00
|
|
|
|
onShow() {
|
|
|
|
|
|
this.isHide = false
|
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
|
// if (this.screenCount > this.switchCount) {
|
|
|
|
|
|
// this.$refs.uToast.show({
|
|
|
|
|
|
// message: '切屏次数已达上限, 系统将自动提交',
|
|
|
|
|
|
// duration: 1000
|
|
|
|
|
|
// })
|
|
|
|
|
|
// this.handleConfirmSubmit()
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }, 1000)
|
|
|
|
|
|
},
|
2024-08-23 16:00:43 +08:00
|
|
|
|
onHide() {
|
2024-08-29 18:12:47 +08:00
|
|
|
|
// this.screenCount++
|
|
|
|
|
|
// console.log('🚀 ~ onHide ~ this.screenCount:', this.screenCount)
|
2024-08-30 17:35:33 +08:00
|
|
|
|
if (!this.isHide) {
|
|
|
|
|
|
this.handleConfirmSubmit()
|
|
|
|
|
|
}
|
2024-08-15 17:47:52 +08:00
|
|
|
|
},
|
2024-08-14 18:55:18 +08:00
|
|
|
|
mounted() {
|
|
|
|
|
|
this.getList()
|
|
|
|
|
|
},
|
2024-08-29 18:12:47 +08:00
|
|
|
|
// onUnload() {
|
|
|
|
|
|
// console.log('🚀 ~ onUnload ~ 页面关闭')
|
|
|
|
|
|
// this.handleConfirmSubmit()
|
|
|
|
|
|
// },
|
2024-08-14 18:55:18 +08:00
|
|
|
|
methods: {
|
|
|
|
|
|
// 获取列表
|
2024-08-23 16:00:43 +08:00
|
|
|
|
async getList() {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const params = {
|
|
|
|
|
|
examId: this.examId
|
|
|
|
|
|
}
|
2024-09-05 18:17:59 +08:00
|
|
|
|
|
2024-08-28 09:51:05 +08:00
|
|
|
|
uni.request({
|
|
|
|
|
|
url: config.baseUrl + '/exam-student/studentExam/getExamQuestionList',
|
|
|
|
|
|
method: 'post',
|
|
|
|
|
|
data: params,
|
|
|
|
|
|
header: {
|
|
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
|
|
|
Authorization: uni.getStorageSync('access_token')
|
|
|
|
|
|
},
|
|
|
|
|
|
success: res => {
|
|
|
|
|
|
console.log('🚀 ~ getList ~ res:', res)
|
|
|
|
|
|
res = res.data
|
|
|
|
|
|
const data = res.data
|
|
|
|
|
|
this.questionList = data.examPaperData
|
|
|
|
|
|
this.recordId = data.recordId
|
|
|
|
|
|
this.examTime = data.answerTime
|
|
|
|
|
|
this.time = Number(data.answerTime) * 60 * 1000
|
|
|
|
|
|
console.log('🚀 ~ getList ~ this.time:', this.time)
|
|
|
|
|
|
console.log('🚀 ~ getList ~ this.questionList:', this.questionList)
|
2024-09-05 18:17:59 +08:00
|
|
|
|
this.random1 = (data.answerTime/3) * 60 + Math.ceil(Math.random() * 20) + 20
|
|
|
|
|
|
this.random2 = (data.answerTime/2) * 60 + Math.ceil(Math.random() * 30) + 30
|
|
|
|
|
|
console.log('🚀 ~ getList ~ this.random1:', this.random1, this.random2)
|
2024-08-28 09:51:05 +08:00
|
|
|
|
if (this.questionList.length > 0) {
|
|
|
|
|
|
this.questionList.forEach((item, index) => {
|
|
|
|
|
|
this.$set(item, 'isShow', index < 7)
|
|
|
|
|
|
this.$set(item, 'isActive', false)
|
|
|
|
|
|
if (item.listOption) {
|
|
|
|
|
|
item.listOption.forEach(option => {
|
|
|
|
|
|
this.$set(option, 'isActive', false)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2024-08-23 16:00:43 +08:00
|
|
|
|
})
|
2024-08-28 09:51:05 +08:00
|
|
|
|
console.log('🚀 ~ this.questionList.forEach ~ this.questionList:', this.questionList)
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
this.$refs.countDown.start()
|
|
|
|
|
|
}, 100)
|
2024-08-23 16:00:43 +08:00
|
|
|
|
}
|
2024-08-28 09:51:05 +08:00
|
|
|
|
},
|
|
|
|
|
|
fail: err => {
|
|
|
|
|
|
console.log(err)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2024-08-23 16:00:43 +08:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.log('🚀 ~ getList ~ error:', error)
|
2024-08-14 18:55:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
changeCountDown(time) {
|
|
|
|
|
|
// console.log('🚀 ~ changeCountDown ~ time:', time)
|
2024-08-23 16:00:43 +08:00
|
|
|
|
// 等时间赋值后再开始计时
|
|
|
|
|
|
if (this.time == 0) return
|
2024-08-14 18:55:18 +08:00
|
|
|
|
this.answerTime =
|
|
|
|
|
|
this.time - (time.days * 24 * 60 * 60 + time.hours * 60 * 60 + time.minutes * 60 + time.seconds) * 1000
|
2024-08-20 17:44:53 +08:00
|
|
|
|
// console.log('🚀 ~ changeCountDown ~ this.answerTime:', this.answerTime)
|
|
|
|
|
|
if (this.answerTime > this.random1 && this.answerTime < this.random2 && !this.hasScanned) {
|
2024-09-05 18:17:59 +08:00
|
|
|
|
// this.openFaceScan() // Android 人脸识别
|
|
|
|
|
|
this.openPhotograph() // IOS 拍照识别
|
2024-08-20 17:44:53 +08:00
|
|
|
|
this.hasScanned = true
|
|
|
|
|
|
} else if (this.answerTime > this.random2 && this.hasScanned) {
|
2024-09-05 18:17:59 +08:00
|
|
|
|
// this.openFaceScan()
|
|
|
|
|
|
this.openPhotograph()
|
2024-08-20 17:44:53 +08:00
|
|
|
|
this.hasScanned = false
|
|
|
|
|
|
}
|
2024-08-14 18:55:18 +08:00
|
|
|
|
if (this.answerTime == this.time) {
|
|
|
|
|
|
// 提示: 时间结束, 自动提交
|
|
|
|
|
|
this.$refs.uToast.show({
|
|
|
|
|
|
message: '考试时间结束, 系统将自动提交',
|
|
|
|
|
|
duration: 1000
|
|
|
|
|
|
})
|
|
|
|
|
|
this.handleConfirmSubmit()
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// 点击题号
|
|
|
|
|
|
handleQuestionNumber(item, index) {
|
|
|
|
|
|
console.log('🚀 ~ handleQuestionNumber ~ item:', item)
|
|
|
|
|
|
this.currentIndex = index
|
|
|
|
|
|
},
|
|
|
|
|
|
// 展开
|
|
|
|
|
|
handleUnfold() {
|
|
|
|
|
|
this.questionList.forEach((item, index) => {
|
|
|
|
|
|
if (index > 6) {
|
|
|
|
|
|
this.$set(item, 'isShow', !item.isShow)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.isRotating = !this.isRotating
|
|
|
|
|
|
console.log('🚀 ~ this.questionList.forEach ~ this.isRotating:', this.isRotating)
|
|
|
|
|
|
},
|
|
|
|
|
|
handleSelectOption(item, index, option, optionIndex) {
|
2024-08-23 16:00:43 +08:00
|
|
|
|
let selectAnswer = ''
|
|
|
|
|
|
console.log('🚀 ~ handleSelectOption ~ option:', item, option, optionIndex)
|
2024-08-14 18:55:18 +08:00
|
|
|
|
item.isActive = true
|
|
|
|
|
|
// 如果是单选题与判断题 则只能选中一个 多选题可以选中多个
|
2024-08-23 16:00:43 +08:00
|
|
|
|
if (item.examType == 1 || item.examType == 3) {
|
2024-08-14 18:55:18 +08:00
|
|
|
|
this.$set(option, 'isActive', true)
|
2024-08-23 16:00:43 +08:00
|
|
|
|
item.listOption.forEach((option, optIndex) => {
|
2024-08-14 18:55:18 +08:00
|
|
|
|
// 除了当前选中的其他都设置为未选中
|
|
|
|
|
|
if (optIndex != optionIndex) {
|
|
|
|
|
|
this.$set(option, 'isActive', false)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2024-08-23 16:00:43 +08:00
|
|
|
|
selectAnswer = option.optionIdent
|
2024-08-14 18:55:18 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$set(option, 'isActive', !option.isActive)
|
|
|
|
|
|
// 如果所有选项都是未选中状态, 则题目也是未选中状态
|
2024-08-23 16:00:43 +08:00
|
|
|
|
let isActive = item.listOption.some(option => option.isActive)
|
2024-08-14 18:55:18 +08:00
|
|
|
|
item.isActive = isActive
|
2024-08-23 16:00:43 +08:00
|
|
|
|
// 将点击的选项的 optionIdent 'ABC' 拼接成字符串
|
|
|
|
|
|
item.listOption.forEach(option => {
|
|
|
|
|
|
if (option.isActive) {
|
|
|
|
|
|
selectAnswer += option.optionIdent
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2024-08-14 18:55:18 +08:00
|
|
|
|
}
|
2024-08-23 16:00:43 +08:00
|
|
|
|
|
|
|
|
|
|
const params = {
|
|
|
|
|
|
recordId: this.recordId,
|
|
|
|
|
|
questionId: item.id,
|
|
|
|
|
|
selectAnswer
|
|
|
|
|
|
}
|
2024-09-03 16:07:30 +08:00
|
|
|
|
if (item.examType == 3) {
|
|
|
|
|
|
params.selectAnswer = selectAnswer == 'A' ? '对' : '错'
|
|
|
|
|
|
}
|
2024-08-23 16:00:43 +08:00
|
|
|
|
console.log('🚀 ~ handleSelectOption ~ params:', params)
|
2024-08-28 09:51:05 +08:00
|
|
|
|
// insertQuestionAnswerById(params)
|
|
|
|
|
|
uni.request({
|
|
|
|
|
|
url: config.baseUrl + '/exam-student/studentExam/insertQuestionAnswerById',
|
|
|
|
|
|
method: 'post',
|
|
|
|
|
|
data: params,
|
|
|
|
|
|
header: {
|
|
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
|
|
|
Authorization: uni.getStorageSync('access_token')
|
2024-09-03 16:07:30 +08:00
|
|
|
|
},
|
|
|
|
|
|
success: res => {
|
|
|
|
|
|
console.log('🚀 ~ handleSelectOption ~ res:', res)
|
2024-08-28 09:51:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2024-08-14 18:55:18 +08:00
|
|
|
|
},
|
|
|
|
|
|
openConfirmModal() {
|
|
|
|
|
|
this.unDoCount = this.questionList.filter(item => !item.isActive).length
|
|
|
|
|
|
this.showConfirmModal = true
|
|
|
|
|
|
},
|
|
|
|
|
|
// 确认提交
|
2024-08-28 17:23:03 +08:00
|
|
|
|
handleConfirmSubmit() {
|
2024-09-04 19:20:45 +08:00
|
|
|
|
console.log('🚀 ~ 提交-->', this.isLoading)
|
|
|
|
|
|
if (this.isLoading) {
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: '正在提交中, 请稍后',
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
})
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
this.isLoading = true
|
2024-08-14 18:55:18 +08:00
|
|
|
|
// 停止计时
|
|
|
|
|
|
this.$refs.countDown.pause()
|
2024-08-23 16:00:43 +08:00
|
|
|
|
const params = {
|
2024-08-26 21:46:08 +08:00
|
|
|
|
userId: uni.getStorageSync('userId'),
|
2024-08-23 16:00:43 +08:00
|
|
|
|
recordId: this.recordId,
|
|
|
|
|
|
examId: this.examId,
|
|
|
|
|
|
// 时间 转换为分钟, 不足一分钟算一分钟
|
|
|
|
|
|
answerTime: Math.ceil(this.answerTime / 60000)
|
|
|
|
|
|
}
|
2024-08-28 09:51:05 +08:00
|
|
|
|
// const res = await commitExamByRecordId(params)
|
|
|
|
|
|
uni.request({
|
|
|
|
|
|
url: config.baseUrl + '/exam-student/studentExam/commitExamByRecordId',
|
|
|
|
|
|
method: 'post',
|
|
|
|
|
|
data: params,
|
|
|
|
|
|
header: {
|
|
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
|
|
|
Authorization: uni.getStorageSync('access_token')
|
|
|
|
|
|
},
|
|
|
|
|
|
success: res => {
|
|
|
|
|
|
console.log('🚀 ~ handleConfirmSubmit ~ res:', res)
|
|
|
|
|
|
res = res.data
|
|
|
|
|
|
const params2 = {
|
|
|
|
|
|
examId: this.examId,
|
|
|
|
|
|
examGrade: res.examGrade,
|
|
|
|
|
|
examResult: res.examResult,
|
|
|
|
|
|
gradeAverage: res.gradeAverage,
|
|
|
|
|
|
answerTime: Math.ceil(this.answerTime / 60000),
|
|
|
|
|
|
examTime: this.examTime,
|
|
|
|
|
|
questionCount: this.questionList.length,
|
|
|
|
|
|
switchCount: this.switchCount,
|
2024-09-04 15:18:01 +08:00
|
|
|
|
examNum: this.examNum + 1,
|
2024-08-28 09:51:05 +08:00
|
|
|
|
examCount: this.examCount,
|
|
|
|
|
|
examCustom: this.examCustom,
|
|
|
|
|
|
results: res.examResult,
|
|
|
|
|
|
studyId: this.studyId || '',
|
|
|
|
|
|
score: this.score,
|
|
|
|
|
|
passScore: this.passScore
|
|
|
|
|
|
}
|
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
|
url: `/pages/YNEduApp/exam/examinationDetails?params=${JSON.stringify(params2)}`
|
|
|
|
|
|
})
|
2024-09-04 19:20:45 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
this.showConfirmModal = false
|
|
|
|
|
|
this.isLoading = false
|
|
|
|
|
|
}, 1000)
|
2024-08-28 09:51:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2024-08-26 21:46:08 +08:00
|
|
|
|
if (this.studyId) {
|
2024-08-28 09:51:05 +08:00
|
|
|
|
// updStudyDurationExamPractice({ userId: params.userId, studyId: this.studyId })
|
|
|
|
|
|
this.updStudyDurationExamPractice({ userId: params.userId, studyId: this.studyId })
|
2024-08-26 21:46:08 +08:00
|
|
|
|
}
|
2024-08-23 16:00:43 +08:00
|
|
|
|
console.log('🚀 ~ handleConfirmSubmit ~ params:', params, res)
|
2024-08-28 09:51:05 +08:00
|
|
|
|
// this.showConfirmModal = false
|
|
|
|
|
|
// const params2 = {
|
|
|
|
|
|
// examId: this.examId,
|
|
|
|
|
|
// examGrade: res.examGrade,
|
|
|
|
|
|
// examResult: res.examResult,
|
|
|
|
|
|
// gradeAverage: res.gradeAverage,
|
|
|
|
|
|
// answerTime: Math.ceil(this.answerTime / 60000),
|
|
|
|
|
|
// examTime: this.examTime,
|
|
|
|
|
|
// questionCount: this.questionList.length,
|
|
|
|
|
|
// switchCount: this.switchCount,
|
|
|
|
|
|
// examNum: this.examNum,
|
|
|
|
|
|
// examCount: this.examCount,
|
|
|
|
|
|
// examCustom: this.examCustom,
|
|
|
|
|
|
// results: res.examResult,
|
|
|
|
|
|
// studyId: this.studyId || ''
|
|
|
|
|
|
// }
|
|
|
|
|
|
// uni.navigateTo({
|
|
|
|
|
|
// url: `/pages/YNEduApp/exam/examinationDetails?params=${JSON.stringify(params2)}`
|
|
|
|
|
|
// })
|
2024-08-15 17:47:52 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 人脸识别
|
2024-09-05 18:17:59 +08:00
|
|
|
|
// async openFaceScan() {
|
|
|
|
|
|
// face.open(['a'], e => {
|
|
|
|
|
|
// console.log('🚀 ~ e-人脸识别:', e)
|
|
|
|
|
|
// face.close()
|
|
|
|
|
|
// let params = {
|
|
|
|
|
|
// userId: uni.getStorageSync('userId'),
|
|
|
|
|
|
// img: e
|
|
|
|
|
|
// }
|
|
|
|
|
|
// params = JSON.stringify(params)
|
|
|
|
|
|
// this.getFaceRecognition(params)
|
|
|
|
|
|
// })
|
|
|
|
|
|
// },
|
2024-08-30 17:35:33 +08:00
|
|
|
|
// 拍照录入
|
|
|
|
|
|
openPhotograph() {
|
|
|
|
|
|
this.isHide = true
|
|
|
|
|
|
uni.chooseImage({
|
|
|
|
|
|
count: 1,
|
|
|
|
|
|
sizeType: ['compressed'],
|
|
|
|
|
|
sourceType: ['camera'],
|
|
|
|
|
|
success: res => {
|
|
|
|
|
|
this.isHide = false
|
|
|
|
|
|
let url = ''
|
|
|
|
|
|
console.log('🚀 ~ res-拍照:', res)
|
|
|
|
|
|
this.imgToBase64(res.tempFilePaths[0]).then(base64 => {
|
|
|
|
|
|
url = base64
|
|
|
|
|
|
console.log('🚀 ~ this.imgToBase64 ~ base64:', url)
|
2024-09-05 18:17:59 +08:00
|
|
|
|
this.getFaceRecognition({ userId: uni.getStorageSync('userId'), img: url })
|
2024-08-30 17:35:33 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
fail: err => {
|
|
|
|
|
|
this.isHide = false
|
|
|
|
|
|
console.log('🚀 ~ err:', err)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
imgToBase64(data) {
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
|
pathToBase64(data)
|
|
|
|
|
|
.then(base64 => {
|
|
|
|
|
|
resolve(base64)
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(error => {
|
|
|
|
|
|
console.error(error)
|
|
|
|
|
|
reject(error)
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 发送请求
|
|
|
|
|
|
getFaceRecognition(params) {
|
2024-09-05 18:17:59 +08:00
|
|
|
|
console.log('🚀 ~ getFaceRecognition ~ params:', params)
|
2024-08-30 17:35:33 +08:00
|
|
|
|
uni.request({
|
|
|
|
|
|
url: config.baseUrl + '/exam-student/personalCenter/getFaceRecognition',
|
|
|
|
|
|
method: 'POST',
|
|
|
|
|
|
header: {
|
|
|
|
|
|
'content-type': 'application/json',
|
|
|
|
|
|
Authorization: uni.getStorageSync('access_token')
|
|
|
|
|
|
},
|
|
|
|
|
|
data: params,
|
|
|
|
|
|
success: res => {
|
2024-09-05 18:17:59 +08:00
|
|
|
|
console.log('🚀 ~ openFaceScan ~ res-人脸识别:', res)
|
2024-08-30 17:35:33 +08:00
|
|
|
|
res = res.data
|
2024-09-05 18:17:59 +08:00
|
|
|
|
console.log('🚀 ~ openFaceScan ~ res-人脸识别:', res.code)
|
2024-08-30 17:35:33 +08:00
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
|
this.$refs.uToast.show({
|
|
|
|
|
|
message: '人脸识别成功',
|
|
|
|
|
|
duration: 1000
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$refs.uToast.show({
|
|
|
|
|
|
message: '人脸识别失败, 即将结束考试',
|
|
|
|
|
|
duration: 1000
|
|
|
|
|
|
})
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
this.handleConfirmSubmit()
|
|
|
|
|
|
}, 1000)
|
2024-08-23 16:00:43 +08:00
|
|
|
|
}
|
2024-08-30 17:35:33 +08:00
|
|
|
|
},
|
|
|
|
|
|
fail(err) {
|
|
|
|
|
|
console.log('🚀 ~ openFaceScan ~ 人脸识别失败', err)
|
2024-09-05 18:17:59 +08:00
|
|
|
|
this.$refs.uToast.show({
|
|
|
|
|
|
message: err.errMsg,
|
|
|
|
|
|
duration: 1000
|
|
|
|
|
|
})
|
2024-08-30 17:35:33 +08:00
|
|
|
|
}
|
2024-08-15 17:47:52 +08:00
|
|
|
|
})
|
2024-08-26 21:46:08 +08:00
|
|
|
|
},
|
|
|
|
|
|
clickImg(url) {
|
2024-08-30 17:35:33 +08:00
|
|
|
|
this.isHide = true
|
2024-08-26 21:46:08 +08:00
|
|
|
|
uni.previewImage({
|
|
|
|
|
|
urls: [url]
|
|
|
|
|
|
})
|
2024-08-30 17:35:33 +08:00
|
|
|
|
// this.screenCount--
|
2024-08-26 21:46:08 +08:00
|
|
|
|
},
|
2024-08-28 09:51:05 +08:00
|
|
|
|
updStudyDurationExamPractice(params) {
|
|
|
|
|
|
uni.request({
|
|
|
|
|
|
url: config.baseUrl + '/exam-student/student/updStudyDurationExamPractice',
|
|
|
|
|
|
method: 'post',
|
|
|
|
|
|
data: params,
|
|
|
|
|
|
header: {
|
|
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
|
|
|
Authorization: uni.getStorageSync('access_token')
|
|
|
|
|
|
},
|
|
|
|
|
|
fail: err => {
|
|
|
|
|
|
console.log(err)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2024-08-14 18:55:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
.content {
|
|
|
|
|
|
padding: 10px;
|
|
|
|
|
|
|
|
|
|
|
|
.top-content {
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
padding: 10px;
|
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.top-wrapper {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
.time {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: flex-start;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.center-wrapper {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
|
|
|
|
|
|
.unfold {
|
|
|
|
|
|
height: 50px;
|
|
|
|
|
|
line-height: 50px;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
.answer-wrapper {
|
|
|
|
|
|
width: 86%;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: flex-start;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
|
|
|
|
|
|
|
.item-wrapper {
|
|
|
|
|
|
padding: 5px 5px 0 0;
|
|
|
|
|
|
width: 12%;
|
|
|
|
|
|
height: 45px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
|
|
.answer-item {
|
|
|
|
|
|
width: 33px;
|
|
|
|
|
|
height: 33px;
|
|
|
|
|
|
line-height: 33px;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
|
background: #f4f9fe;
|
|
|
|
|
|
color: #333;
|
|
|
|
|
|
&.isActive {
|
|
|
|
|
|
background: #1989fa;
|
|
|
|
|
|
}
|
2024-08-23 16:00:43 +08:00
|
|
|
|
&.currentActive {
|
|
|
|
|
|
background: #f4c14a;
|
|
|
|
|
|
}
|
2024-08-14 18:55:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.question-wrapper {
|
|
|
|
|
|
.question-type-wrapper {
|
|
|
|
|
|
margin: 20px 0;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: flex-start;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
|
|
.line {
|
|
|
|
|
|
width: 2px;
|
|
|
|
|
|
height: 11px;
|
|
|
|
|
|
background: #1989fa;
|
|
|
|
|
|
margin-right: 3px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.question-type {
|
|
|
|
|
|
color: #8a8a8a;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.question {
|
|
|
|
|
|
font-weight: 800;
|
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
|
color: #333333;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
.options {
|
|
|
|
|
|
margin-top: 10px;
|
2024-09-04 15:18:01 +08:00
|
|
|
|
margin-bottom: 30px;
|
|
|
|
|
|
.option-wrapper {
|
|
|
|
|
|
max-height: 500px;
|
|
|
|
|
|
overflow: auto;
|
|
|
|
|
|
.option {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: flex-start;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
margin-top: 10px;
|
|
|
|
|
|
background: #f4f9fe;
|
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
|
&.isActive {
|
|
|
|
|
|
background: #8cbff1;
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
}
|
|
|
|
|
|
.option-item {
|
|
|
|
|
|
width: 33px;
|
|
|
|
|
|
height: 33px;
|
|
|
|
|
|
line-height: 33px;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
color: #333;
|
|
|
|
|
|
}
|
|
|
|
|
|
.option-content {
|
|
|
|
|
|
margin-left: 10px;
|
|
|
|
|
|
color: #333;
|
|
|
|
|
|
}
|
2024-08-14 18:55:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
.bottom-btn {
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
bottom: 0;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
|
padding: 15px 0;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
|
|
.btn {
|
|
|
|
|
|
width: 100px;
|
|
|
|
|
|
margin-right: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
::v-deep .u-count-down__text {
|
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
|
color: #1989fa;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|