|
|
|
@ -12,212 +12,205 @@ const question = defineStore({ |
|
|
|
|
id: 'question', |
|
|
|
|
state: () => ({ |
|
|
|
|
currentCartype: storage.get('carType') || '1001', |
|
|
|
|
orderQuestion_subject1:storage.get('question_subject1') || [], //科目一顺序做题
|
|
|
|
|
orderQuestion_subject4:storage.get('question_subject4') ||[],//科目四顺序做题
|
|
|
|
|
currentIndex_subject1:0,//科目一索引 顺序做题
|
|
|
|
|
currentIndex_subject4:0,//科目四索引 顺序做题
|
|
|
|
|
curSubject:storage.get('curSubject') || '1', |
|
|
|
|
loading_subject1:false, |
|
|
|
|
loading_subject4:false, |
|
|
|
|
version:storage.get('version') || '' |
|
|
|
|
orderQuestion_subject1: storage.get('question_subject1') || [], //科目一顺序做题
|
|
|
|
|
orderQuestion_subject4: storage.get('question_subject4') || [], //科目四顺序做题
|
|
|
|
|
currentIndex_subject1: 0, //科目一索引 顺序做题
|
|
|
|
|
currentIndex_subject4: 0, //科目四索引 顺序做题
|
|
|
|
|
curSubject: storage.get('curSubject') || '1', |
|
|
|
|
loading_subject1: false, |
|
|
|
|
loading_subject4: false, |
|
|
|
|
version: storage.get('version') || '' |
|
|
|
|
}), |
|
|
|
|
|
|
|
|
|
actions: { |
|
|
|
|
getAllQuestion(){ |
|
|
|
|
getVersion(this.currentCartype).then(resp=>{ |
|
|
|
|
if(resp.code==='0000'){ |
|
|
|
|
if(this.version!=resp.data){ |
|
|
|
|
this.version=resp.data |
|
|
|
|
storage.set('version',resp.data) |
|
|
|
|
this.getOrderQuestion_sub1(true) |
|
|
|
|
this.getOrderQuestion_sub4(true) |
|
|
|
|
}else{ |
|
|
|
|
this.getOrderQuestion_sub1() |
|
|
|
|
this.getOrderQuestion_sub4() |
|
|
|
|
getAllQuestion() { |
|
|
|
|
getVersion(this.currentCartype).then(resp => { |
|
|
|
|
if (resp.code === '0000') { |
|
|
|
|
if (this.version != resp.data) { |
|
|
|
|
this.version = resp.data |
|
|
|
|
storage.set('version', resp.data) |
|
|
|
|
this.getOrderQuestion_sub1(true) |
|
|
|
|
this.getOrderQuestion_sub4(true) |
|
|
|
|
} else { |
|
|
|
|
this.getOrderQuestion_sub1() |
|
|
|
|
this.getOrderQuestion_sub4() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
divideArray(array, numChunks) { |
|
|
|
|
var chunkSize = Math.ceil(array.length / numChunks); |
|
|
|
|
var dividedArray = []; |
|
|
|
|
for (var i = 0; i < array.length; i += chunkSize) { |
|
|
|
|
dividedArray.push(array.slice(i, i + chunkSize)); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
divideArray(array, numChunks) { |
|
|
|
|
var chunkSize = Math.ceil(array.length / numChunks); |
|
|
|
|
var dividedArray = []; |
|
|
|
|
for (var i = 0; i < array.length; i += chunkSize) { |
|
|
|
|
dividedArray.push(array.slice(i, i + chunkSize)); |
|
|
|
|
} |
|
|
|
|
return dividedArray; |
|
|
|
|
return dividedArray; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//改变当前科目
|
|
|
|
|
changeSubject(val){ |
|
|
|
|
this.curSubject=val |
|
|
|
|
storage.set('curSubject',val) |
|
|
|
|
changeSubject(val) { |
|
|
|
|
this.curSubject = val |
|
|
|
|
storage.set('curSubject', val) |
|
|
|
|
}, |
|
|
|
|
// 获取顺序做题科目1
|
|
|
|
|
getOrderQuestion_sub1(isUpdate) { |
|
|
|
|
if(isUpdate){ |
|
|
|
|
this.loading_subject1=true |
|
|
|
|
queryQuestion({ |
|
|
|
|
carTypeId: this.currentCartype, |
|
|
|
|
subject: '1', |
|
|
|
|
// questionIdList:[10982,10983,10985,10986]
|
|
|
|
|
}).then(res => { |
|
|
|
|
if (res.code == '0000') { |
|
|
|
|
this.loading_subject1=false |
|
|
|
|
uni.showToast({ |
|
|
|
|
title:'题库加载完成!' |
|
|
|
|
}) |
|
|
|
|
this.orderQuestion_subject1 = res.data |
|
|
|
|
const diveList=this.divideArray(this.orderQuestion_subject1,5) |
|
|
|
|
if (isUpdate) { |
|
|
|
|
this.loading_subject1 = true |
|
|
|
|
const that=this |
|
|
|
|
uni.request({ |
|
|
|
|
url: 'https://oss-bq.ahduima.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E9%A2%98%E5%BA%93/%E5%B0%8F%E8%BD%A6%E7%A7%91%E7%9B%AE%E4%B8%80%E9%A2%98%E5%BA%93.json', |
|
|
|
|
success(resp) { |
|
|
|
|
if (resp.data) { |
|
|
|
|
that.orderQuestion_subject1 = resp.data.data |
|
|
|
|
const diveList = that.divideArray(that.orderQuestion_subject1, 5) |
|
|
|
|
that.loading_subject1 = false |
|
|
|
|
uni.setStorageSync('questionOneSub1', diveList[0]) |
|
|
|
|
uni.setStorageSync('questionOneSub2', diveList[1]) |
|
|
|
|
uni.setStorageSync('questionOneSub3', diveList[2]) |
|
|
|
|
uni.setStorageSync('questionOneSub4', diveList[3]) |
|
|
|
|
uni.setStorageSync('questionOneSub5', diveList[4]) |
|
|
|
|
const falseList =storage.get('wrongList_subject1') || [] |
|
|
|
|
const trueList =storage.get('rightList_subject1')|| [] |
|
|
|
|
const falseArr=[] |
|
|
|
|
const rightArr=[] |
|
|
|
|
this.orderQuestion_subject1.forEach(item=>{ |
|
|
|
|
if(falseList.includes(item.questionId)){ |
|
|
|
|
const falseList = storage.get('wrongList_subject1') || [] |
|
|
|
|
const trueList = storage.get('rightList_subject1') || [] |
|
|
|
|
const falseArr = [] |
|
|
|
|
const rightArr = [] |
|
|
|
|
that.orderQuestion_subject1.forEach(item => { |
|
|
|
|
if (falseList.includes(item.questionId)) { |
|
|
|
|
falseArr.push(item.questionId) |
|
|
|
|
} |
|
|
|
|
if(trueList.includes(item.questionId)){ |
|
|
|
|
if (trueList.includes(item.questionId)) { |
|
|
|
|
rightArr.push(item.questionId) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
storage.set('wrongList_subject1',falseArr) |
|
|
|
|
storage.set('rightList_subject1',rightArr) |
|
|
|
|
storage.set('wrongList_subject1', falseArr) |
|
|
|
|
storage.set('rightList_subject1', rightArr) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}else{ |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
const list1 = uni.getStorageSync('questionOneSub1') || [] |
|
|
|
|
const list2 = uni.getStorageSync('questionOneSub2') || [] |
|
|
|
|
const list3 = uni.getStorageSync('questionOneSub3') || [] |
|
|
|
|
const list4 = uni.getStorageSync('questionOneSub4') || [] |
|
|
|
|
const list5 = uni.getStorageSync('questionOneSub5') || [] |
|
|
|
|
this.orderQuestion_subject1=[...list1,...list2,...list3,...list4,...list5] |
|
|
|
|
if(this.orderQuestion_subject1&&this.orderQuestion_subject1.length){ |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
this.loading_subject1=true |
|
|
|
|
queryQuestion({ |
|
|
|
|
carTypeId: this.currentCartype, |
|
|
|
|
subject: '1', |
|
|
|
|
// questionIdList:[10982,10983,10985,10986]
|
|
|
|
|
}).then(res => { |
|
|
|
|
if (res.code == '0000') { |
|
|
|
|
this.loading_subject1=false |
|
|
|
|
uni.showToast({ |
|
|
|
|
title:'题库加载完成!' |
|
|
|
|
}) |
|
|
|
|
this.orderQuestion_subject1 = res.data |
|
|
|
|
const diveList=this.divideArray(this.orderQuestion_subject1,5) |
|
|
|
|
this.orderQuestion_subject1 = [...list1, ...list2, ...list3, ...list4, ...list5] |
|
|
|
|
if (this.orderQuestion_subject1 && this.orderQuestion_subject1.length) { |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
this.loading_subject1 = true |
|
|
|
|
const that = this |
|
|
|
|
uni.request({ |
|
|
|
|
url: 'https://oss-bq.ahduima.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E9%A2%98%E5%BA%93/%E5%B0%8F%E8%BD%A6%E7%A7%91%E7%9B%AE%E4%B8%80%E9%A2%98%E5%BA%93.json', |
|
|
|
|
success(resp) { |
|
|
|
|
if (resp.data) { |
|
|
|
|
that.orderQuestion_subject1 = resp.data.data |
|
|
|
|
const diveList = that.divideArray(that.orderQuestion_subject1, 5) |
|
|
|
|
that.loading_subject1 = false |
|
|
|
|
uni.setStorageSync('questionOneSub1', diveList[0]) |
|
|
|
|
uni.setStorageSync('questionOneSub2', diveList[1]) |
|
|
|
|
uni.setStorageSync('questionOneSub3', diveList[2]) |
|
|
|
|
uni.setStorageSync('questionOneSub4', diveList[3]) |
|
|
|
|
uni.setStorageSync('questionOneSub5', diveList[4]) |
|
|
|
|
const falseList =storage.get('wrongList_subject1') || [] |
|
|
|
|
const trueList =storage.get('rightList_subject1')|| [] |
|
|
|
|
const falseArr=[] |
|
|
|
|
const rightArr=[] |
|
|
|
|
this.orderQuestion_subject1.forEach(item=>{ |
|
|
|
|
if(falseList.includes(item.questionId)){ |
|
|
|
|
const falseList = storage.get('wrongList_subject1') || [] |
|
|
|
|
const trueList = storage.get('rightList_subject1') || [] |
|
|
|
|
const falseArr = [] |
|
|
|
|
const rightArr = [] |
|
|
|
|
that.orderQuestion_subject1.forEach(item => { |
|
|
|
|
if (falseList.includes(item.questionId)) { |
|
|
|
|
falseArr.push(item.questionId) |
|
|
|
|
} |
|
|
|
|
if(trueList.includes(item.questionId)){ |
|
|
|
|
if (trueList.includes(item.questionId)) { |
|
|
|
|
rightArr.push(item.questionId) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
storage.set('wrongList_subject1',falseArr) |
|
|
|
|
storage.set('rightList_subject1',rightArr) |
|
|
|
|
storage.set('wrongList_subject1', falseArr) |
|
|
|
|
storage.set('rightList_subject1', rightArr) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 获取顺序做题科目4
|
|
|
|
|
getOrderQuestion_sub4(isUpdate) { |
|
|
|
|
if(isUpdate){ |
|
|
|
|
this.loading_subject4=true |
|
|
|
|
queryQuestion({ |
|
|
|
|
carTypeId: this.currentCartype, |
|
|
|
|
subject: '4', |
|
|
|
|
// questionIdList:[10982,10983,10985,10986]
|
|
|
|
|
}).then(res => { |
|
|
|
|
if (res.code == '0000') { |
|
|
|
|
this.loading_subject4=false |
|
|
|
|
this.orderQuestion_subject4 = res.data |
|
|
|
|
const diveList=this.divideArray(this.orderQuestion_subject4,5) |
|
|
|
|
if (isUpdate) { |
|
|
|
|
this.loading_subject4 = true |
|
|
|
|
const that = this |
|
|
|
|
uni.request({ |
|
|
|
|
url: 'https://oss-bq.ahduima.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E9%A2%98%E5%BA%93/%E5%B0%8F%E8%BD%A6%E7%A7%91%E7%9B%AE%E5%9B%9B%E9%A2%98%E5%BA%93.json', |
|
|
|
|
success(resp) { |
|
|
|
|
if (resp.data) { |
|
|
|
|
that.orderQuestion_subject4 = resp.data.data |
|
|
|
|
const diveList = that.divideArray(that.orderQuestion_subject4, 5) |
|
|
|
|
that.loading_subject4 = false |
|
|
|
|
uni.setStorageSync('questionFourSub1', diveList[0]) |
|
|
|
|
uni.setStorageSync('questionFourSub2', diveList[1]) |
|
|
|
|
uni.setStorageSync('questionFourSub3', diveList[2]) |
|
|
|
|
uni.setStorageSync('questionFourSub4', diveList[3]) |
|
|
|
|
uni.setStorageSync('questionFourSub5', diveList[4]) |
|
|
|
|
const falseList =storage.get('wrongList_subject4') || [] |
|
|
|
|
const trueList =storage.get('rightList_subject4')|| [] |
|
|
|
|
const falseArr=[] |
|
|
|
|
const rightArr=[] |
|
|
|
|
this.orderQuestion_subject4.forEach(item=>{ |
|
|
|
|
if(falseList.includes(item.questionId)){ |
|
|
|
|
const falseList = storage.get('wrongList_subject4') || [] |
|
|
|
|
const trueList = storage.get('rightList_subject4') || [] |
|
|
|
|
const falseArr = [] |
|
|
|
|
const rightArr = [] |
|
|
|
|
that.orderQuestion_subject4.forEach(item => { |
|
|
|
|
if (falseList.includes(item.questionId)) { |
|
|
|
|
falseArr.push(item.questionId) |
|
|
|
|
} |
|
|
|
|
if(trueList.includes(item.questionId)){ |
|
|
|
|
if (trueList.includes(item.questionId)) { |
|
|
|
|
rightArr.push(item.questionId) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
storage.set('wrongList_subject4',falseArr) |
|
|
|
|
storage.set('rightList_subject4',rightArr) |
|
|
|
|
storage.set('wrongList_subject4', falseArr) |
|
|
|
|
storage.set('rightList_subject4', rightArr) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}else{ |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
const list1 = uni.getStorageSync('questionFourSub1') || [] |
|
|
|
|
const list2 = uni.getStorageSync('questionFourSub2') || [] |
|
|
|
|
const list3 = uni.getStorageSync('questionFourSub3') || [] |
|
|
|
|
const list4 = uni.getStorageSync('questionFourSub4') || [] |
|
|
|
|
const list5 = uni.getStorageSync('questionFourSub5') || [] |
|
|
|
|
this.orderQuestion_subject4=[...list1,...list2,...list3,...list4,...list5] |
|
|
|
|
if(this.orderQuestion_subject4&&this.orderQuestion_subject4.length){ |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
this.loading_subject4=true |
|
|
|
|
queryQuestion({ |
|
|
|
|
carTypeId: this.currentCartype, |
|
|
|
|
subject: '4', |
|
|
|
|
// questionIdList:[10982,10983,10985,10986]
|
|
|
|
|
}).then(res => { |
|
|
|
|
if (res.code == '0000') { |
|
|
|
|
this.loading_subject4=false |
|
|
|
|
this.orderQuestion_subject4 = res.data |
|
|
|
|
const diveList=this.divideArray(this.orderQuestion_subject4,5) |
|
|
|
|
this.orderQuestion_subject4 = [...list1, ...list2, ...list3, ...list4, ...list5] |
|
|
|
|
if (this.orderQuestion_subject4 && this.orderQuestion_subject4.length) { |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
this.loading_subject4 = true |
|
|
|
|
const that = this |
|
|
|
|
uni.request({ |
|
|
|
|
url: 'https://oss-bq.ahduima.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E9%A2%98%E5%BA%93/%E5%B0%8F%E8%BD%A6%E7%A7%91%E7%9B%AE%E5%9B%9B%E9%A2%98%E5%BA%93.json', |
|
|
|
|
success(resp) { |
|
|
|
|
if (resp.data) { |
|
|
|
|
that.orderQuestion_subject4 = resp.data.data |
|
|
|
|
const diveList = that.divideArray(that.orderQuestion_subject4, 5) |
|
|
|
|
that.loading_subject4 = false |
|
|
|
|
uni.setStorageSync('questionFourSub1', diveList[0]) |
|
|
|
|
uni.setStorageSync('questionFourSub2', diveList[1]) |
|
|
|
|
uni.setStorageSync('questionFourSub3', diveList[2]) |
|
|
|
|
uni.setStorageSync('questionFourSub4', diveList[3]) |
|
|
|
|
uni.setStorageSync('questionFourSub5', diveList[4]) |
|
|
|
|
const falseList =storage.get('wrongList_subject4') || [] |
|
|
|
|
const trueList =storage.get('rightList_subject4')|| [] |
|
|
|
|
const falseArr=[] |
|
|
|
|
const rightArr=[] |
|
|
|
|
this.orderQuestion_subject4.forEach(item=>{ |
|
|
|
|
if(falseList.includes(item.questionId)){ |
|
|
|
|
const falseList = storage.get('wrongList_subject4') || [] |
|
|
|
|
const trueList = storage.get('rightList_subject4') || [] |
|
|
|
|
const falseArr = [] |
|
|
|
|
const rightArr = [] |
|
|
|
|
that.orderQuestion_subject4.forEach(item => { |
|
|
|
|
if (falseList.includes(item.questionId)) { |
|
|
|
|
falseArr.push(item.questionId) |
|
|
|
|
} |
|
|
|
|
if(trueList.includes(item.questionId)){ |
|
|
|
|
if (trueList.includes(item.questionId)) { |
|
|
|
|
rightArr.push(item.questionId) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
storage.set('wrongList_subject4',falseArr) |
|
|
|
|
storage.set('rightList_subject4',rightArr) |
|
|
|
|
storage.set('wrongList_subject4', falseArr) |
|
|
|
|
storage.set('rightList_subject4', rightArr) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
//获取索引
|
|
|
|
|
getCurrentIndex(index,val){ |
|
|
|
|
this[`currentIndex_subject${val}`]=index |
|
|
|
|
console.log(`currentIndex_subject${val}`,this[`currentIndex_subject${val}`]); |
|
|
|
|
getCurrentIndex(index, val) { |
|
|
|
|
this[`currentIndex_subject${val}`] = index |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|