main.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. import BaseStore from '@src/stores/base';
  2. export default class MainStore extends BaseStore {
  3. qrCode(url) {
  4. const qr = new window.QRious({
  5. value: url,
  6. size: 200,
  7. });
  8. return qr.toDataURL();
  9. }
  10. /**
  11. * 获取首页配置
  12. */
  13. getIndex() {
  14. return this.apiGet('/base/index');
  15. }
  16. /**
  17. * 获取广告列表
  18. */
  19. getAd(channel) {
  20. return this.apiGet('/base/ad', { channel });
  21. }
  22. /**
  23. * 获取对应位置的提示tips
  24. * @param {*} position
  25. */
  26. getTips(position) {
  27. return this.apiGet('/base/tips', { position });
  28. }
  29. /**
  30. * 获取长难句信息
  31. */
  32. getSentence() {
  33. return this.apiGet('/base/sentence');
  34. }
  35. /**
  36. * 获取心经信息
  37. */
  38. getExperience() {
  39. return this.apiGet('/base/experience');
  40. }
  41. /**
  42. * 获取考分排行信息
  43. */
  44. getScore(total, quant) {
  45. return this.apiGet('/base/score', { total, quant });
  46. }
  47. courseStruct() {
  48. return this.getExercise().then((result) => {
  49. return result.filter(row => row.isCourse);
  50. });
  51. }
  52. dataStruct() {
  53. return this.getExercise().then((result) => {
  54. return result.filter(row => row.isData);
  55. });
  56. }
  57. /**
  58. * 单个科目下的范围
  59. */
  60. rangeExercise() {
  61. return this.apiGet('/base/exercise/range');
  62. }
  63. /**
  64. * 所有练习头2层
  65. */
  66. getExercise() {
  67. return this.getApiCache('API:main:getExercise', () => {
  68. return this.apiGet('/base/exercise/main');
  69. }, 3600);
  70. }
  71. /**
  72. * 获取对应节点下的子节点
  73. * @param {*} id
  74. * @param {*} children
  75. */
  76. getExerciseChildren(id, children) {
  77. return this.apiGet('/base/exercise/children', { id, children });
  78. }
  79. /**
  80. * 获取对应节点的所有父级节点
  81. * @param {*} id
  82. */
  83. getExerciseParent(id) {
  84. return this.apiGet('/base/exercise/parent', { id });
  85. }
  86. getExerciseAll() {
  87. return this.apiGet('/base/exercise/all');
  88. }
  89. /**
  90. * 所有模考层级
  91. */
  92. getExamination() {
  93. return this.getApiCache('API:main:getExamination', () => {
  94. return this.apiGet('/base/examination/main');
  95. }, 3600);
  96. }
  97. /**
  98. * 获取对应节点下的子节点
  99. * @param {*} id
  100. * @param {*} children
  101. */
  102. getExaminationChildren(id, children) {
  103. return this.apiGet('/base/examination/children', { id, children });
  104. }
  105. /**
  106. * 获取对应节点的所有父级节点
  107. * @param {*} id
  108. */
  109. getExaminationParent(id) {
  110. return this.apiGet('/base/examination/parent', { id });
  111. }
  112. /**
  113. * 获取模考题目数
  114. */
  115. getExaminationNumber() {
  116. return this.getApiCache('API:main:getExaminationNumber', () => {
  117. return this.apiGet('/base/examination/number');
  118. }, 3600);
  119. }
  120. /**
  121. * 获取服务信息
  122. * @param {*} service
  123. */
  124. getService(service) {
  125. return this.apiGet('/base/service', { service });
  126. }
  127. getContract(key) {
  128. return this.apiGet('/base/contract', { key });
  129. }
  130. listFaq({ page, size, channel, position }) {
  131. return this.apiGet('/base/faq/list', { page, size, channel, position });
  132. }
  133. listComment({ page, size, channel, position }) {
  134. return this.apiGet('/base/comment/list', { page, size, channel, position });
  135. }
  136. readyInfo() {
  137. return this.apiGet('/base/ready_info');
  138. }
  139. listRead({ page, size, plate }) {
  140. return this.apiGet('/base/read/list', { page, size, plate });
  141. }
  142. listRoom({ page, size, keyword, areaId }) {
  143. return this.apiGet('/base/room/list', { page, size, keyword, areaId });
  144. }
  145. allData(isOfficial) {
  146. return this.apiGet('/base/data/all', { isOfficial });
  147. }
  148. }
  149. export const Main = new MainStore({ key: 'main' });