eduDetail.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import {formatYMD, getEventParam, showLoading} from "../../utils/utils";
  2. import Api from "../../model/api";
  3. import {logicStatus} from "../../model/enum";
  4. const app = getApp();
  5. app.Base({
  6. data: {
  7. teamId: '',
  8. isPre: logicStatus.NO,
  9. topClass: 'top',
  10. active: 0,
  11. stuPageNum: 1,
  12. stuPageSize: 5,
  13. courseStart: '',
  14. item: {},
  15. stuData: [],
  16. courseList: [],
  17. },
  18. async selectDate(e) {
  19. let courseStart = getEventParam(e, "date");
  20. this.data.courseStart = courseStart;
  21. await this.getCourseDate(this.data.item.eduStuId, true);
  22. },
  23. async getCourseDate(studentId, isLoading = false) {
  24. const res3 = await Api.getCourseSchedule({
  25. teamId: this.data.teamId,
  26. studentId,
  27. courseStart: this.data.courseStart,
  28. }, isLoading);
  29. res3.rows.forEach(item => {
  30. if (item.isOnline == logicStatus.YES) {
  31. item.isQuestion = item.suitangUpper;
  32. } else {
  33. item.isQuestion = item.suitangLower;
  34. }
  35. })
  36. this.setData({
  37. courseList: res3.rows,
  38. })
  39. },
  40. onLoad: async function (options) {
  41. const teamId = options.teamId;
  42. this.data.teamId = teamId;
  43. const isPre = options.isPre || logicStatus.NO;
  44. this.data.isPre = isPre;
  45. if (isPre == logicStatus.YES) {
  46. wx.setNavigationBarTitle({title: "往期培训"})
  47. } else {
  48. wx.setNavigationBarTitle({title: "培训"})
  49. }
  50. await this.init(isPre);
  51. },
  52. async init(isPre) {
  53. showLoading();
  54. const [res1, res2] = await Api.promiseAllSettled([
  55. Api.getProjectsWithTeam(this.data.teamId),
  56. Api.getStudentList({
  57. teamId: this.data.teamId,
  58. pageNum: this.data.stuPageNum,
  59. pageSize: this.data.stuPageSize
  60. }),
  61. ])
  62. wx.hideLoading();
  63. res1.data.forEach(item => {
  64. item.itemStart = formatYMD(item.itemStart);
  65. item.itemEnd = formatYMD(item.itemEnd);
  66. })
  67. this.setData({
  68. teamId: this.data.teamId, isPre,
  69. item: res1.data[0],
  70. stuData: res2.data.rows,
  71. })
  72. await this.getCourseDate(res1.data[0].eduStuId);
  73. },
  74. async onPullDownRefresh() {
  75. await this.init(this.data.isPre);
  76. },
  77. onChange(e) {
  78. wx.createSelectorQuery().select('.container').boundingClientRect(function (rect) {
  79. wx.pageScrollTo({
  80. scrollTop: 0
  81. })
  82. }).exec()
  83. if ("介绍" == getEventParam(e, "title")) {
  84. this.setData({
  85. topClass: 'top',
  86. active: getEventParam(e, "index"),
  87. disableLoadMore: false,
  88. })
  89. } else {
  90. this.setData({
  91. topClass: 'top-bg',
  92. active: getEventParam(e, "index"),
  93. disableLoadMore: true
  94. })
  95. }
  96. },
  97. async requestData() {
  98. const res = await Api.getTeamInteraction({
  99. teamId: this.data.teamId,
  100. pageNum: this.pageNum,
  101. pageSize: this.pageSize
  102. });
  103. return res;
  104. },
  105. onHandlePublish(e) {
  106. const isSuccess = getEventParam(e, "isSuccess");
  107. if (isSuccess) {
  108. this.onPullDownRefresh();
  109. }
  110. },
  111. refreshData() {
  112. this.onPullDownRefresh();
  113. }
  114. });