Commit a37cb701 authored by Damon's avatar Damon

refactor: 分离不同题库的数据

parent 658356a1
......@@ -244,10 +244,10 @@ export default {
}
if(this.source === 1){ // 顺序答题,如果答满则清空数据
const check = this.questionList.every(v => v.submitStatus)
const check = this.questionList[this.questionWarehouseId] ? this.questionList[this.questionWarehouseId].every(v => v.submitStatus) : false
if (check) {
this.$u.vuex('lastIndex', 0)
this.$u.vuex('questionList', [])
this.$u.vuex(`lastIndex.${this.questionWarehouseId}`, 0)
this.$u.vuex(`questionList.${this.questionWarehouseId}`, [])
}
}
......@@ -282,7 +282,7 @@ export default {
this.cachePageDataMap = new Map()
// 上次答到了第几题
let index = this.source === 1 ? (this.lastIndex || 0) : 0
let index = this.source === 1 ? (this.lastIndex[this.questionWarehouseId] || 0) : 0
this.refresh(index)
})
},
......@@ -403,12 +403,12 @@ export default {
// 顺序练习,更新答题卡
if (this.source === 1){
this.questionList[this.currentIndex] = item
this.$u.vuex('questionList', this.questionList)
this.$u.vuex('lastIndex', this.currentIndex)
this.questionList[this.questionWarehouseId][this.currentIndex] = item
this.$u.vuex(`questionList.${this.questionWarehouseId}`, this.questionList[this.questionWarehouseId])
this.$u.vuex(`lastIndex.${this.questionWarehouseId}`, this.currentIndex)
// 统计是否达满所有试题
const count = this.questionList.reduce((accumulator, currentValue) => {
const count = this.questionList[this.questionWarehouseId].reduce((accumulator, currentValue) => {
if (currentValue.submitStatus) accumulator++
return accumulator
}, 0)
......@@ -515,8 +515,8 @@ export default {
if(res) {
info.collectionFlag = !status
if (this.source === 1) { //更新缓存数据
this.questionList[this.currentIndex] = info
this.$u.vuex('questionList', this.questionList)
this.questionList[this.questionWarehouseId][this.currentIndex] = info
this.$u.vuex(`questionList.${this.questionWarehouseId}`, this.questionList[this.questionWarehouseId])
}
}
})
......
......@@ -152,7 +152,7 @@ function request({ currentPage, size, onSuccess, onFailed }, vm) {
}
// 回显已答题目
if (vm.source === 1) { // 练习模式回显
const ansItem = vm.questionList.find(v => v.index === item.index)
const ansItem = vm.questionList[vm.questionWarehouseId].find(v => v.index === item.index)
questionList.push(ansItem ? ansItem : item)
} else {
questionList.push(item)
......@@ -216,12 +216,12 @@ const getInitPageList = function(currentIndex, size, currentPage, total) {
}
function initAnswerCardList(total, vm) {
if (!vm.questionList || vm.questionList.length === 0) {
if (!vm.questionList[vm.questionWarehouseId] || vm.questionList[vm.questionWarehouseId].length === 0) {
let list = []
for (let i = 0; i < total; i++) {
list.push({})
}
vm.$u.vuex('questionList', list)
vm.$u.vuex(`questionList.${vm.questionWarehouseId}`, list)
}
}
......
......@@ -43,8 +43,8 @@ const store = new Vuex.Store({
vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '',
openId: lifeData.openId ? lifeData.openId : '',
searchHistory: lifeData.searchHistory ? lifeData.searchHistory : [], // 搜索历史记录
questionList: lifeData.questionList ? lifeData.questionList : [], // 练习列表
lastIndex: lifeData.lastIndex ? lifeData.lastIndex : 0, // 上次做到第几题
questionList: lifeData.questionList ? lifeData.questionList : {}, // 练习列表
lastIndex: lifeData.lastIndex ? lifeData.lastIndex : {}, // 上次做到第几题
tipStatus: lifeData.tipStatus ? lifeData.tipStatus : false, // 滑动提示
questionWarehouseId: lifeData.questionWarehouseId
? lifeData.questionWarehouseId
......
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