myTraining.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. const tools = require('../../utils/tools.js');
  2. const app = require('../../utils/util.js');
  3. Page({
  4. data: {
  5. dataArr: [],
  6. showNull: false
  7. },
  8. goClass(e) {
  9. let id = e.currentTarget.dataset.item.id
  10. let name = e.currentTarget.dataset.item.clasName
  11. let clasEnd = e.currentTarget.dataset.item.clasEnd
  12. if (e.currentTarget.dataset.item.isActive == 0) {
  13. wx.showModal({
  14. showCancel: false,
  15. content: "还未到开班时间哦"
  16. })
  17. }
  18. if (e.currentTarget.dataset.item.isActive == 1) {
  19. wx.switchTab({
  20. url: '../myClass/myClass'
  21. })
  22. }
  23. if (e.currentTarget.dataset.item.isActive == 2) {
  24. wx.navigateTo({
  25. url: '../historyClass/historyClass?id=' + id + '&&name=' + name + '&&clasEnd=' + clasEnd
  26. })
  27. }
  28. },
  29. getArr(sessionKey) {
  30. wx.request({
  31. url: app.globalData.publicUrl + '/wx/student/selWholeClas',
  32. method: "post",
  33. data: {
  34. sessionKey: sessionKey
  35. },
  36. success: (res) => {
  37. if (res.data.code == 0) {
  38. this.setData({
  39. dataArr: res.data.data
  40. })
  41. if (this.data.dataArr.length == 0) {
  42. this.setData({
  43. showNull: true
  44. })
  45. }
  46. } else {
  47. if (this.data.dataArr.length == 0) {
  48. this.setData({
  49. showNull: true
  50. })
  51. }
  52. }
  53. },
  54. fail: () => {
  55. if (this.data.dataArr.length == 0) {
  56. this.setData({
  57. showNull: true
  58. })
  59. }
  60. }
  61. })
  62. },
  63. async onLoad() {
  64. const sessionKey = await tools.checkSessionAndLogin();
  65. this.getArr(sessionKey);
  66. }
  67. })