main.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. getBase() {
  23. return this.apiGet('/base/base');
  24. }
  25. /**
  26. * 获取广告列表
  27. */
  28. getAd(channel) {
  29. return this.apiGet('/base/ad', { channel });
  30. }
  31. /**
  32. * 获取优惠信息
  33. */
  34. getPromote() {
  35. return this.apiGet('/base/promote');
  36. }
  37. /**
  38. * 获取微信信息
  39. */
  40. getWechat() {
  41. return this.apiGet('/base/wechat');
  42. }
  43. /**
  44. * 获取对应位置的提示tips
  45. * @param {*} position
  46. */
  47. getTips(position) {
  48. return this.apiGet('/base/tips', { position });
  49. }
  50. /**
  51. * 获取考分排行信息
  52. */
  53. getScore(total, quant) {
  54. return this.apiGet('/base/score', { total, quant });
  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. /**
  111. * 获取服务信息
  112. * @param {*} service
  113. */
  114. getService(service) {
  115. return this.apiGet('/base/service', { service });
  116. }
  117. getContract(key) {
  118. return this.apiGet('/base/contract', { key });
  119. }
  120. listFaq(page, size, channel, position) {
  121. return this.apiGet('/base/faq/list', { page, size, channel, position });
  122. }
  123. listComment(page, size, channel, position) {
  124. return this.apiGet('/base/comment/list', { page, size, channel, position });
  125. }
  126. readyInfo() {
  127. return this.apiGet('/base/ready_info');
  128. }
  129. listRead(page, size, plate) {
  130. return this.apiGet('/base/read/list', { page, size, plate });
  131. }
  132. }
  133. export const Main = new MainStore({ key: 'main' });