classPanel.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import Api from "../../model/api";
  2. import {formatYMD, getDataSet} from "../../utils/utils";
  3. import {classStatus, logicStatus} from "../../model/enum";
  4. import Route from "../../model/route";
  5. const app = getApp();
  6. app.Base({
  7. type: classStatus.NO_START,
  8. dict: {
  9. [classStatus.NO_START]: {title: '即将开班', tagTxt: '未开始', tagBg: 'tag-bg1', method: Api.getClassList},
  10. [classStatus.RUNNING]: {title: '正在开班', tagTxt: '进行中', tagBg: 'tag-bg0', method: Api.getClassList},
  11. [classStatus.HISTORY]: {title: '历史开班', tagTxt: '已结束', tagBg: 'tag-bg2', method: Api.getClassList},
  12. [classStatus.MY_HISTORY]: {title: '往期培训', tagTxt: '已结束', tagBg: 'tag-bg2', method: Api.getMyHistoryClass},
  13. },
  14. data: {
  15. title: "",
  16. tagTxt: '',
  17. tagBg: '',
  18. },
  19. async onLoad(options) {
  20. this.type = options.type;
  21. const title = this.dict[this.type].title;
  22. wx.setNavigationBarTitle({title})
  23. this.setData({
  24. tagTxt: this.dict[this.type].tagTxt,
  25. tagBg: this.dict[this.type].tagBg,
  26. })
  27. },
  28. toDetail(e) {
  29. if (this.type == classStatus.MY_HISTORY) {
  30. const item = getDataSet(e, "item");
  31. Route.toEduDetail(item.id, logicStatus.YES)
  32. }
  33. },
  34. async requestData() {
  35. let res;
  36. if (this.type == classStatus.MY_HISTORY) {
  37. res = await this.dict[this.type].method(2, {
  38. pageNum: this.pageNum,
  39. pageSize: this.pageSize
  40. });
  41. } else {
  42. res = await this.dict[this.type].method({
  43. teamState: this.type,
  44. pageNum: this.pageNum,
  45. pageSize: this.pageSize
  46. });
  47. }
  48. res.data.rows.forEach(item => {
  49. item.teamStart = formatYMD(item.teamStart);
  50. item.teamEnd = formatYMD(item.teamEnd);
  51. })
  52. return res;
  53. },
  54. })