Commit a37cb701 authored by Damon's avatar Damon

refactor: 分离不同题库的数据

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