myClass.js 38 KB

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