@ -15,6 +15,7 @@
< / view >
< / view >
< view class = "flex m14lr ai-c mt20" v -for = " ( item , index ) in quesItem.optionList "
< view class = "flex m14lr ai-c mt20" v -for = " ( item , index ) in quesItem.optionList "
: key = "item.op" @ tap = "answerQues(item.opValue,index)" >
: key = "item.op" @ tap = "answerQues(item.opValue,index)" >
< template v-if ="item.opDesc" >
< template
< template
v - if = "quesItem.clickAnswer&&quesItem.trueAnswer.includes(item.opValue)" >
v - if = "quesItem.clickAnswer&&quesItem.trueAnswer.includes(item.opValue)" >
< u -icon class = "mr15" name = "checkmark-circle-fill" color = "#05C341" size = "32" > < / u - i c o n >
< u -icon class = "mr15" name = "checkmark-circle-fill" color = "#05C341" size = "32" > < / u - i c o n >
@ -27,6 +28,7 @@
< view class = "option_item" > { { item . op } } < / view >
< view class = "option_item" > { { item . op } } < / view >
< / template >
< / template >
< text class = "fs18" > { { item . opDesc } } < / text >
< text class = "fs18" > { { item . opDesc } } < / text >
< / template >
< / view >
< / view >
< view class = "m14lr mt30"
< view class = "m14lr mt30"
v - if = "quesItem.clickAnswer&&!quesItem.trueAnswer.includes(quesItem.clickAnswer) || tCurrent===1" >
v - if = "quesItem.clickAnswer&&!quesItem.trueAnswer.includes(quesItem.clickAnswer) || tCurrent===1" >
@ -43,7 +45,7 @@
< view style = "width: 220rpx;" >
< view style = "width: 220rpx;" >
< button v-if ="type==='practice'" class="btn" > 四步学科一 < / button >
< button v-if ="type==='practice'" class="btn" > 四步学科一 < / button >
< view v -else class = "btn" style = "text-align: center;" @tap ="submitPaper" >
< 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 - c o u n t - d o w n >
< u -count -down ref = "countDown_1" : time = " 1 *60*60 * 1000" format = "HH:mm:ss" @change ="timeChange" > < / u -count -down >
< text > 交卷 < / text >
< text > 交卷 < / text >
< / view >
< / view >
< / view >
< / view >
@ -90,15 +92,15 @@
< text > 确认交卷 < / text >
< text > 确认交卷 < / text >
< view class = "mt20 flex ai-c jc-sb" >
< view class = "mt20 flex ai-c jc-sb" >
< view class = "text-center" >
< 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 class = "cor-333" > 未答题数 < / view >
< / view >
< / view >
< view class = "text-center" >
< view class = "text-center" >
< u -count -down ref = "countDown_3" class = "balckColor" : time = "1 * 60 * 60 * 1000" format = "HH:mm:ss" > < / u - c o u n t - d o w n >
< u -count -down ref = "countDown_3" class = "balckColor" : time = "1*60*60 * 1000" format = "HH:mm:ss" > < / u - c o u n t - d o w n >
< view > 剩余时间 < / view >
< view > 剩余时间 < / view >
< / view >
< / view >
< view class = "text-center" >
< 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 class = "cor-333" > 考试得分 < / view >
< / view >
< / view >
< / view >
< / view >
@ -139,7 +141,7 @@
< text class = "cor-666" > 题板 < / text >
< text class = "cor-666" > 题板 < / text >
< / view >
< / view >
< / view >
< / view >
< view class = "flex ai-c jc-sb p14" style = "flex-wrap: wrap;max-height: 400px;overflow-y: scroll;" >
< view class = "flex ai-c jc-f s p14" style = "flex-wrap: wrap;max-height: 400px;overflow-y: scroll;" >
< view v-for ="(item,index) of questionList" :key="index" style="width:20%;" class="flex ai-c jc-c" @tap="chooseQueston(index)" >
< view v-for ="(item,index) of questionList" :key="index" style="width:20%;" class="flex ai-c jc-c" @tap="chooseQueston(index)" >
< view class = "tCircle mb10" : class = " {
< view class = "tCircle mb10" : class = " {
'active' : index == topicIndex ,
'active' : index == topicIndex ,
@ -186,7 +188,15 @@
< / template >
< / template >
< script >
< script >
import {
mapState ,
mapActions
} from 'pinia' / / 引 入 映 射 函 数
import storage from '@/jtools/storage' ;
import storage from '@/jtools/storage' ;
import useQuestionStore from '@/jtools/store/question' / / 引 入 s t o r e
import {
submitTest
} from '@/jtools/api/question' ;
export default {
export default {
props : {
props : {
tabsList : {
tabsList : {
@ -203,6 +213,13 @@ export default {
isShowAll : {
isShowAll : {
type : Boolean ,
type : Boolean ,
default : true
default : true
} ,
subject : {
type : [ String , Number ] ,
default : 1 ,
} ,
navTitle : {
type : String
}
}
} ,
} ,
data ( ) {
data ( ) {
@ -218,19 +235,34 @@ export default {
qIndex : 0 ,
qIndex : 0 ,
rightList : [ ] ,
rightList : [ ] ,
wrongList : [ ] ,
wrongList : [ ] ,
collectList : storage . get ( 'collectList' ) || [ ] ,
collectList : storage . get ( ` collectList_subject ${ this . subject } ` ) || [ ] ,
questionList : [ { isCollect : true } ] , / / 数 据 源
questionList : [ { isCollect : true } ] , / / 数 据 源
swiperList : [ ] , / / 轮 播 图 数 据 列 表
swiperList : [ ] , / / 轮 播 图 数 据 列 表
swiperIndex : 0 , / / 轮 播 图 当 前 位 置
swiperIndex : 0 , / / 轮 播 图 当 前 位 置
isChange : false , / / 是 否 切 换
isChange : false , / / 是 否 切 换
topicIndex : 0 , / / 题 目 位 置
topicIndex : 0 , / / 题 目 位 置
duration : 200 , / / 动 画 过 渡 时 长
duration : 200 , / / 动 画 过 渡 时 长
time : 0 ,
}
}
} ,
} ,
onLoad ( ) {
this . renderSwiper ( 0 )
computed : {
... mapState ( useQuestionStore , [ "currentIndex_subject1" , "currentIndex_subject2" ] ) / / 映 射 函 数 , 取 出 t a g s l i s t
} ,
} ,
methods : {
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 ) {
getRightOp ( val ) {
let rightOp = ''
let rightOp = ''
@ -278,14 +310,29 @@ export default {
} ,
} ,
/ / 交 卷
/ / 交 卷
toSubmit ( ) {
toSubmit ( ) {
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 ,
subject : this . subject
} ) . 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 ( {
uni . navigateTo ( {
url : "/pages/questionBank/examResult"
url : "/pages/questionBank/examResult?doNotNum=" + doNotNum + "&wrongList=" + list + "&score=" + score + "&subject=" + this . subject + "&navTitle=" + this . navTitle
} )
}
} )
} )
} ,
} ,
/ / 查 看 考 试 结 果
/ / 查 看 考 试 结 果
toResult ( ) {
toResult ( ) {
const allDoNum = this . wrongList . length + this . rightList . length
const list = JSON . stringify ( this . wrongList )
uni . navigateTo ( {
uni . navigateTo ( {
url : "/pages/questionBank/practiceResult"
url : "/pages/questionBank/practiceResult?allDoNum= " + allDoNum + "&wrongList=" + list + "&subject=" + this . subject + "&navTitle=" + this . navTitle
} )
} )
} ,
} ,
toCollect ( ) {
toCollect ( ) {
@ -307,7 +354,7 @@ export default {
icon : 'none'
icon : 'none'
} )
} )
}
}
storage . set ( 'collectList' , this . collectList )
storage . set ( ` collectList_subject ${ this . subject } ` , this . collectList )
} ,
} ,
cancel ( ) {
cancel ( ) {
this . tipShow = false
this . tipShow = false
@ -360,6 +407,7 @@ export default {
/ / 轮 播 图 当 前 位 置 小 于 原 来 时 则 表 示 为 上 一 题
/ / 轮 播 图 当 前 位 置 小 于 原 来 时 则 表 示 为 上 一 题
this . topicIndex -- ;
this . topicIndex -- ;
}
}
this . getCurrentIndex ( this . topicIndex , this . subject )
/ / 更 新 轮 播 图 位 置 数 值 , 为 更 新 时 让 V u e 能 监 听 到 数 据 有 改 变
/ / 更 新 轮 播 图 位 置 数 值 , 为 更 新 时 让 V u e 能 监 听 到 数 据 有 改 变
this . swiperIndex = e . detail . current ;
this . swiperIndex = e . detail . current ;
} ,
} ,
@ -385,6 +433,8 @@ export default {
/ / 选 择 题 目
/ / 选 择 题 目
pickerTopic ( index ) {
pickerTopic ( index ) {
this . topicIndex = index ;
this . topicIndex = index ;
this . index = this . topicIndex
this . getCurrentIndex ( this . topicIndex , this . subject )
this . renderSwiper ( index ) ;
this . renderSwiper ( index ) ;
} ,
} ,
isArrEqual ( arr1 , arr2 ) {
isArrEqual ( arr1 , arr2 ) {
@ -392,8 +442,8 @@ export default {
} ,
} ,
/ / 答 题
/ / 答 题
answerQues ( op , index ) {
answerQues ( op , index ) {
const falseList = storage . get ( 'wrongList' ) || [ ]
const falseList = storage . get ( ` wrongList_subject ${ this . subject } ` ) || [ ]
const trueList = storage . get ( 'rightList' ) || [ ]
const trueList = storage . get ( ` rightList_subject ${ this . subject } ` ) || [ ]
if ( ! this . questionList [ this . topicIndex ] . clickAnswer ) {
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 ] . 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 } `
this . questionList [ this . topicIndex ] . clickAnswer = ` ${ this . questionList [ this . topicIndex ] . optionList [ index ] . clickAnswer ? this . questionList [ this . topicIndex ] . optionList [ index ] . clickAnswer : '' } ${ op } `
@ -402,12 +452,14 @@ export default {
const arr1 = this . questionList [ this . topicIndex ] . clickAnswer . split ( '' )
const arr1 = this . questionList [ this . topicIndex ] . clickAnswer . split ( '' )
const arr2 = this . questionList [ this . topicIndex ] . trueAnswer . split ( '' )
const arr2 = this . questionList [ this . topicIndex ] . trueAnswer . split ( '' )
if ( this . isArrEqual ( arr1 , arr2 ) ) {
if ( this . isArrEqual ( arr1 , arr2 ) ) {
/ / 判 断 选 择 的 答 案 和 实 际 的 答 案 是 否 相 同 , 如 果 相 同 , 判 断 如 果 该 题 的 I D 在 不 在 正 确 的 数 组 中 , 不 在 则 P u s h ( 存 储 的 的 同 理 )
/ / 如 果 这 道 题 在 错 误 的 数 组 中 则 把 这 道 题 在 错 误 数 组 中 删 掉
if ( ! this . rightList . includes ( this . questionList [ this . topicIndex ] . questionId ) ) {
if ( ! this . rightList . includes ( this . questionList [ this . topicIndex ] . questionId ) ) {
this . rightList . push ( this . questionList [ this . topicIndex ] . questionId )
this . rightList . push ( this . questionList [ this . topicIndex ] . questionId )
}
}
if ( ! trueList . includes ( this . questionList [ this . topicIndex ] . questionId ) ) {
if ( ! trueList . includes ( this . questionList [ this . topicIndex ] . questionId ) ) {
trueList . push ( 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 ) ) {
if ( this . wrongList . includes ( this . questionList [ this . topicIndex ] . questionId ) ) {
const wIndex = this . wrongList . indexOf ( this . questionList [ this . topicIndex ] . questionId )
const wIndex = this . wrongList . indexOf ( this . questionList [ this . topicIndex ] . questionId )
@ -416,8 +468,9 @@ export default {
if ( falseList . includes ( this . questionList [ this . topicIndex ] . questionId ) ) {
if ( falseList . includes ( this . questionList [ this . topicIndex ] . questionId ) ) {
const wIndex = falseList . indexOf ( this . questionList [ this . topicIndex ] . questionId )
const wIndex = falseList . indexOf ( this . questionList [ this . topicIndex ] . questionId )
falseList . splice ( wIndex , 1 )
falseList . splice ( wIndex , 1 )
storage . set ( 'wrongList' , falseList )
storage . set ( ` wrongList_subject ${ this . subject } ` , falseList )
}
}
/ / 答 对 题 目 如 果 不 是 最 后 一 题 , 跳 下 一 题
if ( this . topicIndex < this .questionList.length -1 ) {
if ( this . topicIndex < this .questionList.length -1 ) {
this . topicIndex ++ ;
this . topicIndex ++ ;
this . qIndex = this . topicIndex
this . qIndex = this . topicIndex
@ -443,12 +496,12 @@ export default {
}
}
if ( ! falseList . includes ( this . questionList [ this . topicIndex ] . questionId ) ) {
if ( ! falseList . includes ( this . questionList [ this . topicIndex ] . questionId ) ) {
falseList . push ( 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 ) ) {
if ( trueList . includes ( this . questionList [ this . topicIndex ] . questionId ) ) {
const rIndex = trueList . indexOf ( this . questionList [ this . topicIndex ] . questionId )
const rIndex = trueList . indexOf ( this . questionList [ this . topicIndex ] . questionId )
trueList . splice ( rIndex , 1 )
trueList . splice ( rIndex , 1 )
storage . set ( 'wrongList' , trueList )
storage . set ( ` rightList_subject ${ this . subject } ` , trueList )
}
}
}
}
}
}
@ -459,17 +512,23 @@ export default {
this . renderSwiper ( 0 )
this . renderSwiper ( 0 )
} ,
} ,
getQuestionList ( val ) {
getQuestionList ( val ) {
console . log ( val ) ;
const arr = JSON . parse ( val )
this . questionList = val . map ( item => {
this . questionList = [ ]
arr . forEach ( item => {
let isCollect = false
let isCollect = false
if ( this . collectList . includes ( item . questionId ) ) {
if ( this . collectList . includes ( item . questionId ) ) {
isCollect = true
isCollect = true
}
}
return {
this . questionList . push ( {
isCollect : isCollect ,
isCollect : isCollect ,
... item
... item
}
} )
} )
} )
if ( this . navTitle === '顺序答题' ) {
this . pickerTopic ( this [ ` currentIndex_subject ${ this . subject } ` ] )
} else {
this . renderSwiper ( 0 )
}
}
}
}
}
}
}