//logs.js // const util = require('../../utils/util.js') const app = getApp() Page({ data: { dataArr: [ // { // "url": "/images/sc_img.png", // "name": "长春市社区工作者线上培训班", // "zbdw": "宽城区委组织部", // "time": "2020年06月23日" // }, { // "url": "/images/sc_img.png", // "name": "长春市专职党务工作者线上培训班", // "zbdw": "长春市委组织部", // "time": "2020年06月26日" // }, { // "url": "/images/sc_img.png", // "name": "区域党建联盟", // "zbdw": "宽城区委组织部", // "time": "2020年06月29日" // }, { // "url": "/images/sc_img.png", // "name": "小区党组织建设", // "zbdw": "宽城区委组织部", // "time": "2020年06月30日" // } ] }, onLoad: function () { var sessionKey = "" ; var _this = this; wx.checkSession({ success: () => { console.log("我有缓存") sessionKey = wx.getStorageSync('sessionKey'); console.log(sessionKey) wx.request({ url: app.globalData.publicUrl2 + '/education/student/wx/selClas?sessionKey=' + sessionKey + '&isActive=0', method: "post", success: function (res) { console.log (res,"我是即将开班的列表") _this.setData({ dataArr: res.data.data }) } }) }, fail() { console.log("我没有缓存并去登录请求") wx.login({ success(res) { console.log(res); var code = res.code wx.request({ url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login', method: "get", data: { code }, success: function (res) { sessionKey = res.data.sessionKey; wx.setStorageSync('sessionKey', res.data.sessionKey); } }) } }) } }) } })