You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
"use strict"; const common_vendor = require("../../common/vendor.js"); const store_modules_car = require("./car.js"); const config_api = require("../../config/api.js"); let carObj = store_modules_car.carStore(); const questionStore = common_vendor.defineStore( "wrong", { state: () => ({ wrongList: [], frequency: common_vendor.index.getStorageSync("frequency") ? common_vendor.index.getStorageSync("frequency") : 0 }), actions: { setFrequency(value) { common_vendor.index.setStorageSync("frequency", value); this.frequency = value; }, setList(value) { let obj = { num: 0, id: value }; let index = this.wrongList.findIndex((item) => item.id == value); if (index != -1) { this.wrongList.splice(index, 1); } this.wrongList.push(obj); }, // 查看在不在错题里
lookList(value) { let index = this.wrongList.findIndex((item) => item.id == value); if (index != -1) { let item = this.wrongList[index]; console.log("找到之前的错题了"); item.num = item.num + 1; if (this.frequency && item.num >= this.frequency) { this.deleteWrongOrColFn(value); this.wrongList.splice(index, 1); } } }, async deleteWrongOrColFn(value) { let index = this.wrongList.findIndex((item) => item.id == value); if (index != -1) this.wrongList.splice(index, 1); let obj = { "carType": carObj.carInfo.carType, "questionId": value, "stepType": carObj.carInfo.stepType, "type": 1 }; await config_api.deleteWrongOrCol(obj); } } } ); exports.questionStore = questionStore;
|