Commit 83f5fcb8 authored by Damon's avatar Damon

feat: 切换模式

parent c407dd89
...@@ -110,12 +110,12 @@ export default { ...@@ -110,12 +110,12 @@ export default {
immediate: true immediate: true
}, },
model(newVal, oldVal){ model(newVal, oldVal){
if (newVal === 2) this.autoAnswer() this.changeModel(newVal)
} }
}, },
methods: { methods: {
init (defaulaIndex) { init (defaulaIndex) {
let list = this.list let list = JSON.parse(JSON.stringify(this.list))
if (list == null || list.length == 0) { if (list == null || list.length == 0) {
return return
} }
...@@ -181,21 +181,29 @@ export default { ...@@ -181,21 +181,29 @@ export default {
// 记录滑过来的位置,此值对于下一次滑动的计算很重要 // 记录滑过来的位置,此值对于下一次滑动的计算很重要
this.swiperIndex = current this.swiperIndex = current
if (this.model === 2) { if (this.model === 2) {
this.autoAnswer() this.changeModel()
} }
}, },
autoAnswer() { // 切换模式
this.$set(this.swiperList[this.swiperIndex], 'errShow', true) changeModel(model) {
this.$set(this.swiperList[this.swiperIndex], 'submitStatus', true) let info = JSON.parse(JSON.stringify(this.swiperList[this.swiperIndex]))
const info = this.swiperList[this.swiperIndex] if (model === 1) {
const lists = info.answerList.map(v => { const item = this.list.find(v => v.index === info.index)
if (info.rightKey.includes(v.sort)) { this.$set(this.swiperList, this.swiperIndex, item)
v.checked = true } else {
v.confirm = true // 学习模式,显示答案
} info.errShow = true
return v info.answerList.forEach(v => {
}) if (info.rightKey.includes(v.sort)) {
this.$emit("answerChange", 'pass', lists) v.checked = true
v.confirm = true
} else {
v.checked = false
v.confirm = false
}
})
this.$set(this.swiperList, this.swiperIndex, info)
}
}, },
/** /**
* 获取初始化的swiperList * 获取初始化的swiperList
......
...@@ -225,6 +225,7 @@ export default { ...@@ -225,6 +225,7 @@ export default {
this.init() this.init()
}, },
methods: { methods: {
// 初始化数据
init() { init() {
const params = { const params = {
questionWarehouseId: this.questionWarehouseId, questionWarehouseId: this.questionWarehouseId,
...@@ -251,6 +252,7 @@ export default { ...@@ -251,6 +252,7 @@ export default {
this.refresh(index) this.refresh(index)
}) })
}, },
// 切换
swiperChange(e) { swiperChange(e) {
let current = e.current let current = e.current
this.currentIndex = current this.currentIndex = current
......
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