main.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. * 获取对应位置的提示tips
  17. * @param {*} position
  18. */
  19. getTips(position) {
  20. return this.apiGet('/base/tips', { position });
  21. }
  22. /**
  23. * 获取长难句信息
  24. */
  25. getSentence() {
  26. return this.apiGet('/base/sentence');
  27. }
  28. /**
  29. * 获取心经信息
  30. */
  31. getExperience() {
  32. return this.apiGet('/base/experience');
  33. }
  34. /**
  35. * 获取考分排行信息
  36. */
  37. getScore(total, quant) {
  38. return this.apiGet('/base/score', { total, quant });
  39. }
  40. courseStruct() {
  41. return this.getExercise().then((result) => {
  42. return result.filter(row => row.isCourse);
  43. });
  44. }
  45. dataStruct() {
  46. return this.getExercise().then((result) => {
  47. return result.filter(row => row.isData);
  48. });
  49. }
  50. /**
  51. * 单个科目下的范围
  52. */
  53. rangeExercise() {
  54. return this.apiGet('/base/exercise/range');
  55. }
  56. /**
  57. * 所有练习头2层
  58. */
  59. getExercise() {
  60. return this.getApiCache('API:main:getExercise', () => {
  61. return this.apiGet('/base/exercise/main');
  62. }, 3600);
  63. }
  64. /**
  65. * 获取对应节点下的子节点
  66. * @param {*} id
  67. * @param {*} children
  68. */
  69. getExerciseChildren(id, children) {
  70. return this.apiGet('/base/exercise/children', { id, children });
  71. }
  72. /**
  73. * 获取对应节点的所有父级节点
  74. * @param {*} id
  75. */
  76. getExerciseParent(id) {
  77. return this.apiGet('/base/exercise/parent', { id });
  78. }
  79. /**
  80. * 所有模考层级
  81. */
  82. getExamination() {
  83. return this.getApiCache('API:main:getExamination', () => {
  84. return this.apiGet('/base/examination/main');
  85. }, 3600);
  86. }
  87. /**
  88. * 获取对应节点下的子节点
  89. * @param {*} id
  90. * @param {*} children
  91. */
  92. getExaminationChildren(id, children) {
  93. return this.apiGet('/base/examination/children', { id, children });
  94. }
  95. /**
  96. * 获取对应节点的所有父级节点
  97. * @param {*} id
  98. */
  99. getExaminationParent(id) {
  100. return this.apiGet('/base/examination/parent', { id });
  101. }
  102. /**
  103. * 获取模考题目数
  104. */
  105. getExaminationNumber() {
  106. return this.getApiCache('API:main:getExaminationNumber', () => {
  107. return this.apiGet('/base/examination/number');
  108. }, 3600);
  109. }
  110. listFaq(page, size, channel, position) {
  111. return this.apiGet('/base/faq/list', { page, size, channel, position });
  112. }
  113. listComment(page, size, channel, position) {
  114. return this.apiGet('/base/comment/list', { page, size, channel, position });
  115. }
  116. listArticle(page, size, channel, position) {
  117. return this.apiGet('/base/article/list', { page, size, channel, position });
  118. }
  119. }
  120. export const Main = new MainStore({ key: 'main' });