main.js 968 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import BaseStore from '@src/stores/base';
  2. export default class MainStore extends BaseStore {
  3. /**
  4. * 获取首页配置
  5. */
  6. getIndex() {
  7. return this.apiGet('/base/index');
  8. }
  9. /**
  10. * 获取广告列表
  11. */
  12. getAd() {
  13. return this.apiGet('/base/ad');
  14. }
  15. /**
  16. * 获取考分排行信息
  17. */
  18. getScore(total, quant) {
  19. return this.apiGet('/base/score', { total, quant });
  20. }
  21. /**
  22. * 所有练习层级
  23. */
  24. getExercise() {
  25. return this.getApiCache('API:main:getExercise', () => {
  26. return this.apiGet('/base/exercise/struct');
  27. });
  28. }
  29. getExerciseSingle(id) {
  30. return this.getExercise().then(result => {
  31. for (let i = 0; i < result.length; i += 1) {
  32. if (result[i].id === id) return result[i];
  33. }
  34. return {};
  35. });
  36. }
  37. /**
  38. * 所有模考层级
  39. */
  40. getExamination() {
  41. return this.apiGet('/base/examination/struct');
  42. }
  43. }
  44. export const Main = new MainStore({ key: 'main' });