myClass.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. const app = require('../../utils/util.js');
  2. const tools = require('../../utils/tools.js');
  3. Page({
  4. data: {
  5. showMore: false, //更多
  6. showzs: false,
  7. show: false,
  8. sessionKey: "",
  9. notice: "暂无未读通知",
  10. classInfo: {},
  11. kcArr: [],
  12. sfmArr: [],
  13. studentName: "",
  14. status: '', //状态
  15. },
  16. // 更多
  17. listToggle: function () {
  18. this.setData({
  19. showMore: !this.data.showMore
  20. })
  21. },
  22. hidePopup() {
  23. this.setData({
  24. show: false
  25. });
  26. let sessionKey = "";
  27. wx.checkSession({
  28. success: () => {
  29. sessionKey = wx.getStorageSync('sessionKey');
  30. wx.request({
  31. url: app.globalData.publicUrl + '/wx/student/verification',
  32. method: "post",
  33. data: {
  34. sessionKey: sessionKey
  35. },
  36. success: function (res) {
  37. console.log(res, "我成功了")
  38. }
  39. })
  40. },
  41. fail() {
  42. console.log("我没有缓存并去登录请求")
  43. wx.login({
  44. success(res) {
  45. console.log(res);
  46. let code = res.code
  47. wx.request({
  48. url: app.globalData.publicUrl + '/wx/user/wx7e7a46e129d6cd0f/login',
  49. method: "get",
  50. data: {
  51. code
  52. },
  53. success: function (res) {
  54. sessionKey = res.data.sessionKey;
  55. wx.setStorageSync('sessionKey', res.data.sessionKey);
  56. wx.request({
  57. url: app.globalData.publicUrl + '/wx/student/verification',
  58. method: "post",
  59. data: {
  60. sessionKey: sessionKey
  61. },
  62. success: function (res) {
  63. console.log(res, "我成功了")
  64. }
  65. })
  66. }
  67. })
  68. }
  69. })
  70. }
  71. })
  72. },
  73. myactiveMore() {
  74. wx.navigateTo({
  75. url: '../myActive/myActive'
  76. })
  77. },
  78. // 随堂考试
  79. // gokhAnswer() {
  80. // wx.navigateTo({
  81. // url: '../answerAfterclass/answerAfterclass'
  82. // })
  83. // },
  84. gokhAnswer(e) {
  85. console.log(e.currentTarget.dataset.courseid, "00");
  86. wx.request({
  87. url: app.globalData.publicUrl + '/wx/exam/examList',
  88. method: "post",
  89. data: {
  90. sessionKey: this.data.sessionKey,
  91. courseId: e.currentTarget.dataset.courseid,
  92. clasId: this.data.classInfo.id
  93. },
  94. success: (res) => {
  95. if (res.data.code == 0) {
  96. console.log(res.data);
  97. //let answersId = res.data.list[0].answersId ;
  98. if (res.data.list[0]) {
  99. if (res.data.list[0].answersId) {
  100. this.toPath(res.data.list[0].id, res.data.list[0].paperId, res.data.list[0].answersId, 'answerAfterclass');
  101. } else {
  102. console.log('777777');
  103. this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey, 'answerAfterclass');
  104. }
  105. }
  106. }
  107. }
  108. })
  109. // wx.navigateTo({
  110. // url: '../evaluationCourse/evaluationCourse'
  111. // })
  112. },
  113. //w我的班级去评价
  114. gopjClass(e) {
  115. console.log(e.currentTarget.dataset.courseid, "00");
  116. wx.request({
  117. url: app.globalData.publicUrl + '/wx/exam/quesExamList',
  118. method: "post",
  119. data: {
  120. sessionKey: this.data.sessionKey,
  121. questSub: '3',
  122. courseId: e.currentTarget.dataset.courseid,
  123. clasId: this.data.classInfo.id
  124. },
  125. success: (res) => {
  126. if (res.data.code == 0) {
  127. console.log(res.data);
  128. //let answersId = res.data.list[0].answersId ;
  129. if (res.data.list[0]) {
  130. if (res.data.list[0].answersId) {
  131. if (res.data.list[0].status == '1') {
  132. wx.navigateTo({
  133. url: '/pages/evaluationCourseDetail/evaluationCourseDetail?answersId=' + res.data.list[0].answersId,
  134. })
  135. } else {
  136. this.toPath(res.data.list[0].id, res.data.list[0].paperId, res.data.list[0].answersId, 'evaluationCourse');
  137. }
  138. } else {
  139. console.log('777777');
  140. this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey, 'evaluationCourse');
  141. }
  142. }
  143. }
  144. }
  145. })
  146. // wx.navigateTo({
  147. // url: '../evaluationCourse/evaluationCourse'
  148. // })
  149. },
  150. goMyPoints() {
  151. // wx.showModal({
  152. // showCancel: false,
  153. // content: "敬请期待",
  154. // success(res) {}
  155. // })
  156. wx.navigateTo({
  157. url: '../myPoints/myPoints'
  158. })
  159. },
  160. goactiveDetails() {
  161. wx.navigateTo({
  162. url: '../myactiveDetails/myactiveDetails'
  163. })
  164. },
  165. lq() {
  166. // wx.showModal({
  167. // showCancel: false,
  168. // content: "此功能暂时还未开放哦",
  169. // success(res) {}
  170. // })
  171. this.setData({
  172. showzs: true
  173. });
  174. },
  175. onClose1() {
  176. this.setData({
  177. showzs: false
  178. });
  179. },
  180. // 期末考试
  181. goQmks() {
  182. this.getgoQmks();
  183. },
  184. // 期末考试接口 、、、、、、
  185. getgoQmks() {
  186. console.log(this.data.sessionKey);
  187. console.log(this.data.classInfo.id);
  188. wx.request({
  189. url: app.globalData.publicUrl + '/wx/exam/examList',
  190. method: "post",
  191. data: {
  192. sessionKey: this.data.sessionKey,
  193. clasId: this.data.classInfo.id
  194. },
  195. success: (res) => {
  196. if (res.data.code == 0) {
  197. console.log(res.data);
  198. //let answersId = res.data.list[0].answersId ;
  199. console.log(res.data.list.length);
  200. if (res.data.list[0]) {
  201. if (res.data.list[0].answersId) {
  202. if (res.data.list[0].status == '1') {
  203. wx.navigateTo({
  204. url: '/pages/grade/grade?answersId=' + res.data.list[0].answersId,
  205. })
  206. } else {
  207. this.toPath(res.data.list[0].id, res.data.list[0].paperId, res.data.list[0].answersId, 'answerAfterclass');
  208. }
  209. } else {
  210. this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey, 'answerAfterclass');
  211. }
  212. }
  213. }
  214. }
  215. })
  216. },
  217. // 学员登记表的
  218. goWrite() {
  219. // wx.showModal({
  220. // showCancel: false,
  221. // content: "敬请期待",
  222. // success(res) {}
  223. // })
  224. //this.getBanner();
  225. wx.navigateTo({
  226. url: '../studentRegistration/studentRegistration'
  227. })
  228. },
  229. // 学员登记表 、、、、、、
  230. getBanner() {
  231. console.log(this.data.sessionKey);
  232. wx.request({
  233. url: app.globalData.publicUrl + '/wx/exam/quesExamList',
  234. method: "post",
  235. data: {
  236. sessionKey: this.data.sessionKey,
  237. questSub: '0'
  238. },
  239. success: (res) => {
  240. if (res.data.code == 0) {
  241. console.log(res.data);
  242. //let answersId = res.data.list[0].answersId ;
  243. console.log(res.data.list.length);
  244. if (res.data.list[0]) {
  245. if (res.data.list[0].answersId) {
  246. if (res.data.list[0].status) {
  247. wx.navigateTo({
  248. url: '/pages/studentRegistrationDeyail/studentRegistrationDeyail?answersId=' + res.data.list[0].answersId,
  249. })
  250. } else {
  251. this.toPath(res.data.list[0].id, res.data.list[0].paperId, res.data.list[0].answersId, 'studentRegistration');
  252. }
  253. } else {
  254. console.log('777777');
  255. this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey, 'studentRegistration');
  256. }
  257. }
  258. }
  259. }
  260. })
  261. },
  262. // 综合反馈表 、、、、、、
  263. getBanner1() {
  264. console.log(this.data.sessionKey,"dayin");
  265. console.log(this.data.classInfo.id);
  266. wx.request({
  267. url: app.globalData.publicUrl + '/wx/exam/quesExamList',
  268. method: "post",
  269. data: {
  270. sessionKey: this.data.sessionKey,
  271. questSub: '1',
  272. clasId: this.data.classInfo.id
  273. },
  274. success: (res) => {
  275. if (res.data.code == 0) {
  276. console.log(res.data,"zonghe");
  277. //let answersId = res.data.list[0].answersId ;
  278. console.log(res.data.list.length);
  279. if (res.data.list[0]) {
  280. if (res.data.list[0].answersId) {
  281. if (res.data.list[0].status == '1') {
  282. wx.navigateTo({
  283. url: '/pages/feedBackDetail/feedBackDetail?answersId=' + res.data.list[0].answersId,
  284. })
  285. } else {
  286. this.toPath(res.data.list[0].id, res.data.list[0].paperId, res.data.list[0].answersId, 'feedBack');
  287. }
  288. } else {
  289. this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey, 'feedBack');
  290. }
  291. }
  292. }
  293. }
  294. })
  295. },
  296. toPath(id, paperId, answersId, address, status) {
  297. wx.navigateTo({
  298. url: '/pages/' + address + '/' + address + '?id=' + id + '&paperId=' + paperId + '&answersId=' + answersId + '&status=' + status,
  299. })
  300. },
  301. beginKao(id, paperId, sessionKey, address) {
  302. console.log(paperId, "8888888");
  303. wx.request({
  304. url: app.globalData.publicUrl + '/wx/exam/begin',
  305. method: "post",
  306. data: {
  307. sessionKey: sessionKey,
  308. id: id,
  309. paperId: paperId
  310. },
  311. success: (res) => {
  312. console.log(res);
  313. if (res.data.code == 0) {
  314. console.log(res, "为我么我们微妙"); // 提交答案是后
  315. this.setData({
  316. status: res.data.status
  317. })
  318. this.toPath(id, paperId, res.data.answersId, address, );
  319. }
  320. }
  321. })
  322. },
  323. goWrite2() {
  324. // wx.showModal({
  325. // showCancel: false,
  326. // content: "敬请期待",
  327. // success(res) {}
  328. // })
  329. // wx.navigateTo({
  330. // url: '../feedBack/feedBack'
  331. // })
  332. this.getBanner1();
  333. },
  334. // 跳转直播点播页面
  335. goStudy(e) {
  336. wx.showModal({
  337. showCancel: false,
  338. content: "您有未完成的学习课程,请先完成学习任务后再进行其他课程学习!",
  339. success(res) {}
  340. })
  341. // let id = e.currentTarget.dataset.item.id
  342. // if (e.currentTarget.dataset.item.isLive == 1) {
  343. // if (e.currentTarget.dataset.item.isActive == 1) {
  344. // wx.navigateTo({
  345. // url: '../zbDetails/zbDetails?id=' + id
  346. // })
  347. // } else {
  348. // wx.showModal({
  349. // showCancel: false,
  350. // content: "直播还未开始哦",
  351. // success(res) {}
  352. // })
  353. // }
  354. // } else {
  355. // wx.navigateTo({
  356. // url: '../dbDetails/dbDetails?id=' + id
  357. // })
  358. // }
  359. },
  360. // 查询我是否有班&&班级名字
  361. isClass(sessionKey) {
  362. // let _this = this;
  363. wx.request({
  364. url: app.globalData.publicUrl + '/wx/student/selMyClas',
  365. method: "post",
  366. data: {
  367. sessionKey: sessionKey
  368. },
  369. success: (res) => {
  370. console.log(res.data.code, "我是返回是否有班级")
  371. if (res.data.code == 0) {
  372. this.setData({
  373. classInfo: res.data.data
  374. })
  375. this.isAgree(sessionKey);
  376. } else {
  377. wx.showModal({
  378. content: "您当前还没有开放的班级!",
  379. showCancel: false,
  380. success(res) {
  381. if (res.confirm) {
  382. wx.switchTab({
  383. url: '../index/index'
  384. })
  385. }
  386. }
  387. })
  388. return false;
  389. }
  390. }
  391. })
  392. },
  393. // 协议是否已同意
  394. isAgree(sessionKey) {
  395. // let _this = this;
  396. wx.request({
  397. url: app.globalData.publicUrl + '/wx/student/selStudentSessionKey',
  398. method: "post",
  399. data: {
  400. sessionKey: sessionKey
  401. },
  402. success: (res) => {
  403. console.log(res, "查询学员信息")
  404. if (res.data.code == 0 && res.data.data) {
  405. if (res.data.data.isAgree == 0) {
  406. this.setData({
  407. studentName: res.data.data.studentName,
  408. show: true
  409. });
  410. } else {
  411. this.setData({
  412. studentName: res.data.data.studentName,
  413. show: false
  414. });
  415. }
  416. }
  417. }
  418. })
  419. },
  420. // 我的通知
  421. getMynotice(sessionKey) {
  422. // let _this = this;
  423. wx.request({
  424. url: app.globalData.publicUrl + '/wx/eduNoticeSee/list',
  425. method: "post",
  426. data: {
  427. sessionKey: sessionKey,
  428. isSee: 1,
  429. isNotice: 0
  430. },
  431. success: (res) => {
  432. console.log(res, "333333333")
  433. if (res.data.code == 0) {
  434. if (res.data.list && res.data.list.length !== 0)
  435. this.setData({
  436. notice: res.data.list[0].noticeContent
  437. });
  438. }
  439. }
  440. })
  441. },
  442. gomyNotice() {
  443. // if (this.data.notice !== "暂无未读通知") {
  444. wx.navigateTo({
  445. url: '../myNotice/myNotice'
  446. })
  447. // }
  448. },
  449. // // 我的课程
  450. getMycourse(sessionKey) {
  451. // let _this = this;
  452. wx.request({
  453. url: app.globalData.publicUrl + '/wx/course/selectBySessionKey',
  454. method: "post",
  455. data: {
  456. sessionKey: sessionKey
  457. },
  458. success: (res) => {
  459. console.log(res, "kckckc")
  460. this.setData({
  461. kcArr: res.data.list
  462. });
  463. let result = [];
  464. if (res.data.list)
  465. for (let i = 0; i < res.data.list.length; i++) {
  466. result.push({
  467. courseTime: res.data.list[i].courseTime
  468. });
  469. }
  470. const timesArr = result.map((item) => {
  471. return item.courseTime;
  472. });
  473. let sfmArr = [];
  474. for (let i = 0; i < timesArr.length; i++) {
  475. let value = timesArr[i];
  476. const resultValue = this.handler(value);
  477. sfmArr.push({
  478. courseTime: resultValue
  479. })
  480. this.setData({
  481. sfmArr: sfmArr
  482. })
  483. }
  484. }
  485. })
  486. },
  487. handler(value) {
  488. //换算为秒 进制1000
  489. const second = Math.floor(value / 1000); //判断是否够1秒
  490. if (second < 1) {
  491. return "0秒";
  492. }
  493. const secondValue = second % 60; // 秒
  494. const minutes = Math.floor(second / 60); //判断是否够1分钟
  495. if (minutes < 1) {
  496. return `${secondValue}秒`;
  497. }
  498. const minutesValue = minutes % 60; //分
  499. const hours = Math.floor(minutes / 60); //判断是否够1小时
  500. if (hours < 1) {
  501. return `${minutesValue}分${secondValue}秒`;
  502. }
  503. const hoursValue = hours % 60; //小时
  504. return `${hoursValue}时${minutesValue}分${secondValue}秒`;
  505. },
  506. async onShow() {
  507. const sessionKey = await tools.checkSessionAndLogin();
  508. console.log(sessionKey, "000000");
  509. //const sessionKey = 'BqQROCKCxn7R2NXdQLud9Q==';
  510. this.setData({
  511. sessionKey: sessionKey
  512. })
  513. this.isClass(sessionKey);
  514. this.getMycourse(sessionKey);
  515. this.getMynotice(sessionKey);
  516. }
  517. })