graduation.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. import {
  2. logicStatus,
  3. courseTypes,
  4. courseStatus
  5. } from "../../model/enum";
  6. import Route from "../../model/route";
  7. import Api from "../../model/api";
  8. import {
  9. toast
  10. } from "../../utils/utils";
  11. Page({
  12. data: {
  13. eInfo: {},
  14. isPre: logicStatus.NO,
  15. logicStatusEnum: logicStatus,
  16. },
  17. onLoad: function (options) {
  18. const {
  19. isPre,
  20. detail
  21. } = options;
  22. let eInfo = JSON.parse(detail);
  23. this.setData({
  24. isPre,
  25. eInfo
  26. })
  27. },
  28. toCertificate(e) {
  29. let detail = JSON.stringify(this.data.eInfo);
  30. Route.toCertificate(detail, this.data.isPre, {
  31. get: () => {
  32. this.setData({
  33. 'eInfo.graduateType': 1
  34. });
  35. const eventChannel = this.getOpenerEventChannel()
  36. eventChannel.emit('refresh');
  37. },
  38. refresh: () => {
  39. console.log('refresh data!');
  40. const eventChannel = this.getOpenerEventChannel()
  41. eventChannel.emit('refresh');
  42. }
  43. })
  44. },
  45. toQuestion(e) { //调查
  46. let eInfo = this.data.eInfo;
  47. if (eInfo.isQuestionnaire == logicStatus.NO) {
  48. Route.toQuestionDetail(eInfo.questionnaireId, eInfo.teamId, "", "", eInfo.eduStuId, {
  49. answer: () => {
  50. this.setData({
  51. 'eInfo.isQuestionnaire': 1
  52. })
  53. const eventChannel = this.getOpenerEventChannel()
  54. eventChannel.emit('refresh');
  55. }
  56. });
  57. } else {
  58. // toast("已完成问卷")
  59. Route.toQuestionResult(eInfo.questionnaireId, eInfo.eduStuId);
  60. }
  61. },
  62. toQuestion2(e) { //综合
  63. let eInfo = this.data.eInfo;
  64. if (eInfo.isComprehensive == logicStatus.NO) {
  65. Route.toQuestionDetail(eInfo.comprehensiveId, eInfo.teamId, "", "", eInfo.eduStuId, {
  66. answer: () => {
  67. this.setData({
  68. 'eInfo.isComprehensive': 1
  69. })
  70. const eventChannel = this.getOpenerEventChannel()
  71. eventChannel.emit('refresh');
  72. }
  73. });
  74. } else {
  75. // toast("已完成问卷")
  76. Route.toQuestionResult(eInfo.comprehensiveId, eInfo.eduStuId);
  77. }
  78. },
  79. async toExam(e) { //期末
  80. let eInfo = this.data.eInfo;
  81. if (eInfo.isExam == logicStatus.NO) {
  82. let {
  83. teamId,
  84. eduStuId: studentId
  85. } = this.data.eInfo;
  86. let res = await Api.checkFinalExam({
  87. teamId,
  88. studentId
  89. }, (code, msg, data) => {
  90. wx.hideToast();
  91. if (!data) {
  92. toast(msg);
  93. return false;
  94. }
  95. this.handleCheckFail(data);
  96. return false;
  97. });
  98. if (!res) {
  99. return;
  100. }
  101. Route.toExamDetail(eInfo.paperId, eInfo.examId, eInfo.eduStuId, {
  102. answer: () => {
  103. this.setData({
  104. 'eInfo.isExam': 1
  105. })
  106. const eventChannel = this.getOpenerEventChannel()
  107. eventChannel.emit('refresh');
  108. }
  109. });
  110. } else {
  111. // toast("已完成试卷");
  112. Route.toExamResult(eInfo.examId, eInfo.eduStuId);
  113. }
  114. },
  115. handleCheckFail(data) {
  116. let courseName = data.courseName;
  117. let courseStartTime = new Date(data.courseStart.replaceAll('-', '/')).getTime(); //解决ios兼容问题
  118. let nowTime = Date.now();
  119. const JUMP_TYPES = {
  120. COURSE: '1',
  121. EXAM: '2',
  122. EVALUATE: '3'
  123. };
  124. if (data.courseProcess == courseStatus.NO_START && courseStartTime > nowTime) {
  125. toast(`课程《${courseName}》尚未开始,暂不能参加毕业考试`);
  126. return false;
  127. }
  128. let unPassCheck = {};
  129. if (data.courseProcess == courseStatus.NO_START) {
  130. //去学习
  131. // type=3&id=21&detail=%7B%22teamName%22%3A%22%E7%BB%93%E4%B8%9A%E8%AF%81%E9%A2%86%E5%8F%96%E6%B5%8B%E8%AF%95%E7%8F%AD%22%2C%22eduStuName%22%3A%22%E6%AE%B7%E4%B8%B9%22%2C%22idCard%22%3A%22220421199410204926%22%2C%22isReport%22%3A1%2C%22isOnline%22%3Atrue%2C%22graduateType%22%3A0%2C%22questionnaireId%22%3A%2219%22%2C%22teamEnd%22%3A%222022-06-06%22%2C%22isExam%22%3A0%2C%22picUrl%22%3A%22http%3A%2F%2Fcollege-file-1302740389.cos.ap-beijing.myqcloud.com%2F2i0L5Ls63zSod1574457f7c9bac883c7d5e9f7f58c37.jpg%22%2C%22itemName%22%3A%22%E9%A2%86%E5%8F%96%E7%BB%93%E4%B8%9A%E8%AF%81%E6%B5%8B%E8%AF%95%22%2C%22isCheckin%22%3A0%2C%22teamStart%22%3A%222022-06-01%22%2C%22paperId%22%3A0%2C%22isComprehensive%22%3A0%2C%22teamState%22%3A1%2C%22itemEnd%22%3A%222022-06-06%22%2C%22comprehensiveId%22%3A%2221%22%2C%22eduStuId%22%3A13%2C%22groupName%22%3A%22%E4%B8%80%E7%BB%84%22%2C%22teamId%22%3A2%2C%22itemStart%22%3A%222022-06-01%22%2C%22examId%22%3A0%2C%22isQuestionnaire%22%3A0%2C%22isRegister%22%3A1%7D&plan=%7B%22searchValue%22%3Anull%2C%22createBy%22%3Anull%2C%22createTime%22%3A%222022-06-04%2009%3A00%3A06%22%2C%22updateBy%22%3Anull%2C%22updateTime%22%3Anull%2C%22remark%22%3Anull%2C%22params%22%3A%7B%7D%2C%22id%22%3A21%2C%22courseId%22%3A151%2C%22courseName%22%3A%22%E5%BA%86%E7%A5%9D%E4%B8%AD%E5%9B%BD%E5%85%B1%E4%BA%A7%E5%85%9A%E6%88%90%E7%AB%8B100%E5%91%A8%E5%B9%B4%22%2C%22courseThumbnailUrl%22%3A%22https%3A%2F%2Fcollege-file-1254259530.cos.ap-beijing.myqcloud.com%2Fresource%2Fcourse%2Ff6ea43c4-e00d-47d4-935c-24bfc77c2527%2F%25E5%25BE%25AE%25E4%25BF%25A1%25E5%259B%25BE%25E7%2589%2587_20210421164805.jpg%22%2C%22partIds%22%3Anull%2C%22partIdsRemark%22%3Anull%2C%22partNames%22%3Anull%2C%22arrangeId%22%3A5%2C%22courseStart%22%3A%222022-06-01%2000%3A00%3A00%22%2C%22courseEnd%22%3A%222022-06-06%2000%3A00%3A00%22%2C%22comperes%22%3Anull%2C%22comperesRemark%22%3Anull%2C%22comperesDept%22%3Anull%2C%22comperesDeptId%22%3Anull%2C%22comperesName%22%3Anull%2C%22classroomId%22%3Anull%2C%22baseId%22%3Anull%2C%22baseName%22%3Anull%2C%22classroomName%22%3Anull%2C%22enclosureUrl%22%3A%22%5B%7B%5C%22url%5C%22%3A%5C%22https%3A%2F%2F1254259530.vod2.myqcloud.com%2Fe55e0a06vodcq1254259530%2F4de367ce3701925919887166250%2FOk1e6me3wnQA.mp4%5C%22%2C%5C%22name%5C%22%3A%5C%22%E5%BA%86%E7%A5%9D%E4%B8%AD%E5%9B%BD%E5%85%B1%E4%BA%A7%E5%85%9A%E6%88%90%E7%AB%8B100%E5%91%A8%E5%B9%B4.mp4%5C%22%2C%5C%22fileId%5C%22%3A%5C%223701925919887166250%5C%22%2C%5C%22duration%5C%22%3A116%2C%5C%22verifyInterval%5C%22%3A0%7D%5D%22%2C%22groupIds%22%3A%223%22%2C%22groupId%22%3Anull%2C%22groupName%22%3A%22%E4%B8%80%E7%BB%84%22%2C%22teamId%22%3A2%2C%22teacherId%22%3A133%2C%22teacherName%22%3A%22%E8%B7%AF%E4%BA%9A%E5%85%B0%22%2C%22photoUrl%22%3A%22https%3A%2F%2Fcollege-file-1254259530.cos.ap-beijing.myqcloud.com%2Fresource%2Fteacher%2Fzp%2Fzp_2.png%22%2C%22itemId%22%3A2%2C%22itemName%22%3A%22%E9%A2%86%E5%8F%96%E7%BB%93%E4%B8%9A%E8%AF%81%E6%B5%8B%E8%AF%95%22%2C%22teamName%22%3A%22%E7%BB%93%E4%B8%9A%E8%AF%81%E9%A2%86%E5%8F%96%E6%B5%8B%E8%AF%95%E7%8F%AD%22%2C%22treeIds%22%3Anull%2C%22ceremonyContent%22%3Anull%2C%22ceremonyId%22%3Anull%2C%22ceremonyName%22%3Anull%2C%22seatMap%22%3Anull%2C%22status%22%3A0%2C%22courseStatus%22%3Anull%2C%22liveStatus%22%3Anull%2C%22videoPlaybackUrl%22%3Anull%2C%22courseType%22%3A3%2C%22isLive%22%3A0%2C%22isReplay%22%3A0%2C%22isExam%22%3A0%2C%22examId%22%3Anull%2C%22paperId%22%3Anull%2C%22suitangUpper%22%3A%2220%22%2C%22suitangLower%22%3Anull%2C%22performanceId%22%3Anull%2C%22studentId%22%3Anull%2C%22signStatus%22%3Anull%2C%22isDone%22%3A0%2C%22examDone%22%3A2%2C%22questionDone%22%3A2%2C%22courseSynopsis%22%3A%22%E5%BA%86%E7%A5%9D%E4%B8%AD%E5%9B%BD%E5%85%B1%E4%BA%A7%E5%85%9A%E6%88%90%E7%AB%8B100%E5%91%A8%E5%B9%B4%22%2C%22ceremonyCategory%22%3Anull%2C%22isEvaluate%22%3A0%2C%22courseProcess%22%3A0%2C%22ranks%22%3A%22%E5%9B%BD%E5%AE%B6%E8%8D%A3%E8%AA%89%22%2C%22courseModule%22%3A%22%E6%A5%B7%E6%A8%A1%E5%88%86%E4%BA%AB%22%2C%22isQuestion%22%3Anull%7D&isPre=0
  132. console.log('去学习');
  133. unPassCheck.confirmText = '去学习';
  134. unPassCheck.content = `未学完课程《${courseName}》`;
  135. unPassCheck.jumpType = JUMP_TYPES.COURSE;
  136. } else if (!data.examDone) {
  137. //去考试
  138. // id=36&examId=5&stuId=13
  139. console.log('去考试');
  140. unPassCheck.confirmText = '去考试';
  141. unPassCheck.content = `未参加《${courseName}》的随堂考试`;
  142. unPassCheck.jumpType = JUMP_TYPES.EXAM;
  143. } else if (!data.questionDone) {
  144. //去评价
  145. // id=20&teamId=2&courseId=228&scheduleId=20&eduStuId=13
  146. console.log('去评价');
  147. unPassCheck.confirmText = '去评价';
  148. unPassCheck.content = `未参加《${courseName}》的随堂问卷`;
  149. unPassCheck.jumpType = JUMP_TYPES.EVALUATE;
  150. }
  151. wx.showModal({
  152. title: '不能参加毕业考试',
  153. content: `${unPassCheck.content}`,
  154. confirmText: unPassCheck.confirmText,
  155. success: res => {
  156. if (!res.confirm) {
  157. return;
  158. }
  159. let {
  160. eduStuId,
  161. teamId
  162. } = this.data.eInfo;
  163. let jumpType = unPassCheck.jumpType;
  164. switch (jumpType) {
  165. case JUMP_TYPES.COURSE:
  166. let isPre = logicStatus.NO;
  167. let plan = JSON.stringify(data);
  168. let detail = JSON.stringify(this.data.eInfo);
  169. //start
  170. let type = "";
  171. if (data.courseType == courseTypes.RECORD) {
  172. type = courseTypes.RECORD;
  173. }
  174. // if (item.isReplay && item.isLive && item.liveStatus == liveStatus.LIVEEND && type == "") {
  175. // type = courseTypes.PLAYBACK;
  176. // }
  177. if (data.isLive && type == "") {
  178. type = courseTypes.LIVE;
  179. }
  180. if (type == "") {
  181. type = courseTypes.OFFLINE;
  182. }
  183. //end
  184. Route.toCourseDetail(type, data.id, detail, plan, isPre, {
  185. refresh: () => {
  186. // const eventChannel = this.getOpenerEventChannel()
  187. // eventChannel.emit('refresh');
  188. this.emitRefresh();
  189. }
  190. });
  191. break;
  192. case JUMP_TYPES.EXAM:
  193. // id=36&examId=5&stuId=13
  194. Route.toExamDetail(data.paperId, data.examId, eduStuId, {
  195. answer: () => {
  196. // const eventChannel = this.getOpenerEventChannel()
  197. // eventChannel.emit('refresh');
  198. this.emitRefresh();
  199. }
  200. });
  201. break;
  202. case JUMP_TYPES.EVALUATE:
  203. let qid = "";
  204. if (this.data.eInfo.isOnline) {
  205. qid = data.suitangUpper;
  206. } else {
  207. qid = data.suitangLower;
  208. }
  209. Route.toQuestionDetail(qid, teamId, data.courseId, data.id, eduStuId, {
  210. answer: () => {
  211. // this.triggerEvent("refresh")
  212. // const eventChannel = this.getOpenerEventChannel()
  213. // eventChannel.emit('refresh');
  214. this.emitRefresh();
  215. }
  216. });
  217. break;
  218. }
  219. }
  220. // showCancel: false
  221. });
  222. },
  223. emitRefresh() {
  224. const eventChannel = this.getOpenerEventChannel();
  225. eventChannel.emit('refresh');
  226. }
  227. })