main.js 3.9 KB

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