main.js 3.7 KB

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