Commit 019222e8 authored by Damon's avatar Damon

refactor: 答题状态回显

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