Commit 3227703d authored by Damon's avatar Damon

feat: 已选答案回显

parent 5263292f
...@@ -68,8 +68,8 @@ export default { ...@@ -68,8 +68,8 @@ export default {
handler: function(newValue, oldValue) { handler: function(newValue, oldValue) {
if (newValue.length > 0) { if (newValue.length > 0) {
this.lists = newValue.map((v) => { this.lists = newValue.map((v) => {
v.checked = false if (!v.checked) v.checked = false
v.confirm = false if (!v.confirm) v.confirm = false
return v return v
}) })
} }
...@@ -119,7 +119,7 @@ export default { ...@@ -119,7 +119,7 @@ export default {
}, },
submitAnswer() { submitAnswer() {
this.submitStatus = true this.submitStatus = true
this.$emit('change', this.answer) this.$emit('change', this.answer, this.lists)
}, },
}, },
} }
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
></answer-sheet> ></answer-sheet>
</view> </view>
<view class="explain" v-if="type === 1"> <view class="explain" v-if="type === 1">
<answer-explanation v-show="model === 2 || 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>
</swiper-item> </swiper-item>
...@@ -37,6 +37,7 @@ const END = 2 ...@@ -37,6 +37,7 @@ const END = 2
const SWIPER_LENGTH = 3 const SWIPER_LENGTH = 3
const NO_PREV_PAGE = -1 const NO_PREV_PAGE = -1
const NO_NEXT_PAGE = -2 const NO_NEXT_PAGE = -2
const app = getApp()
export default { export default {
name: 'swiper-limited-load', name: 'swiper-limited-load',
...@@ -85,8 +86,6 @@ export default { ...@@ -85,8 +86,6 @@ export default {
swiperCurrent: 0, swiperCurrent: 0,
// 当前swiper渲染的items // 当前swiper渲染的items
swiperList: [], swiperList: [],
// 错题显示解释
errShow: false
} }
}, },
watch: { watch: {
...@@ -122,18 +121,15 @@ export default { ...@@ -122,18 +121,15 @@ export default {
this.swiperIndex = current this.swiperIndex = current
this.swiperCurrent = current this.swiperCurrent = current
}, },
answerChange(e) { answerChange(status, lists) {
// this.swiperCurrent = this.swiperCurrent + 1 // this.swiperCurrent = this.swiperCurrent + 1
this.$emit("answerChange", e) this.$emit("answerChange", status, lists, this.list[this.swiperIndex].index)
this.errShow = e === 'fail'
console.log("e", e)
}, },
clear () { clear () {
this.list = [] this.list = []
this.swiperList = [] this.swiperList = []
}, },
swiperChange: function (e) { swiperChange: function (e) {
this.errShow = false
let current = e.detail.current let current = e.detail.current
let lastIndex = this.swiperIndex let lastIndex = this.swiperIndex
let currentItem = this.swiperList[current] let currentItem = this.swiperList[current]
...@@ -220,10 +216,7 @@ export default { ...@@ -220,10 +216,7 @@ export default {
getNextSwiperNeedItem : function (currentItem, list) { getNextSwiperNeedItem : function (currentItem, list) {
if (currentItem == null) return null; if (currentItem == null) return null;
let listNeedIndex = currentItem.index + 1 let listNeedIndex = currentItem.index + 1
let realIndex = list.findIndex(function(item){ let realIndex = list.findIndex(item => item.index == listNeedIndex)
return item.index == listNeedIndex
})
if (realIndex == -1) return null if (realIndex == -1) return null
let total = this.total != 0 ? this.total : list.length let total = this.total != 0 ? this.total : list.length
let item = listNeedIndex == total ? null : list[realIndex] let item = listNeedIndex == total ? null : list[realIndex]
......
...@@ -205,8 +205,11 @@ export default { ...@@ -205,8 +205,11 @@ export default {
console.log("收藏") console.log("收藏")
}, },
// 作答完毕 // 作答完毕
answerChange(e) { answerChange(status, lists, index) {
console.log('e', e) this.$set(this.list[index], 'answerList', lists)
this.$set(this.list[index], 'errShow', status === 'fail')
app.globalData.questionList = this.list
console.log("this.list", app.globalData.questionList)
}, },
// 交卷 // 交卷
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