myClass.js 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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. },
  15. // 更多
  16. listToggle: function () {
  17. this.setData({
  18. showMore: !this.data.showMore
  19. })
  20. },
  21. hidePopup() {
  22. this.setData({
  23. show: false
  24. });
  25. let sessionKey = "";
  26. wx.checkSession({
  27. success: () => {
  28. sessionKey = wx.getStorageSync('sessionKey');
  29. wx.request({
  30. url: app.globalData.publicUrl + '/wx/student/verification',
  31. method: "post",
  32. data: {
  33. sessionKey: sessionKey
  34. },
  35. success: function (res) {
  36. console.log(res, "我成功了")
  37. }
  38. })
  39. },
  40. fail() {
  41. console.log("我没有缓存并去登录请求")
  42. wx.login({
  43. success(res) {
  44. console.log(res);
  45. let code = res.code
  46. wx.request({
  47. url: app.globalData.publicUrl + '/wx/user/wx7e7a46e129d6cd0f/login',
  48. method: "get",
  49. data: {
  50. code
  51. },
  52. success: function (res) {
  53. sessionKey = res.data.sessionKey;
  54. wx.setStorageSync('sessionKey', res.data.sessionKey);
  55. wx.request({
  56. url: app.globalData.publicUrl + '/wx/student/verification',
  57. method: "post",
  58. data: {
  59. sessionKey: sessionKey
  60. },
  61. success: function (res) {
  62. console.log(res, "我成功了")
  63. }
  64. })
  65. }
  66. })
  67. }
  68. })
  69. }
  70. })
  71. },
  72. myactiveMore() {
  73. wx.navigateTo({
  74. url: '../myActive/myActive'
  75. })
  76. },
  77. gokhAnswer() {
  78. wx.navigateTo({
  79. url: '../answerAfterclass/answerAfterclass'
  80. })
  81. },
  82. gopjClass() {
  83. wx.navigateTo({
  84. url: '../evaluationCourse/evaluationCourse'
  85. })
  86. },
  87. goMyPoints() {
  88. // wx.showModal({
  89. // showCancel: false,
  90. // content: "敬请期待",
  91. // success(res) {}
  92. // })
  93. wx.navigateTo({
  94. url: '../myPoints/myPoints'
  95. })
  96. },
  97. goactiveDetails() {
  98. wx.navigateTo({
  99. url: '../myactiveDetails/myactiveDetails'
  100. })
  101. },
  102. lq() {
  103. // wx.showModal({
  104. // showCancel: false,
  105. // content: "此功能暂时还未开放哦",
  106. // success(res) {}
  107. // })
  108. this.setData({
  109. showzs: true
  110. });
  111. },
  112. onClose1() {
  113. this.setData({
  114. showzs: false
  115. });
  116. },
  117. goQmks() {
  118. wx.showModal({
  119. showCancel: false,
  120. content: "此功能暂时还未开放哦",
  121. success(res) {}
  122. })
  123. },
  124. // 学员登记表的
  125. goWrite() {
  126. // wx.showModal({
  127. // showCancel: false,
  128. // content: "敬请期待",
  129. // success(res) {}
  130. // })
  131. this.getBanner();
  132. // wx.navigateTo({
  133. // url: '../studentRegistration/studentRegistration'
  134. // })
  135. },
  136. // 学员登记表 、、、、、、
  137. getBanner() {
  138. wx.request({
  139. url: app.globalData.publicUrl + '/wx/exam/list',
  140. method: "post",
  141. data: {
  142. sessionKey: this.data.sessionKey,
  143. questSub: '0'
  144. },
  145. success: (res) => {
  146. if (res.data.code == 0) {
  147. console.log(res.data);
  148. //let answersId = res.data.list[0].answersId ;
  149. console.log(res.data.list.length);
  150. if (res.data.list[0]) {
  151. if (res.data.list[0].answersId) {
  152. this.toPath(res.data.list[0].id, res.data.list[0].paperId, res.data.list[0].answersId);
  153. } else {
  154. console.log('777777');
  155. this.beginKao(res.data.list[0].id, res.data.list[0].paperId, this.data.sessionKey);
  156. }
  157. }
  158. }
  159. }
  160. })
  161. },
  162. toPath(id, paperId, answersId) {
  163. wx.navigateTo({
  164. url: '/pages/studentRegistration/studentRegistration?id=' + id + '&paperId=' + paperId + '&answersId=' + answersId,
  165. })
  166. },
  167. beginKao(id, paperId, sessionKey) {
  168. console.log(paperId, "8888888");
  169. wx.request({
  170. url: app.globalData.publicUrl + '/wx/exam/begin',
  171. method: "post",
  172. data: {
  173. sessionKey: sessionKey,
  174. id: id,
  175. paperId: paperId
  176. },
  177. success: (res) => {
  178. console.log(res);
  179. if (res.data.code == 0) {
  180. console.log(res, "为我么我们微妙"); // 提交答案是后
  181. this.toPath(id, paperId, res.data.answersId);
  182. }
  183. }
  184. })
  185. },
  186. goWrite2() {
  187. // wx.showModal({
  188. // showCancel: false,
  189. // content: "敬请期待",
  190. // success(res) {}
  191. // })
  192. wx.navigateTo({
  193. url: '../feedBack/feedBack'
  194. })
  195. },
  196. // 跳转直播点播页面
  197. goStudy(e) {
  198. wx.showModal({
  199. showCancel: false,
  200. content: "您有未完成的学习课程,请先完成学习任务后再进行其他课程学习!",
  201. success(res) {}
  202. })
  203. // let id = e.currentTarget.dataset.item.id
  204. // if (e.currentTarget.dataset.item.isLive == 1) {
  205. // if (e.currentTarget.dataset.item.isActive == 1) {
  206. // wx.navigateTo({
  207. // url: '../zbDetails/zbDetails?id=' + id
  208. // })
  209. // } else {
  210. // wx.showModal({
  211. // showCancel: false,
  212. // content: "直播还未开始哦",
  213. // success(res) {}
  214. // })
  215. // }
  216. // } else {
  217. // wx.navigateTo({
  218. // url: '../dbDetails/dbDetails?id=' + id
  219. // })
  220. // }
  221. },
  222. // 查询我是否有班&&班级名字
  223. isClass(sessionKey) {
  224. // let _this = this;
  225. wx.request({
  226. url: app.globalData.publicUrl + '/wx/student/selMyClas',
  227. method: "post",
  228. data: {
  229. sessionKey: sessionKey
  230. },
  231. success: (res) => {
  232. console.log(res.data.code, "我是返回是否有班级")
  233. if (res.data.code == 0) {
  234. this.setData({
  235. classInfo: res.data.data
  236. })
  237. this.isAgree(sessionKey);
  238. } else {
  239. wx.showModal({
  240. content: "您当前还没有开放的班级!",
  241. showCancel: false,
  242. success(res) {
  243. if (res.confirm) {
  244. wx.switchTab({
  245. url: '../index/index'
  246. })
  247. }
  248. }
  249. })
  250. return false;
  251. }
  252. }
  253. })
  254. },
  255. // 协议是否已同意
  256. isAgree(sessionKey) {
  257. // let _this = this;
  258. wx.request({
  259. url: app.globalData.publicUrl + '/wx/student/selStudentSessionKey',
  260. method: "post",
  261. data: {
  262. sessionKey: sessionKey
  263. },
  264. success: (res) => {
  265. console.log(res, "查询学员信息")
  266. if (res.data.code == 0 && res.data.data) {
  267. if (res.data.data.isAgree == 0) {
  268. this.setData({
  269. studentName: res.data.data.studentName,
  270. show: true
  271. });
  272. } else {
  273. this.setData({
  274. studentName: res.data.data.studentName,
  275. show: false
  276. });
  277. }
  278. }
  279. }
  280. })
  281. },
  282. // 我的通知
  283. getMynotice(sessionKey) {
  284. // let _this = this;
  285. wx.request({
  286. url: app.globalData.publicUrl + '/wx/eduNoticeSee/list',
  287. method: "post",
  288. data: {
  289. sessionKey: sessionKey,
  290. isSee: 1,
  291. isNotice: 0
  292. },
  293. success: (res) => {
  294. console.log(res, "333333333")
  295. if (res.data.code == 0) {
  296. if (res.data.list && res.data.list.length !== 0)
  297. this.setData({
  298. notice: res.data.list[0].noticeContent
  299. });
  300. }
  301. }
  302. })
  303. },
  304. gomyNotice() {
  305. // if (this.data.notice !== "暂无未读通知") {
  306. wx.navigateTo({
  307. url: '../myNotice/myNotice'
  308. })
  309. // }
  310. },
  311. // // 我的课程
  312. getMycourse(sessionKey) {
  313. // let _this = this;
  314. wx.request({
  315. url: app.globalData.publicUrl + '/wx/course/selectBySessionKey',
  316. method: "post",
  317. data: {
  318. sessionKey: sessionKey
  319. },
  320. success: (res) => {
  321. console.log(res, "kckckc")
  322. this.setData({
  323. kcArr: res.data.list
  324. });
  325. let result = [];
  326. if (res.data.list)
  327. for (let i = 0; i < res.data.list.length; i++) {
  328. result.push({
  329. courseTime: res.data.list[i].courseTime
  330. });
  331. }
  332. const timesArr = result.map((item) => {
  333. return item.courseTime;
  334. });
  335. let sfmArr = [];
  336. for (let i = 0; i < timesArr.length; i++) {
  337. let value = timesArr[i];
  338. const resultValue = this.handler(value);
  339. sfmArr.push({
  340. courseTime: resultValue
  341. })
  342. this.setData({
  343. sfmArr: sfmArr
  344. })
  345. }
  346. }
  347. })
  348. },
  349. handler(value) {
  350. //换算为秒 进制1000
  351. const second = Math.floor(value / 1000); //判断是否够1秒
  352. if (second < 1) {
  353. return "0秒";
  354. }
  355. const secondValue = second % 60; // 秒
  356. const minutes = Math.floor(second / 60); //判断是否够1分钟
  357. if (minutes < 1) {
  358. return `${secondValue}秒`;
  359. }
  360. const minutesValue = minutes % 60; //分
  361. const hours = Math.floor(minutes / 60); //判断是否够1小时
  362. if (hours < 1) {
  363. return `${minutesValue}分${secondValue}秒`;
  364. }
  365. const hoursValue = hours % 60; //小时
  366. return `${hoursValue}时${minutesValue}分${secondValue}秒`;
  367. },
  368. async onShow() {
  369. //const sessionKey = await tools.checkSessionAndLogin();
  370. const sessionKey = 'BqQROCKCxn7R2NXdQLud9Q==';
  371. this.setData({
  372. sessionKey: sessionKey
  373. })
  374. //this.isClass(sessionKey);
  375. this.getMycourse(sessionKey);
  376. this.getMynotice(sessionKey);
  377. }
  378. })