myClass.js 31 KB

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