startClass.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const app = require('../../utils/util.js');
  2. Page({
  3. data: {
  4. dataArr: []
  5. },
  6. getjj(sessionKey) {
  7. var _this = this;
  8. wx.request({
  9. url: app.globalData.publicUrl2 + '/education/student/wx/selClas',
  10. method: "post",
  11. data: {
  12. sessionKey: sessionKey,
  13. isActive: "0"
  14. },
  15. success: function (res) {
  16. console.log(res.data.data.length, "我是即将开班的列表")
  17. _this.setData({
  18. dataArr: res.data.data
  19. })
  20. }
  21. })
  22. },
  23. onLoad: function () {
  24. var _this = this;
  25. wx.checkSession({
  26. success: () => {
  27. console.log("我有缓存")
  28. var sessionKey = wx.getStorageSync('sessionKey');
  29. this.getjj(sessionKey);
  30. },
  31. fail() {
  32. console.log("我没有缓存并去登录请求")
  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. wx.setStorageSync('sessionKey', res.data.sessionKey);
  45. var sessionKey = res.data.sessionKey
  46. this.getjj(sessionKey);
  47. }
  48. })
  49. }
  50. })
  51. }
  52. })
  53. }
  54. })