qsh 5 days ago
parent 62896b197d
commit 70fe0f0c42
  1. 12
      src/jtools/store/question.js

@ -9,8 +9,8 @@ const question = defineStore({
state: () => ({
currentCartype: storage.get('carType') || '1001',
currentCarName: storage.get('carName') || '小车C1/C2/C3',
orderQuestion_subject1: storage.get('question_subject1') || [], //科目一顺序做题
orderQuestion_subject4: storage.get('question_subject4') || [], //科目四顺序做题
orderQuestion_subject1: [], //科目一顺序做题
orderQuestion_subject4: [], //科目四顺序做题
currentIndex_subject1: 0, //科目一索引 顺序做题
currentIndex_subject4: 0, //科目四索引 顺序做题
curSubject: storage.get('curSubject') || '1',
@ -77,8 +77,7 @@ const question = defineStore({
const arr = uni.getStorageSync(`question1Sub${i + 1}`) || [];
this.orderQuestion_subject1 = [...this.orderQuestion_subject1, ...arr];
}
if (this.orderQuestion_subject1 && this.orderQuestion_subject1.length) {
} else {
if (this.orderQuestion_subject1.length == 0) {
this.loading_subject1 = true;
this.loadAllQuestion(url, 1);
}
@ -95,8 +94,7 @@ const question = defineStore({
const arr = uni.getStorageSync(`question4Sub${i + 1}`) || [];
this.orderQuestion_subject4 = [...this.orderQuestion_subject4, ...arr];
}
if (this.orderQuestion_subject4 && this.orderQuestion_subject4.length) {
} else {
if (this.orderQuestion_subject4.length == 0) {
this.loading_subject4 = true;
this.loadAllQuestion(url, 4);
}
@ -114,7 +112,7 @@ const question = defineStore({
storage.remove(`question${course}Sub${i + 1}`);
}
that[`orderQuestion_subject${course}`] = resp.data?.data || [];
const diveList = that.divideArray(that.orderQuestion_subject4, JSON_SPLIT_LENGTH);
const diveList = that.divideArray(that[`orderQuestion_subject${course}`], JSON_SPLIT_LENGTH);
that[`loading_subject${course}`] = false;
for (let i = 0; i < JSON_SPLIT_LENGTH; i++) {
uni.setStorageSync(`question${course}Sub${i + 1}`, diveList[i]);

Loading…
Cancel
Save