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.

54 lines
1.7 KiB

1 week ago
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const store_modules_car = require("./car.js");
  4. const config_api = require("../../config/api.js");
  5. let carObj = store_modules_car.carStore();
  6. const questionStore = common_vendor.defineStore(
  7. "wrong",
  8. {
  9. state: () => ({
  10. wrongList: [],
  11. frequency: common_vendor.index.getStorageSync("frequency") ? common_vendor.index.getStorageSync("frequency") : 0
  12. }),
  13. actions: {
  14. setFrequency(value) {
  15. common_vendor.index.setStorageSync("frequency", value);
  16. this.frequency = value;
  17. },
  18. setList(value) {
  19. let obj = { num: 0, id: value };
  20. let index = this.wrongList.findIndex((item) => item.id == value);
  21. if (index != -1) {
  22. this.wrongList.splice(index, 1);
  23. }
  24. this.wrongList.push(obj);
  25. },
  26. // 查看在不在错题里
  27. lookList(value) {
  28. let index = this.wrongList.findIndex((item) => item.id == value);
  29. if (index != -1) {
  30. let item = this.wrongList[index];
  31. console.log("找到之前的错题了");
  32. item.num = item.num + 1;
  33. if (this.frequency && item.num >= this.frequency) {
  34. this.deleteWrongOrColFn(value);
  35. this.wrongList.splice(index, 1);
  36. }
  37. }
  38. },
  39. async deleteWrongOrColFn(value) {
  40. let index = this.wrongList.findIndex((item) => item.id == value);
  41. if (index != -1)
  42. this.wrongList.splice(index, 1);
  43. let obj = {
  44. "carType": carObj.carInfo.carType,
  45. "questionId": value,
  46. "stepType": carObj.carInfo.stepType,
  47. "type": 1
  48. };
  49. await config_api.deleteWrongOrCol(obj);
  50. }
  51. }
  52. }
  53. );
  54. exports.questionStore = questionStore;