pull/29/head
脆皮鸭 1 year ago
parent 89c4b2148e
commit 851319e24c
  1. 90
      src/pages/questionBank/components/Question.vue

@ -120,16 +120,16 @@
</view> </view>
<view class="text-center flex jc-c ai-c" style="flex-direction: column;" @tap="toCollect"> <view class="text-center flex jc-c ai-c" style="flex-direction: column;" @tap="toCollect">
<u-icon name="star-fill" v-if="collectList.includes(questionList[topicIndex].questionId)" <u-icon name="star-fill" v-if="collectList.includes(questionList[topicIndex].questionId)"
color="rgb(249,236,141)" size="24"></u-icon> color="rgb(249,236,141)" size="20"></u-icon>
<u-icon name="star" v-else size="24"></u-icon> <u-icon name="star" v-else size="20"></u-icon>
<text class="cor-666">{{collectList.includes(questionList[topicIndex].questionId)?'已收藏':'收藏'}}</text> <text class="cor-666">{{collectList.includes(questionList[topicIndex].questionId)?'已收藏':'收藏'}}</text>
</view> </view>
<view class="text-center"> <view class="text-center">
<view style="color: #00B74F;">{{rightList.length}}</view> <view style="color: #00B74F;">{{type=='exam'?rightList.length:storageRightList.length}}</view>
<text class="cor-666">答对</text> <text class="cor-666">答对</text>
</view> </view>
<view class="text-center"> <view class="text-center">
<view style="color: #FF6E02;">{{wrongList.length}}</view> <view style="color: #FF6E02;">{{type=='exam'?wrongList.length:storageWrongList.length}}</view>
<text class="cor-666">答错</text> <text class="cor-666">答错</text>
</view> </view>
<view class="text-center" @tap="popupShow=!popupShow"> <view class="text-center" @tap="popupShow=!popupShow">
@ -212,16 +212,16 @@
</view> </view>
<view class="text-center flex jc-c ai-c" style="flex-direction: column;" @tap="toCollect"> <view class="text-center flex jc-c ai-c" style="flex-direction: column;" @tap="toCollect">
<u-icon name="star-fill" v-if="collectList.includes(questionList[topicIndex].questionId)" <u-icon name="star-fill" v-if="collectList.includes(questionList[topicIndex].questionId)"
color="rgb(249,236,141)" size="24"></u-icon> color="rgb(249,236,141)" size="20"></u-icon>
<u-icon name="star" v-else size="24"></u-icon> <u-icon name="star" v-else size="20"></u-icon>
<text class="cor-666">{{collectList.includes(questionList[topicIndex].questionId)?'已收藏':'收藏'}}</text> <text class="cor-666">{{collectList.includes(questionList[topicIndex].questionId)?'已收藏':'收藏'}}</text>
</view> </view>
<view class="text-center"> <view class="text-center">
<view style="color: #00B74F;">{{rightList.length}}</view> <view style="color: #00B74F;">{{type=='exam'?rightList.length:storageRightList.length}}</view>
<text class="cor-666">答对</text> <text class="cor-666">答对</text>
</view> </view>
<view class="text-center"> <view class="text-center">
<view style="color: #FF6E02;">{{wrongList.length}}</view> <view style="color: #FF6E02;">{{type=='exam'?wrongList.length:storageWrongList.length}}</view>
<text class="cor-666">答错</text> <text class="cor-666">答错</text>
</view> </view>
<view class="text-center" @tap="popupShow=!popupShow"> <view class="text-center" @tap="popupShow=!popupShow">
@ -232,15 +232,17 @@
</view> </view>
</view> </view>
<view class="flex ai-c jc-fs p14" style="flex-wrap: wrap;max-height: 400px;overflow-y: scroll;"> <view class="flex ai-c jc-fs p14" style="flex-wrap: wrap;max-height: 400px;overflow-y: scroll;">
<view v-for="(item,index) of questionList" :key="item.questionId" style="width:20%;" class="flex ai-c jc-c" <view v-for="(item,index) of questionList" :key="item.questionId" style="width:20%;position: relative;" class="flex ai-c jc-c"
@tap="chooseQueston(index)"> @tap="chooseQueston(index)">
<view class="tCircle mb10" :class="{ <view class="tCircle mb10" :class="{
'active':index == topicIndex, 'active':index == topicIndex,
'success':rightList.includes(item.questionId), 'success':type=='exam'?rightList.includes(item.questionId):storageRightList.includes(item.questionId),
'error':wrongList.includes(item.questionId) 'error':type=='exam'?wrongList.includes(item.questionId):storageWrongList.includes(item.questionId)
}"> }">
{{index+1}} {{index+1}}
</view> </view>
<u-icon name="star-fill" v-if="collectList.includes(item.questionId)" style="position: absolute;right: 5px;top:-3px"
color="rgb(249,236,141)" size="24"></u-icon>
</view> </view>
</view> </view>
</view> </view>
@ -334,6 +336,8 @@
tCurrent: 0, tCurrent: 0,
index: 0, index: 0,
qIndex: 0, qIndex: 0,
storageRightList:storage.get(`rightList_subject${this.subject}`) || [],
storageWrongList: storage.get(`wrongList_subject${this.subject}`) || [],
rightList: [], rightList: [],
wrongList: [], wrongList: [],
collectList: storage.get(`collectList_subject${this.subject}`) || [], collectList: storage.get(`collectList_subject${this.subject}`) || [],
@ -407,8 +411,8 @@
if (this.tCurrent != 1) { if (this.tCurrent != 1) {
this.originArray = JSON.stringify(this.questionList) this.originArray = JSON.stringify(this.questionList)
} }
const falseList = storage.get(`wrongList_subject${this.subject}`) || [] // const falseList = storage.get(`wrongList_subject${this.subject}`) || []
const trueList = storage.get(`rightList_subject${this.subject}`) || [] // const trueList = storage.get(`rightList_subject${this.subject}`) || []
if (this.tCurrent !== 1) { if (this.tCurrent !== 1) {
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('')
@ -418,18 +422,18 @@
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 (!this.storageRightList.includes(this.questionList[this.topicIndex].questionId)) {
trueList.push(this.questionList[this.topicIndex].questionId) this.storageRightList.push(this.questionList[this.topicIndex].questionId)
storage.set(`rightList_subject${this.subject}`, trueList) storage.set(`rightList_subject${this.subject}`, this.storageRightList)
} }
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)
this.wrongList.splice(wIndex, 1) this.wrongList.splice(wIndex, 1)
} }
if (falseList.includes(this.questionList[this.topicIndex].questionId)) { if (this.storageWrongList.includes(this.questionList[this.topicIndex].questionId)) {
const wIndex = falseList.indexOf(this.questionList[this.topicIndex].questionId) const wIndex = this.storageWrongList.indexOf(this.questionList[this.topicIndex].questionId)
falseList.splice(wIndex, 1) this.storageWrongList.splice(wIndex, 1)
storage.set(`wrongList_subject${this.subject}`, falseList) storage.set(`wrongList_subject${this.subject}`, this.storageWrongList)
} }
// //
if (this.topicIndex < this.questionList.length - 1) { if (this.topicIndex < this.questionList.length - 1) {
@ -455,14 +459,14 @@
if (!this.wrongList.includes(this.questionList[this.topicIndex].questionId)) { if (!this.wrongList.includes(this.questionList[this.topicIndex].questionId)) {
this.wrongList.push(this.questionList[this.topicIndex].questionId) this.wrongList.push(this.questionList[this.topicIndex].questionId)
} }
if (!falseList.includes(this.questionList[this.topicIndex].questionId)) { if (!this.storageWrongList.includes(this.questionList[this.topicIndex].questionId)) {
falseList.push(this.questionList[this.topicIndex].questionId) this.storageWrongList.push(this.questionList[this.topicIndex].questionId)
storage.set(`wrongList_subject${this.subject}`, falseList) storage.set(`wrongList_subject${this.subject}`, this.storageWrongList)
} }
if (trueList.includes(this.questionList[this.topicIndex].questionId)) { if (this.storageRightList.includes(this.questionList[this.topicIndex].questionId)) {
const rIndex = trueList.indexOf(this.questionList[this.topicIndex].questionId) const rIndex = this.storageRightList.indexOf(this.questionList[this.topicIndex].questionId)
trueList.splice(rIndex, 1) this.storageRightList.splice(rIndex, 1)
storage.set(`rightList_subject${this.subject}`, trueList) storage.set(`rightList_subject${this.subject}`, this.storageRightList)
} }
} }
} }
@ -674,8 +678,8 @@
}, },
// //
answerQues(op, index) { answerQues(op, index) {
const falseList = storage.get(`wrongList_subject${this.subject}`) || [] // const falseList = storage.get(`wrongList_subject${this.subject}`) || []
const trueList = storage.get(`rightList_subject${this.subject}`) || [] // 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?this.questionList[this.topicIndex].optionList[index].chooseOption:''}${op}` `${this.questionList[this.topicIndex].optionList[index].chooseOption?this.questionList[this.topicIndex].optionList[index].chooseOption:''}${op}`
@ -708,18 +712,18 @@
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 (!this.storageRightList.includes(this.questionList[this.topicIndex].questionId)) {
trueList.push(this.questionList[this.topicIndex].questionId) this.storageRightList.push(this.questionList[this.topicIndex].questionId)
storage.set(`rightList_subject${this.subject}`, trueList) storage.set(`rightList_subject${this.subject}`, this.storageRightList)
} }
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)
this.wrongList.splice(wIndex, 1) this.wrongList.splice(wIndex, 1)
} }
if (falseList.includes(this.questionList[this.topicIndex].questionId)) { if (this.storageWrongList.includes(this.questionList[this.topicIndex].questionId)) {
const wIndex = falseList.indexOf(this.questionList[this.topicIndex].questionId) const wIndex = this.storageWrongList.indexOf(this.questionList[this.topicIndex].questionId)
falseList.splice(wIndex, 1) this.storageWrongList.splice(wIndex, 1)
storage.set(`wrongList_subject${this.subject}`, falseList) storage.set(`wrongList_subject${this.subject}`, this.storageWrongList)
} }
// //
if (this.topicIndex < this.questionList.length - 1) { if (this.topicIndex < this.questionList.length - 1) {
@ -745,14 +749,14 @@
if (!this.wrongList.includes(this.questionList[this.topicIndex].questionId)) { if (!this.wrongList.includes(this.questionList[this.topicIndex].questionId)) {
this.wrongList.push(this.questionList[this.topicIndex].questionId) this.wrongList.push(this.questionList[this.topicIndex].questionId)
} }
if (!falseList.includes(this.questionList[this.topicIndex].questionId)) { if (!this.storageWrongList.includes(this.questionList[this.topicIndex].questionId)) {
falseList.push(this.questionList[this.topicIndex].questionId) this.storageWrongList.push(this.questionList[this.topicIndex].questionId)
storage.set(`wrongList_subject${this.subject}`, falseList) storage.set(`wrongList_subject${this.subject}`, this.storageWrongList)
} }
if (trueList.includes(this.questionList[this.topicIndex].questionId)) { if (this.storageRightList.includes(this.questionList[this.topicIndex].questionId)) {
const rIndex = trueList.indexOf(this.questionList[this.topicIndex].questionId) const rIndex = this.storageRightList.indexOf(this.questionList[this.topicIndex].questionId)
trueList.splice(rIndex, 1) this.storageRightList.splice(rIndex, 1)
storage.set(`rightList_subject${this.subject}`, trueList) storage.set(`rightList_subject${this.subject}`, this.storageRightList)
} }
} }
} }

Loading…
Cancel
Save