YNUtdPlatform/pages/YNEduApp/exam/beforeExam.vue

203 lines
4.7 KiB
Vue
Raw Normal View History

2024-08-12 16:19:57 +08:00
<template>
<view class="view">
<div class="content">
<div class="title">{{ title }}</div>
<div class="subtitle">{{ subtitle }}</div>
<div class="info">
<div class="duration-wrapper">
<u-icon name="/static/images/time.png"></u-icon>
<div class="duration">{{ duration }}分钟</div>
<div class="explain">考试时长</div>
</div>
<div class="count-wrapper">
2024-08-15 17:47:52 +08:00
<u-icon name="/static/images/infinite.png" size="21"></u-icon>
2024-08-12 16:19:57 +08:00
<div class="count">{{ count }}</div>
<div class="explain">考试次数</div>
</div>
<div class="switch-count-wrapper">
<u-icon name="/static/images/qiehuan.png"></u-icon>
2024-08-29 18:12:47 +08:00
<div class="switch-count">{{ '不允许切屏' }}</div>
2024-08-12 16:19:57 +08:00
<div class="explain">切屏次数</div>
</div>
</div>
<div class="explain">*进入考试后计时结束将自动交卷退出后将会继续计时</div>
<!-- 底部固定按钮 -->
<div class="bottom-btn">
<div class="btn">
<u-button type="primary" size="small" shape="circle" text="进入考试" @click="openModal" />
</div>
</div>
<!-- 确认进入考试弹框 -->
2024-08-15 17:47:52 +08:00
<u-modal
:show="showModal"
title="提示"
:content="content"
showCancelButton
@cancel="showModal = false"
@confirm="handleEnterExam"
/>
2024-08-12 16:19:57 +08:00
</div>
</view>
</template>
<script>
export default {
data() {
return {
showModal: false,
// 标题
2024-08-23 16:00:43 +08:00
title: '',
2024-08-12 16:19:57 +08:00
// 副标题
2024-08-23 16:00:43 +08:00
subtitle: '',
2024-08-12 16:19:57 +08:00
// 考试时长
2024-08-23 16:00:43 +08:00
duration: '',
2024-08-12 16:19:57 +08:00
// 考试次数
count: '不限次',
// 切屏次数
2024-08-23 16:00:43 +08:00
switchCount: '',
2024-08-26 21:46:08 +08:00
studyId: '',
2024-08-23 16:00:43 +08:00
content: '是否确认进入考试?',
examId: '',
examNum: 0, // 考试次数
2024-09-04 15:18:01 +08:00
examCount: '', // 1: 不限次 2: 及格终止 3: 自定义
2024-08-23 16:00:43 +08:00
examCustom: 0, // 自定义次数
2024-08-28 09:51:05 +08:00
score: 0,
passScore: 0
2024-08-12 16:19:57 +08:00
}
},
2024-08-23 16:00:43 +08:00
onLoad(opt) {
opt = JSON.parse(opt.params)
console.log('🚀 ~ onLoad ~ opt:', opt)
this.examId = opt.id
this.title = opt.name
this.subtitle = opt.validityDate
this.duration = opt.responseTime
2024-09-04 15:18:01 +08:00
this.examNum = opt.examNum
this.count = opt.examCount === 1 ? '不限次' : opt.examCount === 2 ? '及格终止' : opt.examCustom
this.examCount = opt.examCount
this.examCustom = opt.examCustom
2024-08-23 16:00:43 +08:00
this.switchCount = opt.cutNum.includes('null') || opt.cutNum.includes('undefined') ? '不限次' : opt.cutNum
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-23 16:00:43 +08:00
},
2024-08-12 16:19:57 +08:00
methods: {
2024-08-15 17:47:52 +08:00
openModal() {
this.showModal = true
},
2024-08-12 16:19:57 +08:00
// 进入考试
handleEnterExam() {
2024-08-23 16:00:43 +08:00
const params = {
examId: this.examId, // 考试id
switchCount: this.switchCount, // 切屏次数
examNum: this.examNum,
examCount: this.examCount,
2024-08-26 21:46:08 +08:00
examCustom: this.examCustom,
studyId: this.studyId, // 学习id
2024-08-28 09:51:05 +08:00
score: this.score, // 总分
passScore: this.passScore // 及格分数
2024-08-23 16:00:43 +08:00
}
2024-08-26 21:46:08 +08:00
console.log('🚀 ~ handleEnterExam ~ params:', params)
2024-08-14 18:55:18 +08:00
uni.navigateTo({
2024-08-23 16:00:43 +08:00
url: `/pages/YNEduApp/exam/examination?params=${JSON.stringify(params)}`
2024-08-14 18:55:18 +08:00
})
2024-08-12 16:19:57 +08:00
}
}
}
</script>
<style lang="scss" scoped>
.view {
padding: 10px;
}
.content {
padding: 10px;
border-radius: 5px;
background-color: #fff;
height: 90vh;
box-sizing: border-box;
.title {
font-size: 18px;
font-weight: bold;
color: #333;
padding-top: 20px;
}
.subtitle {
font-size: 14px;
color: #666;
margin-top: 10px;
}
.info {
display: flex;
justify-content: space-between;
margin-top: 20px;
.duration-wrapper,
.count-wrapper,
.switch-count-wrapper {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100px;
height: 100px;
background: #f4f9fe;
border-radius: 4px;
margin-bottom: 20px;
.icon {
width: 20px;
height: 20px;
}
.duration,
.count,
.switch-count {
font-size: 16px;
color: #333;
margin-left: 5px;
}
.explain {
font-size: 12px;
color: #999;
margin-left: 5px;
}
}
}
.explain {
font-size: 12px;
color: #999;
}
.bottom-btn {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background-color: #fff;
padding: 10px 0;
display: flex;
justify-content: flex-end;
align-items: center;
.btn {
width: 33%;
margin-right: 10px;
}
}
}
::v-deep .u-modal__content {
flex-direction: column;
align-items: center;
}
</style>