main.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. * 获取优惠信息
  24. */
  25. getPromote() {
  26. return this.apiGet('/base/promote');
  27. }
  28. /**
  29. * 获取对应位置的提示tips
  30. * @param {*} position
  31. */
  32. getTips(position) {
  33. return this.apiGet('/base/tips', { position });
  34. }
  35. /**
  36. * 获取长难句信息
  37. */
  38. getSentence() {
  39. return this.apiGet('/base/sentence');
  40. }
  41. /**
  42. * 获取心经信息
  43. */
  44. getExperience() {
  45. return this.apiGet('/base/experience');
  46. }
  47. /**
  48. * 获取考分排行信息
  49. */
  50. getScore(total, quant) {
  51. return this.apiGet('/base/score', { total, quant });
  52. }
  53. courseStruct() {
  54. return this.getExercise().then((result) => {
  55. return result.filter(row => row.isCourse);
  56. });
  57. }
  58. dataStruct() {
  59. return this.getExercise().then((result) => {
  60. return result.filter(row => row.isData);
  61. });
  62. }
  63. /**
  64. * 单个科目下的范围
  65. */
  66. rangeExercise() {
  67. return this.apiGet('/base/exercise/range');
  68. }
  69. /**
  70. * 所有练习头2层
  71. */
  72. getExercise() {
  73. return this.getApiCache('API:main:getExercise', () => {
  74. return this.apiGet('/base/exercise/main');
  75. }, 3600);
  76. }
  77. /**
  78. * 获取对应节点下的子节点
  79. * @param {*} id
  80. * @param {*} children
  81. */
  82. getExerciseChildren(id, children) {
  83. return this.apiGet('/base/exercise/children', { id, children });
  84. }
  85. /**
  86. * 获取对应节点的所有父级节点
  87. * @param {*} id
  88. */
  89. getExerciseParent(id) {
  90. return this.apiGet('/base/exercise/parent', { id });
  91. }
  92. getExerciseAll() {
  93. return this.apiGet('/base/exercise/all');
  94. }
  95. /**
  96. * 所有模考层级
  97. */
  98. getExamination() {
  99. return this.getApiCache('API:main:getExamination', () => {
  100. return this.apiGet('/base/examination/main');
  101. }, 3600);
  102. }
  103. /**
  104. * 获取对应节点下的子节点
  105. * @param {*} id
  106. * @param {*} children
  107. */
  108. getExaminationChildren(id, children) {
  109. return this.apiGet('/base/examination/children', { id, children });
  110. }
  111. /**
  112. * 获取对应节点的所有父级节点
  113. * @param {*} id
  114. */
  115. getExaminationParent(id) {
  116. return this.apiGet('/base/examination/parent', { id });
  117. }
  118. /**
  119. * 获取模考题目数
  120. */
  121. getExaminationNumber() {
  122. return this.getApiCache('API:main:getExaminationNumber', () => {
  123. return this.apiGet('/base/examination/number');
  124. }, 3600);
  125. }
  126. /**
  127. * 获取服务信息
  128. * @param {*} service
  129. */
  130. getService(service) {
  131. return this.apiGet('/base/service', { service });
  132. }
  133. getContract(key) {
  134. return this.apiGet('/base/contract', { key });
  135. }
  136. listFaq({ page, size, channel, position }) {
  137. return this.apiGet('/base/faq/list', { page, size, channel, position });
  138. }
  139. listComment({ page, size, channel, position }) {
  140. return this.apiGet('/base/comment/list', { page, size, channel, position });
  141. }
  142. readyInfo() {
  143. return this.apiGet('/base/ready_info');
  144. }
  145. listRead({ page, size, plate }) {
  146. return this.apiGet('/base/read/list', { page, size, plate });
  147. }
  148. listRoom({ page, size, keyword, areaId }) {
  149. return this.apiGet('/base/room/list', { page, size, keyword, areaId });
  150. }
  151. allData(isOfficial) {
  152. return this.apiGet('/base/data/all', { isOfficial });
  153. }
  154. }
  155. export const Main = new MainStore({ key: 'main' });