myClass.js 31 KB

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