main.js 3.0 KB

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