| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- <!-- 考试任务 -->
- <template>
- <view class="examTask-component">
- <view class="card">
- <view class="card-header">
- <view class="header-left">
- <view class="card-title">考试任务</view>
- <view class="header-subtitle">待完成的学习考试任务</view>
- </view>
- <text class="header-link" @click="goToPage('1')">更多 ›</text>
- </view>
- <view class="card-body">
- <view class="for-max-box" @click="goToPage('2',item)"
- v-for="(item,index) in onlineExamList" :key="index">
- <view class="left-box">
- <view>{{item.examName}}</view>
- <view>待完成</view>
- </view>
- <view class="right-box">›</view>
- </view>
- <view v-if="!onlineExamList[0]" class="empty-tip">暂无考试任务</view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- examUserExamStudyTaskList,
- } from '@/pages_safetyEducationExamination/api/index.js'
- export default {
- data() {
- return {
- onlineExamList:[],
- }
- },
- created() {
- },
- mounted() {
- this.examUserExamStudyTaskList();
- },
- methods: {
- goToPage(type,item){
- if(type == 1){
- //考试列表
- uni.navigateTo({
- url: '/pages_safetyEducationExamination/views/exam/index',
- });
- }else if(type == 2){
- //开始考试相关业务
- if(item.conditionType == 1){
- if(item.examStudy&&item.courseId){
- //学习课程
- let obj = {
- courseId: item.courseId,
- examId: item.examId,
- }
- //等待后续逻辑
- }else{
- //学时要求
- if(item.knowledgePointIds&&item.completedStudyHours&&item.studyHoursRequirement){
- //学时知识点
- uni.navigateTo({
- url: '/pages_safetyEducationExamination/views/studyHourTask/index',
- });
- }else{
- //无知识点要求
- uni.navigateTo({
- url: '/pages_safetyEducationExamination/views/study/index',
- });
- }
- }
- }else if(item.conditionType == 2){
- //学习课程
- let obj = {
- courseId: item.courseId,
- examId: item.examId,
- }
- //等待后续逻辑
- }else if(item.conditionType == 3){
- //模拟考试
- if(item.mockExamId){
- let obj = {
- examId: item.examId,
- attemptId: item.mockExamId,
- }
- //等待后续逻辑
- }else{
- this.examUserExamStart({examId:item.examId,examScene:2});
- }
- }else if(item.conditionType == 4){
- //开始考试
- }
- }
- },
- //模拟考试获取试卷
- async examUserExamStart(obj) {
- try {
- const { data } = await examUserExamStart(obj);
- if (data.code === 200) {
- let obj = {
- examId: item.examId,
- attemptId: response.data.attemptId,
- }
- //等待后续逻辑
- }
- } catch (e) { console.error('模拟考试获取试卷失败', e); }
- },
- //开始考试判断是否有承诺书
- setRichExamData(item){
- if(item.commitmentEnabled == 1 && !item.commitmentConfirmed){
- //富文本弹窗考试承诺书
- this.$set(this,'preButtonType',item.commitmentPrintEnabled == 1?true:false);
- this.$set(this,'richTextHtml',item.commitmentContent);
- this.$set(this,'preData',item);
- this.$set(this,'preExamDialogType',true);
- }else{
- if(item.attemptId){
- //上次考试未完成继续考试
- let obj = {
- attemptId: item.attemptId,
- type: '1',
- examKind:item.examKind,
- }
- //等待后续逻辑
- }else{
- //开始新考试
- this.examUserExamStart(item);
- }
- }
- },
- //开始考试
- async examUserExamStart(item) {
- try {
- let obj = {examId:item.examId,examScene:1};
- const { data } = await examUserExamStudyTaskList(obj);
- if (data.code === 200) {
- let obj = {
- examId: item.examId,
- attemptId: response.data.attemptId,
- type: '1',
- examKind:item.examKind,
- }
- //等待后续逻辑
- }
- } catch (e) { console.error('获取考试任务失败', e); }
- },
- //获取任务列表
- async examUserExamStudyTaskList() {
- try {
- let obj = { page: 1, pageSize: 1, examStatus: 2, isSpecialExam: false };
- const { data } = await examUserExamStudyTaskList(obj);
- if (data.code === 200) {
- this.$set(this,'onlineExamList',data.data.records);
- }
- } catch (e) { console.error('获取考试任务失败', e); }
- },
- },
- }
- </script>
- <style lang="stylus" scoped>
- .examTask-component {
- margin: 0 32rpx 32rpx;
- .card {
- background: #fff;
- border-radius: 24rpx;
- overflow: hidden;
- margin-bottom: 24rpx;
- box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.03);
- border: 1px solid #dde3ed;
- }
- .card-header {
- padding: 20rpx 28rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .card-title {
- font-size: 28rpx;
- color: #333;
- }
- .header-subtitle{
- margin-top:10rpx;
- font-size:22rpx;
- color:#8896a7;
- }
- .header-link {
- padding:10rpx 20rpx;
- font-size: 24rpx;
- color: #1857d4;
- }
- }
- .card-body {
- padding: 0 28rpx 24rpx;
- .for-max-box:nth-child(1){
- margin-top:0;
- }
- .for-max-box{
- margin-top:20rpx;
- display: flex;
- background-color:#f4f6fa;
- padding: 20rpx 24rpx;
- border-radius: 16rpx;
- .left-box{
- flex:1;
- view:nth-child(1){
- font-size:26rpx;
- margin-bottom:4rpx;
- }
- view:nth-child(2){
- font-size:22rpx;
- color:#8896a7;
- }
- }
- .right-box{
- line-height:60rpx;
- font-size:40rpx;
- color:#8896a7;
- }
- }
- .empty-tip{
- text-align: center;
- line-height:40rpx;
- color:#8896a7;
- font-size:24rpx;
- }
- }
- }
- </style>
|