Commit 019222e8 authored by Damon's avatar Damon

refactor: 答题状态回显

parent d0bc0751
...@@ -122,8 +122,9 @@ export default { ...@@ -122,8 +122,9 @@ export default {
this.swiperCurrent = current this.swiperCurrent = current
}, },
answerChange(status, lists) { answerChange(status, lists) {
// this.swiperCurrent = this.swiperCurrent + 1 this.$set(this.swiperList[this.swiperIndex], 'errShow', status === 'fail')
this.$emit("answerChange", status, lists, this.list[this.swiperIndex].index) this.$emit("answerChange", status, lists, this.list[this.swiperIndex].index)
if (status === 'pass') this.swiperCurrent = this.swiperCurrent + 1
}, },
clear () { clear () {
this.list = [] this.list = []
......
...@@ -160,6 +160,25 @@ export default { ...@@ -160,6 +160,25 @@ export default {
index: 2, index: 2,
rightKey: ['B', 'C'], rightKey: ['B', 'C'],
}, },
{
type: 2,
title: '测试标题测试标题测试标题测试标题',
answerList: [
{
sort: 'A',
text: '是',
},
{
sort: 'B',
text: '否',
},
],
answer: 'B',
explain:
'测试内容测试内容测试内容测试内容测试内容测试内容',
index: 3,
rightKey: ['B'],
},
] ]
this.requestQuestionInfo(lists) this.requestQuestionInfo(lists)
...@@ -168,15 +187,14 @@ export default { ...@@ -168,15 +187,14 @@ export default {
requestQuestionInfo(lists) { requestQuestionInfo(lists) {
// 初始化setData后,需要调用swiper组件的init方法 // 初始化setData后,需要调用swiper组件的init方法
this.list = lists this.list = lists
setTimeout(() => { this.$nextTick(() => {
// 比如上次答到了第20题 // 比如上次答到了第20题
this.$refs.swiper.init(0) this.$refs.swiper.init(0)
// 初始化后再把动画弄出来,否则初始的current不是0,界面会自动跳动到当前位置,体验不太好 // 初始化后再把动画弄出来,否则初始的current不是0,界面会自动跳动到当前位置,体验不太好
this.swiperDuration = '250' this.swiperDuration = '250'
// 全局记一下list, 答题卡页暂时就直接用了 // 全局记一下list, 答题卡页暂时就直接用了
app.globalData.questionList = lists app.globalData.questionList = lists
}, 1000) })
}, },
swiperChange(e) { swiperChange(e) {
let current = e.current let current = e.current
...@@ -206,8 +224,8 @@ export default { ...@@ -206,8 +224,8 @@ export default {
}, },
// 作答完毕 // 作答完毕
answerChange(status, lists, index) { answerChange(status, lists, index) {
this.$set(this.list[index], 'answerList', lists) this.$set(this.list[this.currentIndex], 'answerList', lists)
this.$set(this.list[index], 'errShow', status === 'fail') this.$set(this.list[this.currentIndex], 'errShow', status === 'fail')
app.globalData.questionList = this.list app.globalData.questionList = this.list
console.log("this.list", app.globalData.questionList) console.log("this.list", app.globalData.questionList)
}, },
......
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