提交
This commit is contained in:
@@ -15,18 +15,20 @@
|
||||
</view>
|
||||
<view class="flex m14lr ai-c mt20" v-for="(item,index) in quesItem.optionList"
|
||||
:key="item.op" @tap="answerQues(item.opValue,index)">
|
||||
<template
|
||||
v-if="quesItem.clickAnswer&&quesItem.trueAnswer.includes(item.opValue)">
|
||||
<u-icon class="mr15" name="checkmark-circle-fill" color="#05C341" size="32"></u-icon>
|
||||
</template>
|
||||
<template
|
||||
v-else-if="quesItem.clickAnswer&&quesItem.clickAnswer.includes(item.opValue)&&!quesItem.trueAnswer.includes(item.opValue)">
|
||||
<u-icon class="mr15" name="close-circle-fill" color="red" size="32"></u-icon>
|
||||
</template>
|
||||
<template v-else-if="!item.chooseOption">
|
||||
<view class="option_item">{{item.op}}</view>
|
||||
</template>
|
||||
<text class="fs18">{{item.opDesc}}</text>
|
||||
<template v-if="item.opDesc">
|
||||
<template
|
||||
v-if="quesItem.clickAnswer&&quesItem.trueAnswer.includes(item.opValue)">
|
||||
<u-icon class="mr15" name="checkmark-circle-fill" color="#05C341" size="32"></u-icon>
|
||||
</template>
|
||||
<template
|
||||
v-else-if="quesItem.clickAnswer&&quesItem.clickAnswer.includes(item.opValue)&&!quesItem.trueAnswer.includes(item.opValue)">
|
||||
<u-icon class="mr15" name="close-circle-fill" color="red" size="32"></u-icon>
|
||||
</template>
|
||||
<template v-else-if="!item.chooseOption">
|
||||
<view class="option_item">{{item.op}}</view>
|
||||
</template>
|
||||
<text class="fs18">{{item.opDesc}}</text>
|
||||
</template>
|
||||
</view>
|
||||
<view class="m14lr mt30"
|
||||
v-if="quesItem.clickAnswer&&!quesItem.trueAnswer.includes(quesItem.clickAnswer) || tCurrent===1">
|
||||
@@ -43,7 +45,7 @@
|
||||
<view style="width: 220rpx;">
|
||||
<button v-if="type==='practice'" class="btn">四步学科一</button>
|
||||
<view v-else class="btn" style="text-align: center;" @tap="submitPaper">
|
||||
<u-count-down ref="countDown_1" :time="1 * 60 * 60 * 1000" format="HH:mm:ss"></u-count-down>
|
||||
<u-count-down ref="countDown_1" :time=" 1*60*60 * 1000" format="HH:mm:ss" @change="timeChange"></u-count-down>
|
||||
<text>交卷</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -90,15 +92,15 @@
|
||||
<text>确认交卷</text>
|
||||
<view class="mt20 flex ai-c jc-sb">
|
||||
<view class="text-center">
|
||||
<text style="color:#FF6E02">99</text>
|
||||
<text style="color:#FF6E02">{{questionList.length-rightList.length-wrongList.length}}</text>
|
||||
<view class="cor-333">未答题数</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<u-count-down ref="countDown_3" class="balckColor" :time="1 * 60 * 60 * 1000" format="HH:mm:ss"></u-count-down>
|
||||
<u-count-down ref="countDown_3" class="balckColor" :time="1*60*60 * 1000" format="HH:mm:ss"></u-count-down>
|
||||
<view>剩余时间</view>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<text style="color:#333">9</text>
|
||||
<text style="color:#333">{{(rightList.length/questionList.length * 100).toFixed(0)}}</text>
|
||||
<view class="cor-333">考试得分</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -186,7 +188,15 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
mapState,
|
||||
mapActions
|
||||
} from 'pinia' //引入映射函数
|
||||
import storage from '@/jtools/storage';
|
||||
import useQuestionStore from '@/jtools/store/question' //引入store
|
||||
import {
|
||||
submitTest
|
||||
} from '@/jtools/api/question';
|
||||
export default {
|
||||
props:{
|
||||
tabsList:{
|
||||
@@ -203,6 +213,13 @@ export default {
|
||||
isShowAll:{
|
||||
type:Boolean,
|
||||
default:true
|
||||
},
|
||||
subject:{
|
||||
type:[String,Number],
|
||||
default:1,
|
||||
},
|
||||
navTitle:{
|
||||
type:String
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@@ -218,19 +235,34 @@ export default {
|
||||
qIndex:0,
|
||||
rightList:[],
|
||||
wrongList:[],
|
||||
collectList:storage.get('collectList') || [],
|
||||
collectList:storage.get(`collectList_subject${this.subject}`) || [],
|
||||
questionList: [{isCollect:true}],//数据源
|
||||
swiperList: [], // 轮播图数据列表
|
||||
swiperIndex: 0, // 轮播图当前位置
|
||||
isChange: false, // 是否切换
|
||||
topicIndex: 0, // 题目位置
|
||||
duration: 200, // 动画过渡时长
|
||||
time:0,
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.renderSwiper(0)
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState(useQuestionStore, ["currentIndex_subject1","currentIndex_subject2"]) //映射函数,取出tagslist
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useQuestionStore,['getCurrentIndex']),
|
||||
timeChange(e){
|
||||
this.time=e
|
||||
if(e.hours==0&&e.minutes==0&&e.seconds==0&&e.milliseconds==0){
|
||||
uni.showToast({
|
||||
title:"考试结束,将为您自动交卷~",
|
||||
icon:'none'
|
||||
})
|
||||
setTimeout(()=>{
|
||||
this.toSubmit()
|
||||
},1000)
|
||||
}
|
||||
},
|
||||
//获取正确选项
|
||||
getRightOp(val){
|
||||
let rightOp=''
|
||||
@@ -278,8 +310,20 @@ export default {
|
||||
},
|
||||
//交卷
|
||||
toSubmit(){
|
||||
uni.navigateTo({
|
||||
url:"/pages/questionBank/examResult"
|
||||
const restTime=this.time.hours*60*60+this.time.minutes*60+this.time.seconds
|
||||
const score=(this.rightList.length/this.questionList.length * 100).toFixed(0)
|
||||
submitTest({
|
||||
"carTypeId": storage.get('carType') || '1001',
|
||||
"score": score,
|
||||
"testTime": 60*60-restTime,
|
||||
}).then(resp=>{
|
||||
const doNotNum=this.questionList.length-this.rightList.length-this.wrongList.length
|
||||
const list = JSON.stringify(this.wrongList)
|
||||
if(resp.code==='0000'){
|
||||
uni.navigateTo({
|
||||
url:"/pages/questionBank/examResult?doNotNum="+doNotNum+"&wrongList="+list+"&score="+score+"&subject="+this.subject
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
//查看考试结果
|
||||
@@ -307,7 +351,7 @@ export default {
|
||||
icon:'none'
|
||||
})
|
||||
}
|
||||
storage.set('collectList',this.collectList)
|
||||
storage.set(`collectList_subject${this.subject}`,this.collectList)
|
||||
},
|
||||
cancel(){
|
||||
this.tipShow=false
|
||||
@@ -360,6 +404,7 @@ export default {
|
||||
// 轮播图当前位置小于原来时则表示为上一题
|
||||
this.topicIndex--;
|
||||
}
|
||||
this.getCurrentIndex(this.topicIndex,this.subject)
|
||||
// 更新轮播图位置数值,为更新时让 Vue 能监听到数据有改变
|
||||
this.swiperIndex = e.detail.current;
|
||||
},
|
||||
@@ -385,6 +430,7 @@ export default {
|
||||
// 选择题目
|
||||
pickerTopic(index) {
|
||||
this.topicIndex = index;
|
||||
this.getCurrentIndex(this.topicIndex,this.subject)
|
||||
this.renderSwiper(index);
|
||||
},
|
||||
isArrEqual(arr1, arr2){
|
||||
@@ -392,8 +438,8 @@ export default {
|
||||
},
|
||||
//答题
|
||||
answerQues(op, index) {
|
||||
const falseList =storage.get('wrongList') || []
|
||||
const trueList =storage.get('rightList') || []
|
||||
const falseList =storage.get(`wrongList_subject${this.subject}`) || []
|
||||
const trueList =storage.get(`rightList_subject${this.subject}`) || []
|
||||
if (!this.questionList[this.topicIndex].clickAnswer) {
|
||||
this.questionList[this.topicIndex].optionList[index].chooseOption =`${this.questionList[this.topicIndex].optionList[index].chooseOption?this.questionList[this.topicIndex].optionList[index].chooseOption:''}${op}`
|
||||
this.questionList[this.topicIndex].clickAnswer = `${this.questionList[this.topicIndex].optionList[index].clickAnswer?this.questionList[this.topicIndex].optionList[index].clickAnswer:''}${op}`
|
||||
@@ -402,12 +448,14 @@ export default {
|
||||
const arr1=this.questionList[this.topicIndex].clickAnswer.split('')
|
||||
const arr2=this.questionList[this.topicIndex].trueAnswer.split('')
|
||||
if(this.isArrEqual(arr1,arr2)){
|
||||
//判断选择的答案和实际的答案是否相同,如果相同,判断如果该题的ID在不在正确的数组中,不在则Push(存储的的同理)
|
||||
//如果这道题在错误的数组中则把这道题在错误数组中删掉
|
||||
if(!this.rightList.includes(this.questionList[this.topicIndex].questionId)){
|
||||
this.rightList.push(this.questionList[this.topicIndex].questionId)
|
||||
}
|
||||
if(!trueList.includes(this.questionList[this.topicIndex].questionId)){
|
||||
trueList.push(this.questionList[this.topicIndex].questionId)
|
||||
storage.set('rightList',trueList)
|
||||
storage.set(`rightList_subject${this.subject}`,trueList)
|
||||
}
|
||||
if(this.wrongList.includes(this.questionList[this.topicIndex].questionId)){
|
||||
const wIndex=this.wrongList.indexOf(this.questionList[this.topicIndex].questionId)
|
||||
@@ -416,8 +464,9 @@ export default {
|
||||
if(falseList.includes(this.questionList[this.topicIndex].questionId)){
|
||||
const wIndex=falseList.indexOf(this.questionList[this.topicIndex].questionId)
|
||||
falseList.splice(wIndex,1)
|
||||
storage.set('wrongList',falseList)
|
||||
storage.set(`wrongList_subject${this.subject}`,falseList)
|
||||
}
|
||||
//答对题目 如果不是最后一题,跳下一题
|
||||
if(this.topicIndex<this.questionList.length-1){
|
||||
this.topicIndex ++;
|
||||
this.qIndex=this.topicIndex
|
||||
@@ -443,12 +492,12 @@ export default {
|
||||
}
|
||||
if(!falseList.includes(this.questionList[this.topicIndex].questionId)){
|
||||
falseList.push(this.questionList[this.topicIndex].questionId)
|
||||
storage.set('wrongList',falseList)
|
||||
storage.set(`wrongList_subject${this.subject}`,falseList)
|
||||
}
|
||||
if(trueList.includes(this.questionList[this.topicIndex].questionId)){
|
||||
const rIndex=trueList.indexOf(this.questionList[this.topicIndex].questionId)
|
||||
trueList.splice(rIndex,1)
|
||||
storage.set('wrongList',trueList)
|
||||
storage.set(`rightList_subject${this.subject}`,trueList)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -459,17 +508,23 @@ export default {
|
||||
this.renderSwiper(0)
|
||||
},
|
||||
getQuestionList(val) {
|
||||
console.log(val);
|
||||
this.questionList=val.map(item=>{
|
||||
const arr = JSON.parse(val)
|
||||
this.questionList=[]
|
||||
arr.forEach(item=>{
|
||||
let isCollect=false
|
||||
if(this.collectList.includes(item.questionId)){
|
||||
isCollect=true
|
||||
}
|
||||
return {
|
||||
this.questionList.push({
|
||||
isCollect:isCollect,
|
||||
...item
|
||||
}
|
||||
})
|
||||
})
|
||||
if(this.navTitle==='顺序答题'){
|
||||
this.pickerTopic(this[`currentIndex_subject${this.subject}`])
|
||||
}else{
|
||||
this.renderSwiper(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user