myClass.js 29 KB

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