eduDetail.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import {formatTime, formatYMD, getEventParam, showLoading} from "../../utils/utils";
  2. import Api from "../../model/api";
  3. import {logicStatus, uploadResTypes} 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. let {teamId, isPre} = options;
  42. this.data.teamId = teamId;
  43. isPre = 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. item.teamStart = formatYMD(item.teamStart),
  67. item.teamEnd = formatYMD(item.teamEnd)
  68. })
  69. this.setData({
  70. teamId: this.data.teamId, isPre,
  71. item: res1.data[0],
  72. stuData: res2.data.rows,
  73. })
  74. await this.getCourseDate(res1.data[0].eduStuId);
  75. },
  76. async onPullDownRefresh() {
  77. await this.init(this.data.isPre);
  78. },
  79. onChange(e) {
  80. wx.createSelectorQuery().select('.container').boundingClientRect(function (rect) {
  81. wx.pageScrollTo({
  82. scrollTop: 0
  83. })
  84. }).exec()
  85. if ("介绍" == getEventParam(e, "title")) {
  86. this.setData({
  87. topClass: 'top',
  88. active: getEventParam(e, "index"),
  89. disableLoadMore: false,
  90. })
  91. } else {
  92. this.setData({
  93. topClass: 'top-bg',
  94. active: getEventParam(e, "index"),
  95. disableLoadMore: true
  96. })
  97. }
  98. },
  99. async requestData() {
  100. const res = await Api.getTeamInteraction({
  101. teamId: this.data.teamId,
  102. pageNum: this.pageNum,
  103. pageSize: this.pageSize
  104. });
  105. res.data.rows.forEach(item => {
  106. if (item.attachmentUrlList && item.attachmentType == uploadResTypes.IMAGE) {
  107. let attachmentUrlList = item.attachmentUrlList || [];
  108. item.attachmentUrlList = attachmentUrlList.map(item => {
  109. return {
  110. url: item,
  111. isImage: true
  112. }
  113. })
  114. item.createTime = formatTime(item.createTime);
  115. }
  116. })
  117. return res;
  118. },
  119. onHandlePublish(e) {
  120. const isSuccess = getEventParam(e, "isSuccess");
  121. if (isSuccess) {
  122. this.onPullDownRefresh();
  123. }
  124. },
  125. refreshData() {
  126. this.onPullDownRefresh();
  127. }
  128. });