startClass.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. const app = require('../../utils/util.js');
  2. const tools = require('../../utils/tools.js');
  3. Page({
  4. data: {
  5. dataArr: []
  6. },
  7. getjj(sessionKey) {
  8. var _this = this;
  9. wx.request({
  10. url: app.globalData.publicUrl2 + '/wx/student/selClasToo',
  11. method: "post",
  12. data: {
  13. sessionKey: sessionKey,
  14. isActive: "0"
  15. },
  16. success: function (res) {
  17. console.log(res.data, "我是即将开班的列表")
  18. _this.setData({
  19. dataArr: res.data.data
  20. })
  21. }
  22. })
  23. },
  24. async onLoad() {
  25. const sessionKey = await tools.checkSessionAndLogin();
  26. this.getjj(sessionKey);
  27. // var _this = this;
  28. // wx.checkSession({
  29. // success: () => {
  30. // console.log("我有缓存")
  31. // var sessionKey = wx.getStorageSync('sessionKey');
  32. // if (sessionKey == "") {
  33. // wx.login({
  34. // success(res) {
  35. // console.log(res);
  36. // var code = res.code
  37. // wx.request({
  38. // url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
  39. // method: "get",
  40. // data: {
  41. // code
  42. // },
  43. // success: function (res) {
  44. // sessionKey = res.data.sessionKey;
  45. // wx.setStorageSync('sessionKey', res.data.sessionKey);
  46. // _this.getjj(sessionKey);
  47. // }
  48. // })
  49. // }
  50. // })
  51. // } else {
  52. // _this.getjj(sessionKey);
  53. // }
  54. // },
  55. // fail() {
  56. // console.log("我没有缓存并去登录请求")
  57. // wx.login({
  58. // success(res) {
  59. // console.log(res);
  60. // var code = res.code
  61. // wx.request({
  62. // url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
  63. // method: "get",
  64. // data: {
  65. // code
  66. // },
  67. // success: function (res) {
  68. // wx.setStorageSync('sessionKey', res.data.sessionKey);
  69. // var sessionKey = res.data.sessionKey
  70. // this.getjj(sessionKey);
  71. // }
  72. // })
  73. // }
  74. // })
  75. // }
  76. // })
  77. }
  78. })