main.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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(channel) {
  23. return this.apiGet('/base/ad', { channel });
  24. }
  25. /**
  26. * 获取微信信息
  27. */
  28. getWechat() {
  29. return this.apiGet('/base/wechat');
  30. }
  31. /**
  32. * 获取对应位置的提示tips
  33. * @param {*} position
  34. */
  35. getTips(position) {
  36. return this.apiGet('/base/tips', { position });
  37. }
  38. /**
  39. * 获取考分排行信息
  40. */
  41. getScore(total, quant) {
  42. return this.apiGet('/base/score', { total, quant });
  43. }
  44. /**
  45. * 所有练习头2层
  46. */
  47. getExercise() {
  48. return this.getApiCache('API:main:getExercise', () => {
  49. return this.apiGet('/base/exercise/main');
  50. }, 3600);
  51. }
  52. /**
  53. * 获取对应节点下的子节点
  54. * @param {*} id
  55. * @param {*} children
  56. */
  57. getExerciseChildren(id, children) {
  58. return this.apiGet('/base/exercise/children', { id, children });
  59. }
  60. /**
  61. * 获取对应节点的所有父级节点
  62. * @param {*} id
  63. */
  64. getExerciseParent(id) {
  65. return this.apiGet('/base/exercise/parent', { id });
  66. }
  67. /**
  68. * 所有模考层级
  69. */
  70. getExamination() {
  71. return this.getApiCache('API:main:getExamination', () => {
  72. return this.apiGet('/base/examination/main');
  73. }, 3600);
  74. }
  75. /**
  76. * 获取对应节点下的子节点
  77. * @param {*} id
  78. * @param {*} children
  79. */
  80. getExaminationChildren(id, children) {
  81. return this.apiGet('/base/examination/children', { id, children });
  82. }
  83. /**
  84. * 获取对应节点的所有父级节点
  85. * @param {*} id
  86. */
  87. getExaminationParent(id) {
  88. return this.apiGet('/base/examination/parent', { id });
  89. }
  90. /**
  91. * 获取模考题目数
  92. */
  93. getExaminationNumber() {
  94. return this.getApiCache('API:main:getExaminationNumber', () => {
  95. return this.apiGet('/base/examination/number');
  96. }, 3600);
  97. }
  98. /**
  99. * 获取服务信息
  100. * @param {*} service
  101. */
  102. getService(service) {
  103. return this.apiGet('/base/service', { service });
  104. }
  105. getContract(key) {
  106. return this.apiGet('/base/contract', { key });
  107. }
  108. listFaq(page, size, channel, position) {
  109. return this.apiGet('/base/faq/list', { page, size, channel, position });
  110. }
  111. listComment(page, size, channel, position) {
  112. return this.apiGet('/base/comment/list', { page, size, channel, position });
  113. }
  114. readyInfo() {
  115. return this.apiGet('/base/ready_info');
  116. }
  117. listRead(page, size, plate) {
  118. return this.apiGet('/base/read/list', { page, size, plate });
  119. }
  120. }
  121. export const Main = new MainStore({ key: 'main' });