startClass.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //logs.js
  2. // const util = require('../../utils/util.js')
  3. const app = getApp()
  4. Page({
  5. data: {
  6. dataArr: [
  7. // {
  8. // "url": "/images/sc_img.png",
  9. // "name": "长春市社区工作者线上培训班",
  10. // "zbdw": "宽城区委组织部",
  11. // "time": "2020年06月23日"
  12. // }, {
  13. // "url": "/images/sc_img.png",
  14. // "name": "长春市专职党务工作者线上培训班",
  15. // "zbdw": "长春市委组织部",
  16. // "time": "2020年06月26日"
  17. // }, {
  18. // "url": "/images/sc_img.png",
  19. // "name": "区域党建联盟",
  20. // "zbdw": "宽城区委组织部",
  21. // "time": "2020年06月29日"
  22. // }, {
  23. // "url": "/images/sc_img.png",
  24. // "name": "小区党组织建设",
  25. // "zbdw": "宽城区委组织部",
  26. // "time": "2020年06月30日"
  27. // }
  28. ]
  29. },
  30. onLoad: function () {
  31. var sessionKey = "" ;
  32. var _this = this;
  33. wx.checkSession({
  34. success: () => {
  35. console.log("我有缓存")
  36. sessionKey = wx.getStorageSync('sessionKey');
  37. console.log(sessionKey)
  38. wx.request({
  39. url: app.globalData.publicUrl2 + '/education/student/wx/selClas?sessionKey=' + sessionKey + '&isActive=0',
  40. method: "post",
  41. success: function (res) {
  42. console.log (res,"我是即将开班的列表")
  43. _this.setData({
  44. dataArr: res.data.data
  45. })
  46. }
  47. })
  48. },
  49. fail() {
  50. console.log("我没有缓存并去登录请求")
  51. wx.login({
  52. success(res) {
  53. console.log(res);
  54. var code = res.code
  55. wx.request({
  56. url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
  57. method: "get",
  58. data: {
  59. code
  60. },
  61. success: function (res) {
  62. sessionKey = res.data.sessionKey;
  63. wx.setStorageSync('sessionKey', res.data.sessionKey);
  64. }
  65. })
  66. }
  67. })
  68. }
  69. })
  70. }
  71. })