main.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import BaseStore from '@src/stores/base';
  2. export default class MainStore extends BaseStore {
  3. courseStruct() {
  4. return this.getExercise().then((result) => {
  5. return result.filter(row => row.isCourse);
  6. });
  7. }
  8. dataStruct() {
  9. return this.getExercise().then((result) => {
  10. return result.filter(row => row.isData);
  11. });
  12. }
  13. /**
  14. * 获取首页配置
  15. */
  16. getIndex() {
  17. return this.apiGet('/base/index');
  18. }
  19. /**
  20. * 获取广告列表
  21. */
  22. getAd() {
  23. return this.apiGet('/base/ad');
  24. }
  25. /**
  26. * 获取对应位置的提示tips
  27. * @param {*} position
  28. */
  29. getTips(position) {
  30. return this.apiGet('/base/tips', { position });
  31. }
  32. /**
  33. * 获取考分排行信息
  34. */
  35. getScore(total, quant) {
  36. return this.apiGet('/base/score', { total, quant });
  37. }
  38. /**
  39. * 所有练习头2层
  40. */
  41. getExercise() {
  42. return this.getApiCache('API:main:getExercise', () => {
  43. return this.apiGet('/base/exercise/main');
  44. }, 3600);
  45. }
  46. /**
  47. * 获取对应节点下的子节点
  48. * @param {*} id
  49. * @param {*} children
  50. */
  51. getExerciseChildren(id, children) {
  52. return this.apiGet('/base/exercise/children', { id, children });
  53. }
  54. /**
  55. * 获取对应节点的所有父级节点
  56. * @param {*} id
  57. */
  58. getExerciseParent(id) {
  59. return this.apiGet('/base/exercise/parent', { id });
  60. }
  61. /**
  62. * 所有模考层级
  63. */
  64. getExamination() {
  65. return this.getApiCache('API:main:getExamination', () => {
  66. return this.apiGet('/base/examination/main');
  67. }, 3600);
  68. }
  69. /**
  70. * 获取对应节点下的子节点
  71. * @param {*} id
  72. * @param {*} children
  73. */
  74. getExaminationChildren(id, children) {
  75. return this.apiGet('/base/examination/children', { id, children });
  76. }
  77. /**
  78. * 获取对应节点的所有父级节点
  79. * @param {*} id
  80. */
  81. getExaminationParent(id) {
  82. return this.apiGet('/base/examination/parent', { id });
  83. }
  84. /**
  85. * 获取模考题目数
  86. */
  87. getExaminationNumber() {
  88. return this.getApiCache('API:main:getExaminationNumber', () => {
  89. return this.apiGet('/base/examination/number');
  90. }, 3600);
  91. }
  92. /**
  93. * 获取服务信息
  94. * @param {*} service
  95. */
  96. getService(service) {
  97. return this.apiGet('/base/service', { service });
  98. }
  99. }
  100. export const Main = new MainStore({ key: 'main' });