myClass.js 38 KB

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