agoClass.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. 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: function (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: function (res) {
  66. wx.setStorageSync('sessionKey', res.data.sessionKey);
  67. var sessionKey = res.data.sessionKey
  68. _this.getjj(sessionKey);
  69. }
  70. })
  71. }
  72. })
  73. }
  74. })
  75. }
  76. })