myClass.js 38 KB

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