Commit 9bb7c049 authored by Damon's avatar Damon

refactor: 学习模式

parent 036e24b0
......@@ -4,10 +4,12 @@ let learnApiFun = function(vm) {
let getQuestion = async (params = {}) => await vm.$u.post('/rest/question/query/getQuestion', params)
let getQuestionTotal = async (params = {}) => await vm.$u.post('/rest/question/query/getQuestionTotal', params)
let answer = async (params = {}) => await vm.$u.post('/rest/question/save/answer', params)
const learnApi = {
getQuestion,
getQuestionTotal
getQuestionTotal,
answer
}
return learnApi
}
......
......@@ -109,6 +109,9 @@ export default {
},
immediate: true
},
model(newVal, oldVal){
if (newVal === 2) this.autoAnswer()
}
},
methods: {
init (defaulaIndex) {
......@@ -177,6 +180,22 @@ export default {
this.$emit("change", info)
// 记录滑过来的位置,此值对于下一次滑动的计算很重要
this.swiperIndex = current
if (this.model === 2) {
this.autoAnswer()
}
},
autoAnswer() {
this.$set(this.swiperList[this.swiperIndex], 'errShow', true)
this.$set(this.swiperList[this.swiperIndex], 'submitStatus', true)
const info = this.swiperList[this.swiperIndex]
const lists = info.answerList.map(v => {
if (info.rightKey.includes(v.sort)) {
v.checked = true
v.confirm = true
}
return v
})
this.$emit("answerChange", 'pass', lists)
},
/**
* 获取初始化的swiperList
......
......@@ -28,6 +28,7 @@
:timestamp="timestamp"
bg-color=""
:show-hours="false"
@end="timeEnd"
></u-count-down
></view>
</view>
......@@ -326,6 +327,9 @@ export default {
changeModel(i) {
this.model = i
},
timeEnd() {
},
// 作答完毕
answerChange(status, lists) {
......@@ -352,7 +356,7 @@ export default {
}
// 如果回答错误或者是考试模式,自动进入下一题
if (status === 'pass' || this.type === 2) {
if ((status === 'pass' && this.model !== 2)|| this.type === 2) {
if (this.currentIndex + 1 > this.total - 1) {
return
}
......
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