const app = require('../../utils/util.js'); Page({ data: { showMore: false, //更多 show: false, SessionKey: "", notice: "", className: '', kcArr: [], "myactiveArr": [{ "name": "现场体验:长山花园社区", "cysj": "2020/06/20 07:09", "cyry": "全体人员", }, { "name": "实战演练:党建工作实务", "cysj": "2020/06/21 07:09", "cyry": "全体人员", }, { "name": "现场体验:青岛路社区", "cysj": "2020/06/22 07:09", "cyry": "全体人员", } ] }, // 更多 listToggle: function () { this.setData({ showMore: !this.data.showMore }) }, hidePopup() { var _this = this; _this.setData({ show: false }); var sessionKey = ""; wx.checkSession({ success: () => { sessionKey = wx.getStorageSync('sessionKey'); wx.request({ url: app.globalData.publicUrl2 + '/wx/student/verification', method: "post", data: { sessionKey: sessionKey }, success: function (res) { console.log(res, "我成功了") } }) }, 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); wx.request({ url: app.globalData.publicUrl2 + '/wx/student/verification', method: "post", data: { sessionKey: sessionKey }, success: function (res) { console.log(res, "我成功了") } }) } }) } }) } }) }, myactiveMore() { wx.navigateTo({ url: '../myActive/myActive' }) }, gokhAnswer() { wx.navigateTo({ url: '../answerAfterclass/answerAfterclass' }) }, gopjClass() { wx.navigateTo({ url: '../evaluationCourse/evaluationCourse' }) }, goMyPoints() { wx.navigateTo({ url: '../myPoints/myPoints' }) }, goactiveDetails() { wx.navigateTo({ url: '../myactiveDetails/myactiveDetails' }) }, lq() { wx.showToast({ title: '领取成功' }) }, goWrite() { wx.navigateTo({ url: '../studentRegistration/studentRegistration' }) }, goWrite2() { wx.navigateTo({ url: '../feedBack/feedBack' }) }, // 跳转直播点播页面 goStudy(e) { // console.log(e.currentTarget.dataset.item.id) let id = e.currentTarget.dataset.item.id if (e.currentTarget.dataset.item.isLive == 1) { wx.navigateTo({ url: '../zbDetails/zbDetails?id=' + id }) } else { wx.navigateTo({ url: '../dbDetails/dbDetails?id=' + id }) } }, // 我的班级名字 getClassName(sessionKey) { var _this = this; wx.request({ url: app.globalData.publicUrl2 + '/wx/student/selAllClas', method: "post", data: { sessionKey: sessionKey }, success: function (res) { console.log(res.data.data, "22222222") var filterArr = res.data.data.claList.filter(o => o.isActive == 5) console.log(filterArr) if (filterArr.length !== 0) { _this.setData({ className: filterArr[0].clasName }) } } }) }, // 查询我是否有班 isClass(sessionKey) { var _this = this; wx.request({ url: app.globalData.publicUrl2 + '/wx/student/selAllClas', method: "post", data: { sessionKey: sessionKey }, success: function (res) { console.log(res.data, "我是返回的班级列表") var filterArr = res.data.data.claList.filter(o => o.isActive == 5) console.log(filterArr, "我是筛选出来的数组") if (filterArr.length == 0) { wx.showModal({ title: '您还未加入班级', content: '跳转至身份认证', success: function (res) { if (res.confirm) { wx.redirectTo({ url: '../Identity/Identity' }) } else { wx.switchTab({ url: '../index/index' }) } } }) return false; } else { _this.isAgree(sessionKey); } } }) }, // 协议是否已同意 isAgree(sessionKey) { var _this = this; wx.request({ url: app.globalData.publicUrl2 + '/wx/student/selStudentSessionKey', method: "post", data: { sessionKey: sessionKey }, success: function (res) { console.log(res.data, "wwwwww") if (res.data.data) { if (res.data.data.isAgree == 0) { _this.setData({ show: true }); } else { _this.setData({ show: false }); } } } }) }, // 我的通知 getMynotice(sessionKey) { var _this = this; wx.request({ url: app.globalData.publicUrl3 + '/wx/eduNoticeSee/list', method: "post", data: { sessionKey: sessionKey, isSee: 1, isPublish: 0, isNotice: 0 }, success: function (res) { console.log(res, "333333333") if (res.data) _this.setData({ notice: res.data.list[0].noticeContent }); } }) }, // // 我的课程 getMycourse(sessionKey) { var _this = this; wx.request({ url: app.globalData.publicUrl + '/wx/course/selectBySessionKey', method: "post", data: { sessionKey: sessionKey }, success: function (res) { console.log(res) _this.setData({ kcArr: res.data.list }); } }) }, onShow() { var _this = this; wx.checkSession({ success: () => { console.log("我有缓存") var sessionKey = wx.getStorageSync('sessionKey'); console.log(sessionKey, "我有缓存") if (sessionKey == "") { 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); _this.isClass(sessionKey); _this.getClassName(sessionKey); _this.getMycourse(sessionKey); _this.getMynotice(sessionKey); } }) } }) } else { _this.isClass(sessionKey); _this.getMycourse(sessionKey); _this.getClassName(sessionKey); _this.getMynotice(sessionKey); } }, 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) { wx.setStorageSync('sessionKey', res.data.sessionKey); var sessionKey = res.data.sessionKey; _this.isClass(sessionKey); _this.getMycourse(sessionKey); _this.getClassName(sessionKey); _this.getMynotice(sessionKey); } }) } }) } }) } })