index.js 964 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // 该文件用于创建store实例
  2. import {
  3. action,
  4. observable
  5. } from 'mobx-miniprogram'
  6. export const store = observable({
  7. // 数据字段
  8. userInfo: {},
  9. // 阅读结果
  10. readDetail: {},
  11. //pk数据,包括被pk人的身份信息与录音得分
  12. pkData: {},
  13. // 计算属性
  14. get sum() {
  15. return this.numA + this.numB
  16. },
  17. // actions
  18. setUser: action(function (step) {
  19. let grade = step.grade
  20. var gradeObj = {
  21. "PRIMARY_FIRST_GRADE": "一年级",
  22. "PRIMARY_SECOND_GRADE": "二年级",
  23. "PRIMARY_THREE_GRADE": "三年级",
  24. "PRIMARY_SENIOR_GRADE": "四年级",
  25. "PRIMARY_FIVE_GRADE":"五年级",
  26. "PRIMARY_SIX_GRADE":"五年级",
  27. "PRESCHOOL": "学前班",
  28. }
  29. step.gradeName = grade ? gradeObj[grade] : '请选择'
  30. this.userInfo = step
  31. }, ),
  32. setReadDetail: action(function (detail) {
  33. this.readDetail = detail
  34. }),
  35. setPkData: action(function (data) {
  36. this.pkData = data
  37. })
  38. })