agoClass.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // const app = getApp()
  2. const app = require('../../utils/util.js');
  3. Page({
  4. data: {
  5. dataArr: []
  6. },
  7. getjj(sessionKey) {
  8. var _this = this;
  9. wx.request({
  10. url: app.globalData.publicUrl2 + '/education/student/wx/selClas',
  11. method: "post",
  12. data: {
  13. sessionKey: sessionKey,
  14. isActive: "2"
  15. },
  16. success: function (res) {
  17. console.log(res.data.data.length, "我是往期开班的列表")
  18. _this.setData({
  19. dataArr: res.data.data
  20. })
  21. }
  22. })
  23. },
  24. onLoad: function () {
  25. var _this = this;
  26. wx.checkSession({
  27. success: () => {
  28. console.log("我有缓存")
  29. var sessionKey = wx.getStorageSync('sessionKey');
  30. this.getjj(sessionKey);
  31. },
  32. fail() {
  33. console.log("我没有缓存并去登录请求")
  34. wx.login({
  35. success(res) {
  36. console.log(res);
  37. var code = res.code
  38. wx.request({
  39. url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
  40. method: "get",
  41. data: {
  42. code
  43. },
  44. success: function (res) {
  45. wx.setStorageSync('sessionKey', res.data.sessionKey);
  46. var sessionKey = res.data.sessionKey
  47. this.getjj(sessionKey);
  48. }
  49. })
  50. }
  51. })
  52. }
  53. })
  54. }
  55. })