Commit 6e125020 authored by Damon's avatar Damon

refactor: 作答完毕逻辑处理

parent 019222e8
...@@ -59,7 +59,9 @@ export default { ...@@ -59,7 +59,9 @@ export default {
data() { data() {
return { return {
lists: [], lists: [],
// 已提交答案
submitStatus: false, submitStatus: false,
// 答案对错
answer: '', answer: '',
} }
}, },
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
@change="answerChange" @change="answerChange"
></answer-sheet> ></answer-sheet>
</view> </view>
<view class="explain" v-if="type === 1"> <view class="explain">
<answer-explanation v-show="model === 2 || item.errShow" :answer="item.answer" :explain="item.explain"></answer-explanation> <answer-explanation v-show="model === 2 || item.errShow" :answer="item.answer" :explain="item.explain"></answer-explanation>
</view> </view>
</view> </view>
...@@ -122,9 +122,8 @@ export default { ...@@ -122,9 +122,8 @@ export default {
this.swiperCurrent = current this.swiperCurrent = current
}, },
answerChange(status, lists) { answerChange(status, lists) {
this.$set(this.swiperList[this.swiperIndex], 'errShow', status === 'fail') this.$set(this.swiperList[this.swiperIndex], 'errShow', this.type === 2 ? true : status === 'fail')
this.$emit("answerChange", status, lists, this.list[this.swiperIndex].index) this.$emit("answerChange", status, lists)
if (status === 'pass') this.swiperCurrent = this.swiperCurrent + 1
}, },
clear () { clear () {
this.list = [] this.list = []
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
title="答题" title="答题"
title-bold title-bold
></u-navbar> ></u-navbar>
<view class="head"> <view class="head" v-if="type !== 3">
<view class="u-flex tab" v-if="type === 1"> <view class="u-flex tab" v-if="type === 1">
<view :class="['tab-list', {'active': model === 1}]" @click="changeModel(1)">答题模式</view> <view :class="['tab-list', {'active': model === 1}]" @click="changeModel(1)">答题模式</view>
<view :class="['tab-list', {'active': model === 2}]" @click="changeModel(2)">学习模式</view> <view :class="['tab-list', {'active': model === 2}]" @click="changeModel(2)">学习模式</view>
...@@ -39,11 +39,11 @@ ...@@ -39,11 +39,11 @@
</view> </view>
</view> </view>
<view class="u-flex"> <view class="u-flex">
<view class="c-list" v-if="type === 1" @click="collection"> <view class="c-list" v-if="type === 1 || type === 3" @click="collection">
<u-icon name="star" color="#5A6073" size="40"></u-icon> <u-icon name="star" color="#5A6073" size="40"></u-icon>
<text>收藏</text> <text>收藏</text>
</view> </view>
<view class="c-list" v-else @click="handPapers"> <view class="c-list" v-if="type === 2" @click="handPapers">
<u-icon name="file-text" color="#5A6073" size="40"></u-icon> <u-icon name="file-text" color="#5A6073" size="40"></u-icon>
<text>交卷</text> <text>交卷</text>
</view> </view>
...@@ -80,7 +80,7 @@ export default { ...@@ -80,7 +80,7 @@ export default {
return { return {
visible: false, visible: false,
show: false, show: false,
// 1 练习 2 考试 // 1 练习 2 考试 3 每日一练
type: 1, type: 1,
// 1 答题模式 2 学习模式 // 1 答题模式 2 学习模式
model: 1, model: 1,
...@@ -223,11 +223,18 @@ export default { ...@@ -223,11 +223,18 @@ export default {
console.log("收藏") console.log("收藏")
}, },
// 作答完毕 // 作答完毕
answerChange(status, lists, index) { answerChange(status, lists) {
// 保存答题状态
this.$set(this.list[this.currentIndex], 'answerList', lists) this.$set(this.list[this.currentIndex], 'answerList', lists)
this.$set(this.list[this.currentIndex], 'errShow', status === 'fail') this.$set(this.list[this.currentIndex], 'errShow', this.type === 2 ? true : status === 'fail')
app.globalData.questionList = this.list app.globalData.questionList = this.list
console.log("this.list", app.globalData.questionList) // 如果回答错误或者是考试模式,自动进入下一题
if (status === 'pass' || this.type === 2) {
if (this.currentIndex + 1 > this.list.length - 1) {
return
}
this.current = this.currentIndex + 1
}
}, },
// 交卷 // 交卷
handPapers() { handPapers() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment