myTraining.js 1.7 KB

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