agoClass.js 2.2 KB

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