myClass.js 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  1. const app = require('../../utils/util.js');
  2. const tools = require('../../utils/tools.js');
  3. Page({
  4. data: {
  5. isRz: false,
  6. showMore: false, //更多
  7. showzs: false, //证书显示
  8. show: false, //协议显示
  9. notice: "暂无未读通知",
  10. classInfo: {}, //班级信息
  11. kcArr: [], //课程列表
  12. sfmArr: [], //换算时分秒数组
  13. studentName: "", //学生名字
  14. status: '', //状态
  15. myCanvasId: 0, //画布id
  16. byzsbj: "../../images/zsbj.jpg", //结业证背景 用于合成图片
  17. IngCourseArr: [], //如果有正在进行的课就存一下
  18. istask: false, //判断班级群是否添加
  19. istask1: false, //学员登记表是否完成
  20. istask2: false, //课程是否完成
  21. istask3: false, //期末考试是否完成
  22. istask4: false, //综合反馈是否完成
  23. currentId: null,
  24. currentName: ""
  25. },
  26. // 查询我是否认证
  27. isRz(sessionKey) {
  28. wx.request({
  29. url: app.globalData.publicUrl + '/wx/student/selStudentSessionKey',
  30. method: "post",
  31. data: {
  32. sessionKey
  33. },
  34. success: (res) => {
  35. if (res.data.code == 0 && (res.data.data !== null || res.data.data !== "")) {
  36. this.setData({
  37. isRz: false
  38. })
  39. this.isClass(sessionKey)
  40. } else {
  41. this.setData({
  42. isRz: true
  43. })
  44. }
  45. }
  46. })
  47. },
  48. escRz() {
  49. wx.switchTab({
  50. url: '/pages/index/index',
  51. })
  52. },
  53. goRz() {
  54. wx.navigateTo({
  55. url: '/pages/Identity/Identity',
  56. })
  57. },
  58. // 查询我是否有班&&班级名字
  59. isClass(sessionKey) {
  60. wx.request({
  61. url: app.globalData.publicUrl + '/wx/student/selMyClas',
  62. method: "post",
  63. data: {
  64. sessionKey
  65. },
  66. success: (res) => {
  67. if (res.data.code == 0) {
  68. this.setData({
  69. classInfo: res.data.data
  70. })
  71. this.isAgree(sessionKey);
  72. this.getMynotice(sessionKey);
  73. this.getMycourse(sessionKey);
  74. this.checkTaskList(sessionKey);
  75. this.checkTaskList3(sessionKey, res.data.data.id);
  76. this.checkTaskList4(sessionKey, res.data.data.id);
  77. } else {
  78. if (res.data.msg == "运行时异常:学员不可同时存在两个班级中。") {
  79. wx.showModal({
  80. content: "学员不可同时存在多个班级中哦",
  81. showCancel: false,
  82. success(res) {
  83. if (res.confirm) {
  84. wx.switchTab({
  85. url: '../index/index'
  86. })
  87. }
  88. }
  89. })
  90. return false;
  91. } else {
  92. wx.showModal({
  93. content: "您当前还没有正在开放的班级!",
  94. showCancel: false,
  95. success(res) {
  96. if (res.confirm) {
  97. wx.switchTab({
  98. url: '../index/index'
  99. })
  100. }
  101. }
  102. })
  103. return false;
  104. }
  105. }
  106. }
  107. })
  108. },
  109. // 协议是否已同意
  110. isAgree(sessionKey) {
  111. wx.request({
  112. url: app.globalData.publicUrl + '/wx/student/selStudentSessionKey',
  113. method: "post",
  114. data: {
  115. sessionKey
  116. },
  117. success: (res) => {
  118. if (res.data.code == 0 && res.data.data) {
  119. if (res.data.data.agreement == 0) {
  120. this.setData({
  121. studentName: res.data.data.studentName,
  122. show: false
  123. });
  124. } else {
  125. this.setData({
  126. studentName: res.data.data.studentName,
  127. show: true
  128. });
  129. }
  130. }
  131. }
  132. })
  133. },
  134. // 点击同意协议 并且记一下
  135. hidePopup() {
  136. wx.request({
  137. url: app.globalData.publicUrl + '/wx/student/verification',
  138. method: "post",
  139. data: {
  140. sessionKey: this.data.sessionKey
  141. },
  142. success: (res) => {
  143. this.setData({
  144. show: false
  145. });
  146. }
  147. })
  148. },
  149. moreThink() {
  150. wx.switchTab({
  151. url: '../index/index'
  152. })
  153. },
  154. // 检查班级群是否加了 && 学员登记任务check
  155. checkTaskList(sessionKey) {
  156. wx.request({
  157. url: app.globalData.publicUrl + '/wx/student/selStudentSessionKey',
  158. method: "post",
  159. data: {
  160. sessionKey
  161. },
  162. success: (res) => {
  163. if (res.data.code == 0) {
  164. console.log(res)
  165. this.setData({
  166. studentName: res.data.data.studentName,
  167. })
  168. if (res.data.data.joinClas == 0) {
  169. this.setData({
  170. istask: true
  171. })
  172. }
  173. if (res.data.data.register == 0) {
  174. this.setData({
  175. istask1: true
  176. })
  177. }
  178. }
  179. }
  180. })
  181. },
  182. // 期末考试任务检查
  183. checkTaskList3(sessionKey, id) {
  184. wx.request({
  185. url: app.globalData.publicUrl + '/wx/exam/clasExamstatus',
  186. method: "post",
  187. data: {
  188. sessionKey: sessionKey,
  189. clasId: id
  190. },
  191. success: (res) => {
  192. if (res.data.code == 0 && res.data.status == 1) {
  193. this.setData({
  194. istask3: true
  195. })
  196. }
  197. }
  198. })
  199. },
  200. // 综合反馈任务check
  201. checkTaskList4(sessionKey, id) {
  202. wx.request({
  203. url: app.globalData.publicUrl + '/wx/exam/status',
  204. method: "post",
  205. data: {
  206. sessionKey: sessionKey,
  207. clasId: id
  208. },
  209. success: (res) => {
  210. if (res.data.code == 0 && res.data.status == 1) {
  211. this.setData({
  212. istask4: true
  213. })
  214. }
  215. }
  216. })
  217. },
  218. // 页面上显示的我的未读通知
  219. getMynotice(sessionKey) {
  220. wx.request({
  221. url: app.globalData.publicUrl + '/wx/eduNoticeSee/list',
  222. method: "post",
  223. data: {
  224. sessionKey: sessionKey,
  225. isSee: 1
  226. // isNotice: 0
  227. },
  228. success: (res) => {
  229. if (res.data.code == 0) {
  230. if (res.data.list && res.data.list.length !== 0)
  231. this.setData({
  232. notice: res.data.list[0].noticeContent
  233. });
  234. }
  235. }
  236. })
  237. },
  238. // 跳转通知页
  239. gomyNotice() {
  240. wx.navigateTo({
  241. url: '../myNotice/myNotice'
  242. })
  243. },
  244. // 学员登记表
  245. goWrite() {
  246. if (this.data.classInfo.id == -1) {
  247. wx.navigateTo({
  248. url: '../studentRegistration/studentRegistration'
  249. })
  250. } else {
  251. if (!this.data.istask) {
  252. wx.showModal({
  253. showCancel: false,
  254. content: "请先去扫描二维码加入班级群吧",
  255. success(res) {
  256. if (res.confirm) {
  257. wx.switchTab({
  258. url: '../myMission/myMission'
  259. })
  260. }
  261. }
  262. })
  263. return false
  264. }
  265. wx.navigateTo({
  266. url: '../studentRegistration/studentRegistration'
  267. })
  268. }
  269. },
  270. // 学院介绍
  271. toAdd1() {
  272. wx.navigateTo({
  273. url: '../schoolIntrouce/schoolIntrouce'
  274. })
  275. },
  276. // 学员名单
  277. toAdd2() {
  278. wx.navigateTo({
  279. url: '../studentList/studentList?id=' + this.data.classInfo.id
  280. })
  281. },
  282. // 项目组名单
  283. toAdd3() {
  284. wx.navigateTo({
  285. url: '../groupsList/groupsList'
  286. })
  287. },
  288. // 我的课程
  289. getMycourse(sessionKey) {
  290. wx.request({
  291. url: app.globalData.publicUrl + '/wx/course/selectBySessionKey',
  292. method: "post",
  293. data: {
  294. sessionKey: sessionKey
  295. },
  296. success: (res) => {
  297. console.log(res, "我的课程")
  298. this.setData({
  299. kcArr: res.data.list,
  300. istask2: res.data.allDone,
  301. currentName: "",
  302. currentId: null
  303. });
  304. for (let i = 0; i < res.data.list.length; i++) {
  305. if (res.data.list[i].isLive == -1) {
  306. // 这个节课未全部完成
  307. if (res.data.list[i].isDone == "0") {
  308. // 这个视频已经进行了 看一半或者看完了
  309. if (res.data.list[i].isStudyDone == 0 || res.data.list[i].isStudyDone == 1) {
  310. this.setData({
  311. currentName: res.data.list[i].courseName,
  312. currentId: res.data.list[i].id
  313. })
  314. }
  315. }
  316. }
  317. }
  318. let result = [];
  319. if (res.data.list)
  320. for (let i = 0; i < res.data.list.length; i++) {
  321. result.push({
  322. courseTime: res.data.list[i].courseTime
  323. });
  324. }
  325. const timesArr = result.map((item) => {
  326. return item.courseTime;
  327. });
  328. let sfmArr = [];
  329. for (let i = 0; i < timesArr.length; i++) {
  330. let value = timesArr[i];
  331. const resultValue = this.handler(value);
  332. sfmArr.push({
  333. courseTime: resultValue
  334. })
  335. this.setData({
  336. sfmArr: sfmArr
  337. })
  338. }
  339. }
  340. })
  341. },
  342. // 时间换算
  343. handler(value) {
  344. //换算为秒 进制1000
  345. const second = Math.floor(value / 1000); //判断是否够1秒
  346. if (second < 1) {
  347. return "0秒";
  348. }
  349. const secondValue = second % 60; // 秒
  350. const minutes = Math.floor(second / 60); //判断是否够1分钟
  351. if (minutes < 1) {
  352. return `${secondValue}秒`;
  353. }
  354. const minutesValue = minutes % 60; //分
  355. const hours = Math.floor(minutes / 60); //判断是否够1小时
  356. if (hours < 1) {
  357. return `${minutesValue}分${secondValue}秒`;
  358. }
  359. const hoursValue = hours % 60; //小时
  360. return `${hoursValue}时${minutesValue}分${secondValue}秒`;
  361. },
  362. // 查看更多列表展开
  363. listToggle: function () {
  364. this.setData({
  365. showMore: !this.data.showMore
  366. })
  367. },
  368. // 去学习
  369. goStudy(e) {
  370. let id = e.currentTarget.dataset.item.id //此课程的id
  371. let courseUrl = e.currentTarget.dataset.item.courseUrl //此课程的id
  372. let courseName = e.currentTarget.dataset.item.courseName //此课程的id
  373. let courseInfo = e.currentTarget.dataset.item.courseInfo //此课程的id
  374. if (this.data.classInfo.id == -1) {
  375. if (e.currentTarget.dataset.item.isLive == 1) {
  376. if (e.currentTarget.dataset.item.isActive == 1) {
  377. wx.navigateTo({
  378. url: '../zbDetails/zbDetails?id=' + id
  379. })
  380. } else if (e.currentTarget.dataset.item.isActive == -1) {
  381. if (courseUrl == null || courseUrl == "") {
  382. wx.showModal({
  383. showCancel: false,
  384. content: "直播回放还未上传噢"
  385. })
  386. } else {
  387. wx.navigateTo({
  388. url: '../livePlayback/livePlayback?courseName=' + courseName + '&courseUrl=' + courseUrl + '&courseInfo=' + courseInfo
  389. })
  390. }
  391. } else {
  392. wx.showModal({
  393. showCancel: false,
  394. content: "直播还未开始哦"
  395. })
  396. return false;
  397. }
  398. } else {
  399. wx.navigateTo({
  400. url: '../dbDetails/dbDetails?id=' + id
  401. })
  402. }
  403. } else {
  404. console.log(this.data.istask)
  405. if (!this.data.istask) {
  406. wx.showModal({
  407. showCancel: false,
  408. content: "请先去扫描二维码加入班级群吧",
  409. success(res) {
  410. if (res.confirm) {
  411. wx.switchTab({
  412. url: '../myMission/myMission'
  413. })
  414. }
  415. }
  416. })
  417. return false
  418. }
  419. if (!this.data.istask1) {
  420. wx.showModal({
  421. showCancel: false,
  422. content: "请先填写学员登记表再来学习哦!"
  423. })
  424. return false
  425. }
  426. // 直播
  427. if (e.currentTarget.dataset.item.isLive == 1) {
  428. if (e.currentTarget.dataset.item.isActive == 1) {
  429. wx.navigateTo({
  430. url: '../zbDetails/zbDetails?id=' + id
  431. })
  432. } else if (e.currentTarget.dataset.item.isActive == -1) {
  433. if (courseUrl == null || courseUrl == "") {
  434. wx.showModal({
  435. showCancel: false,
  436. content: "直播回放还未上传噢"
  437. })
  438. } else {
  439. wx.navigateTo({
  440. url: '../livePlayback/livePlayback?courseName=' + courseName + '&courseUrl=' + courseUrl + '&courseInfo=' + courseInfo
  441. })
  442. }
  443. } else {
  444. wx.showModal({
  445. showCancel: false,
  446. content: "直播还未开始哦"
  447. })
  448. return false;
  449. }
  450. } else {
  451. if (this.data.currentId != null) {
  452. // 没学或者没学完
  453. if (e.currentTarget.dataset.item.isDone == 0) {
  454. if (id == this.data.currentId) {
  455. wx.navigateTo({
  456. url: '../dbDetails/dbDetails?id=' + id
  457. })
  458. } else {
  459. // 有未完成的但不是我 就不能跳转
  460. wx.showModal({
  461. showCancel: false,
  462. content: "您的" + this.data.currentName + "课还未学完,快去学习吧"
  463. })
  464. }
  465. } else {
  466. // 我看完了这个视频 还能看
  467. wx.navigateTo({
  468. url: '../dbDetails/dbDetails?id=' + id
  469. })
  470. }
  471. } else {
  472. wx.navigateTo({
  473. url: '../dbDetails/dbDetails?id=' + id
  474. })
  475. }
  476. }
  477. }
  478. },
  479. // 去考试
  480. gokhAnswer(e) {
  481. wx.showLoading({
  482. mask: true,
  483. title: '加载中',
  484. })
  485. if (this.data.classInfo.id == -1) {
  486. this.examination(e.currentTarget.dataset.item.id);
  487. wx.hideLoading();
  488. } else {
  489. wx.hideLoading();
  490. if (!this.data.istask) {
  491. wx.showModal({
  492. showCancel: false,
  493. content: "请先去扫描二维码加入班级群吧",
  494. success(res) {
  495. if (res.confirm) {
  496. wx.switchTab({
  497. url: '../myMission/myMission'
  498. })
  499. }
  500. }
  501. })
  502. return false
  503. }
  504. if (!this.data.istask1) {
  505. wx.showModal({
  506. showCancel: false,
  507. content: "请先填写学员登记表再来学习哦!"
  508. })
  509. return false
  510. }
  511. let isStudyDone = e.currentTarget.dataset.item.isStudyDone
  512. if (isStudyDone != 1) {
  513. wx.showModal({
  514. showCancel: false,
  515. content: "您当前的学习课程还未完成哦,请先完成再来考试吧!"
  516. })
  517. return false
  518. } else {
  519. this.examination(e.currentTarget.dataset.item.id);
  520. }
  521. }
  522. },
  523. // 考试方法单拿出来
  524. examination(id) {
  525. wx.request({
  526. url: app.globalData.publicUrl + '/wx/exam/examList',
  527. method: "post",
  528. data: {
  529. sessionKey: this.data.sessionKey,
  530. courseId: id,
  531. clasId: this.data.classInfo.id
  532. },
  533. success: (res) => {
  534. if (res.data.code == 0) {
  535. if (res.data.list.length == 0) {
  536. wx.showModal({
  537. showCancel: false,
  538. content: '老师还未出考试题哦'
  539. })
  540. } else {
  541. console.log(res, '1111')
  542. if (res.data.list[0]) {
  543. if (res.data.list[0].answersId) {
  544. this.toPath(res.data.list[0].id, res.data.list[0].paperId, res.data.list[0].answersId, 'answerAfterclass');
  545. } else {
  546. this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey, 'answerAfterclass');
  547. }
  548. }
  549. }
  550. }
  551. }
  552. })
  553. },
  554. //去评价
  555. gopjClass(e) {
  556. if (this.data.classInfo.id == -1) {
  557. this.evaluate(e.currentTarget.dataset.item.id)
  558. } else {
  559. if (!this.data.istask) {
  560. wx.showModal({
  561. showCancel: false,
  562. content: "请先去扫描二维码加入班级群吧",
  563. success(res) {
  564. if (res.confirm) {
  565. wx.switchTab({
  566. url: '../myMission/myMission'
  567. })
  568. }
  569. }
  570. })
  571. return false
  572. }
  573. if (!this.data.istask1) {
  574. wx.showModal({
  575. showCancel: false,
  576. content: "请先填写学员登记表再来学习哦!"
  577. })
  578. return false
  579. }
  580. let isStudyDone = e.currentTarget.dataset.item.isStudyDone
  581. if (isStudyDone != 1) {
  582. wx.showModal({
  583. showCancel: false,
  584. content: "您的学习课程还未完成哦,请先完成再来评价吧!"
  585. })
  586. return false
  587. } else {
  588. this.evaluate(e.currentTarget.dataset.item.id)
  589. }
  590. }
  591. },
  592. // 评价方法单拿出来
  593. evaluate(id) {
  594. wx.request({
  595. url: app.globalData.publicUrl + '/wx/exam/quesExamList',
  596. method: "post",
  597. data: {
  598. sessionKey: this.data.sessionKey,
  599. courseId: id,
  600. clasId: this.data.classInfo.id
  601. },
  602. success: (res) => {
  603. if (res.data.code == 0) {
  604. if (res.data.list.length == 0) {
  605. wx.showModal({
  606. showCancel: false,
  607. content: '老师还未出评价模板哦'
  608. })
  609. } else {
  610. if (res.data.list[0]) {
  611. if (res.data.list[0].answersId) {
  612. this.toPath(res.data.list[0].id, res.data.list[0].paperId, res.data.list[0].answersId, 'evaluationCourse');
  613. } else {
  614. this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey, 'evaluationCourse');
  615. }
  616. }
  617. }
  618. }
  619. }
  620. })
  621. },
  622. // 查看详情成绩
  623. gockcj(e) {
  624. console.log(e.currentTarget.dataset.item.isExamId)
  625. if (e.currentTarget.dataset.item.isExamId) {
  626. wx.request({
  627. url: app.globalData.publicUrl + '/wx/answer/detail',
  628. method: "post",
  629. data: {
  630. answersId: e.currentTarget.dataset.item.isExamId
  631. },
  632. success: (res) => {
  633. if (res.data.list[0] && res.data.list[0].answerScore >= 0 && res.data.list[0].answerScore != null) {
  634. wx.navigateTo({
  635. url: '/pages/grade/grade?answersId=' + e.currentTarget.dataset.item.isExamId,
  636. })
  637. } else {
  638. wx.showModal({
  639. showCancel: false,
  640. content: '当前老师批阅中,请耐心等待'
  641. })
  642. }
  643. },
  644. fail: () => {
  645. wx.showModal({
  646. showCancel: false,
  647. content: '当前老师批阅中,请耐心等待'
  648. })
  649. }
  650. })
  651. }
  652. },
  653. // 查看详情评价
  654. gockpj(e) {
  655. wx.navigateTo({
  656. url: '/pages/evaluationCourseDetail/evaluationCourseDetail?answersId=' + e.currentTarget.dataset.item.isFeedbackId,
  657. })
  658. },
  659. // 期末考试
  660. goQmks() {
  661. if (this.data.classInfo.id == -1) {
  662. wx.request({
  663. url: app.globalData.publicUrl + '/wx/exam/examList',
  664. method: "post",
  665. data: {
  666. sessionKey: this.data.sessionKey,
  667. clasId: this.data.classInfo.id
  668. },
  669. success: (res) => {
  670. if (res.data.code == 0) {
  671. if (res.data.list.length == 0) {
  672. wx.showModal({
  673. showCancel: false,
  674. content: '期末考试还未开始哦!'
  675. })
  676. } else {
  677. if (res.data.list[0].answersId) {
  678. if (res.data.list[0].status == '1') {
  679. wx.request({
  680. url: app.globalData.publicUrl + '/wx/answer/detail',
  681. method: "post",
  682. data: {
  683. answersId: res.data.list[0].answersId
  684. },
  685. success: (res1) => {
  686. if (res1.data.list[0].answerScore >= 0 && res1.data.list[0].answerScore != null) {
  687. wx.navigateTo({
  688. url: '/pages/grade/grade?answersId=' + res.data.list[0].answersId,
  689. })
  690. } else {
  691. wx.showModal({
  692. showCancel: false,
  693. content: '当前老师批阅中,请耐心等待'
  694. })
  695. }
  696. }
  697. })
  698. } else {
  699. this.toPath(res.data.list[0].id, res.data.list[0].paperId, res.data.list[0].answersId, 'answerAfterclass');
  700. }
  701. } else {
  702. this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey, 'answerAfterclass');
  703. }
  704. }
  705. }
  706. }
  707. })
  708. } else {
  709. if (!this.data.istask) {
  710. wx.showModal({
  711. showCancel: false,
  712. content: "请先去扫描二维码加入班级群吧",
  713. success(res) {
  714. if (res.confirm) {
  715. wx.switchTab({
  716. url: '../myMission/myMission'
  717. })
  718. }
  719. }
  720. })
  721. return false
  722. }
  723. if (!this.data.istask2) {
  724. wx.showModal({
  725. showCancel: false,
  726. content: "您的课程任务还未全部完成哦!请先去完成再来期末考试吧!"
  727. })
  728. return false
  729. }
  730. wx.request({
  731. url: app.globalData.publicUrl + '/wx/exam/examList',
  732. method: "post",
  733. data: {
  734. sessionKey: this.data.sessionKey,
  735. clasId: this.data.classInfo.id
  736. },
  737. success: (res) => {
  738. if (res.data.code == 0) {
  739. if (res.data.list.length == 0) {
  740. wx.showModal({
  741. showCancel: false,
  742. content: '期末考试还未开始哦!'
  743. })
  744. } else {
  745. if (res.data.list[0].answersId) {
  746. if (res.data.list[0].status == '1') {
  747. wx.request({
  748. url: app.globalData.publicUrl + '/wx/answer/detail',
  749. method: "post",
  750. data: {
  751. answersId: res.data.list[0].answersId
  752. },
  753. success: (res1) => {
  754. if (res1.data.list[0].answerScore >= 0 && res1.data.list[0].answerScore != null) {
  755. wx.navigateTo({
  756. url: '/pages/grade/grade?answersId=' + res.data.list[0].answersId,
  757. })
  758. } else {
  759. wx.showModal({
  760. showCancel: false,
  761. content: '当前老师批阅中,请耐心等待'
  762. })
  763. }
  764. }
  765. })
  766. } else {
  767. this.toPath(res.data.list[0].id, res.data.list[0].paperId, res.data.list[0].answersId, 'answerAfterclass');
  768. }
  769. } else {
  770. this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey, 'answerAfterclass');
  771. }
  772. }
  773. }
  774. }
  775. })
  776. }
  777. },
  778. // 综合反馈表
  779. goWrite2() {
  780. if (this.data.istask4) {
  781. wx.request({
  782. url: app.globalData.publicUrl + '/wx/exam/quesExamList',
  783. method: "post",
  784. data: {
  785. sessionKey: this.data.sessionKey,
  786. questSub: '1',
  787. clasId: this.data.classInfo.id
  788. },
  789. success: (res) => {
  790. if (res.data.code == 0) {
  791. if (res.data.list[0]) {
  792. if (res.data.list[0].answersId) {
  793. wx.navigateTo({
  794. url: '/pages/feedBackDetail/feedBackDetail?answersId=' + res.data.list[0].answersId,
  795. })
  796. } else {
  797. this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey, 'feedBack');
  798. }
  799. }
  800. }
  801. }
  802. })
  803. } else {
  804. wx.request({
  805. url: app.globalData.publicUrl + '/wx/exam/quesExamList',
  806. method: "post",
  807. data: {
  808. sessionKey: this.data.sessionKey,
  809. questSub: '1',
  810. clasId: this.data.classInfo.id
  811. },
  812. success: (res) => {
  813. if (res.data.code == 0) {
  814. if (res.data.list.length == 0) {
  815. wx.showModal({
  816. showCancel: false,
  817. content: '当前综合反馈还不可以填写哦!'
  818. })
  819. } else {
  820. if (res.data.list[0].answersId) {
  821. if (res.data.list[0].status == '1') {
  822. wx.navigateTo({
  823. url: '/pages/feedBackDetail/feedBackDetail?answersId=' + res.data.list[0].answersId,
  824. })
  825. } else {
  826. this.toPath(res.data.list[0].id, res.data.list[0].paperId, res.data.list[0].answersId, 'feedBack');
  827. }
  828. } else {
  829. this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey, 'feedBack');
  830. }
  831. }
  832. }
  833. }
  834. })
  835. }
  836. },
  837. // 我的积分
  838. goMyPoints() {
  839. wx.navigateTo({
  840. url: '../myPoints/myPoints'
  841. })
  842. },
  843. // 领取结业证
  844. lq() {
  845. if (this.data.classInfo.id == -1) {
  846. wx.showLoading({
  847. mask: true,
  848. title: '加载中',
  849. })
  850. this.setData({
  851. myCanvasId: this.data.myCanvasId + 1
  852. })
  853. let str = this.data.studentName + "同志于" + this.data.classInfo.beginDate + " 至 " + this.data.classInfo.endDate + "参加学习完成规定培训内容,准予结业,特发此证。"
  854. let strArr = [];
  855. let a = str.slice(0, 16);
  856. let b = str.slice(16, 36);
  857. let c = str.slice(36, 56);
  858. strArr.push(a, b, c);
  859. const ctx = wx.createCanvasContext(this.data.myCanvasId);
  860. ctx.drawImage(this.data.byzsbj, 0, 0, 300, 415); //里面的参数无非就是图片放置的位置即图片的横纵坐标,图片的宽高
  861. ctx.setFillStyle("#000");
  862. ctx.setFontSize(16); //字大小
  863. ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
  864. let leftPositionAarr = [60, 30, 30, 30]
  865. for (let i = 0; i < strArr.length; i++) {
  866. ctx.fillText(strArr[i], leftPositionAarr[i], 160 + i * 30);
  867. }
  868. // ctx.fillText(str, 150, 160); //150:canvas画布宽300,取1/2,中间,280:纵向位置
  869. ctx.draw();
  870. wx.hideLoading();
  871. this.setData({
  872. showzs: true
  873. });
  874. wx.request({
  875. url: app.globalData.publicUrl + '/wx/student/wxGraduation',
  876. method: "post",
  877. data: {
  878. sessionKey: this.data.sessionKey
  879. },
  880. success: (res) => {
  881. console.log(res.data, "领取结业证提交")
  882. }
  883. })
  884. } else {
  885. if (!this.data.istask) {
  886. wx.showModal({
  887. showCancel: false,
  888. content: "请先去扫描二维码加入班级群吧",
  889. success(res) {
  890. if (res.confirm) {
  891. wx.switchTab({
  892. url: '../myMission/myMission'
  893. })
  894. }
  895. }
  896. })
  897. return false
  898. }
  899. if (!this.data.istask3) {
  900. wx.showModal({
  901. showCancel: false,
  902. content: "您的期末考试还未完成哦!"
  903. })
  904. return false
  905. }
  906. wx.showLoading({
  907. mask: true,
  908. title: '加载中',
  909. })
  910. this.setData({
  911. myCanvasId: this.data.myCanvasId + 1
  912. })
  913. let str = this.data.studentName + "同志于" + this.data.classInfo.beginDate + " 至 " + this.data.classInfo.endDate + "参加学习完成规定培训内容,准予结业,特发此证。"
  914. let strArr = [];
  915. let a = str.slice(0, 16);
  916. let b = str.slice(16, 36);
  917. let c = str.slice(36, 56);
  918. strArr.push(a, b, c);
  919. const ctx = wx.createCanvasContext(this.data.myCanvasId);
  920. ctx.drawImage(this.data.byzsbj, 0, 0, 300, 415); //里面的参数无非就是图片放置的位置即图片的横纵坐标,图片的宽高
  921. ctx.setFillStyle("#000");
  922. ctx.setFontSize(16); //字大小
  923. ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
  924. let leftPositionAarr = [60, 30, 30, 30]
  925. for (let i = 0; i < strArr.length; i++) {
  926. ctx.fillText(strArr[i], leftPositionAarr[i], 160 + i * 30);
  927. }
  928. ctx.draw();
  929. wx.hideLoading();
  930. this.setData({
  931. showzs: true
  932. });
  933. wx.request({
  934. url: app.globalData.publicUrl + '/wx/student/wxGraduation',
  935. method: "post",
  936. data: {
  937. sessionKey: this.data.sessionKey
  938. },
  939. success: (res) => {
  940. console.log(res.data, "领取结业证提交")
  941. }
  942. })
  943. }
  944. },
  945. // 存储结业证
  946. saveZs() {
  947. wx.canvasToTempFilePath({ //把当前画布指定区域的内容导出生成指定大小的图片
  948. canvasId: this.data.myCanvasId,
  949. success(res) {
  950. wx.authorize({ //向用户发起授权请求
  951. scope: 'scope.writePhotosAlbum', //保存相册授权
  952. success: () => {
  953. wx.saveImageToPhotosAlbum({ //保存图片到系统相册
  954. filePath: res.tempFilePath,
  955. success: () => {
  956. wx.showToast({
  957. title: '图片保存成功'
  958. })
  959. }
  960. })
  961. }
  962. })
  963. }
  964. })
  965. },
  966. // 证书隐藏
  967. onClose1() {
  968. this.setData({
  969. showzs: false
  970. });
  971. },
  972. toPath(id, paperId, answersId, address, status) {
  973. wx.navigateTo({
  974. url: '/pages/' + address + '/' + address + '?id=' + id + '&paperId=' + paperId + '&answersId=' + answersId + '&status=' + status,
  975. })
  976. },
  977. beginKao(id, paperId, sessionKey, address) {
  978. wx.request({
  979. url: app.globalData.publicUrl + '/wx/exam/begin',
  980. method: "post",
  981. data: {
  982. sessionKey: sessionKey,
  983. id: id,
  984. paperId: paperId
  985. },
  986. success: (res) => {
  987. if (res.data.code == 0) {
  988. this.setData({
  989. status: res.data.status
  990. })
  991. this.toPath(id, paperId, res.data.answersId, address);
  992. }
  993. }
  994. })
  995. },
  996. async onShow() {
  997. // wx.showLoading({
  998. // title: '加载中',
  999. // mask:true
  1000. // })
  1001. const sessionKey = await tools.checkSessionAndLogin();
  1002. this.setData({
  1003. sessionKey
  1004. });
  1005. this.isRz(sessionKey)
  1006. }
  1007. })