const app = require('../../utils/util.js'); Page({ data: { showMore: false, //更多 showzs: false, show: false, SessionKey: "", notice: "暂无未读通知", className: '', logoImg: '', kcArr: [], sfmArr: [] }, // 更多 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.showModal({ // showCancel: false, // content: "敬请期待", // success(res) {} // }) wx.navigateTo({ url: '../myPoints/myPoints' }) }, goactiveDetails() { wx.navigateTo({ url: '../myactiveDetails/myactiveDetails' }) }, lq() { // wx.showModal({ // showCancel: false, // content: "此功能暂时还未开放哦", // success(res) {} // }) this.setData({ showzs: true }); }, onClose1() { this.setData({ showzs: false }); }, goQmks() { wx.showModal({ showCancel: false, content: "此功能暂时还未开放哦", success(res) {} }) }, goWrite() { // wx.showModal({ // showCancel: false, // content: "敬请期待", // success(res) {} // }) wx.navigateTo({ url: '../studentRegistration/studentRegistration' }) }, goWrite2() { // wx.showModal({ // showCancel: false, // content: "敬请期待", // success(res) {} // }) wx.navigateTo({ url: '../feedBack/feedBack' }) }, // 跳转直播点播页面 goStudy(e) { let id = e.currentTarget.dataset.item.id if (e.currentTarget.dataset.item.isLive == 1) { if (e.currentTarget.dataset.item.isActive == 1) { wx.navigateTo({ url: '../zbDetails/zbDetails?id=' + id }) } else { wx.showModal({ showCancel: false, content: "直播还未开始哦", success(res) {} }) } } else { wx.navigateTo({ url: '../dbDetails/dbDetails?id=' + id }) } }, // 查询我是否有班&&班级名字 isClass(sessionKey) { var _this = this; wx.request({ url: app.globalData.publicUrl2 + '/wx/student/selMyClas', method: "post", data: { sessionKey: sessionKey }, success: function (res) { console.log(res, "我是返回是否有班级") if (res.data.code == 0) { _this.setData({ className: res.data.data.clasName, logoImg: res.data.data.logoImg }) } else { wx.showModal({ content: "您当前还没有开放的班级!", showCancel: false, success(res) { if (res.confirm) { wx.switchTab({ url: '../index/index' }) } } }) return false; } } }) }, // 协议是否已同意 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, isNotice: 0 }, success: function (res) { console.log(res, "333333333") if (res.data.code == 0) { if (res.data.list && res.data.list.length !== 0) _this.setData({ notice: res.data.list[0].noticeContent }); } } }) }, gomyNotice() { // if (this.data.notice !== "暂无未读通知") { wx.navigateTo({ url: '../myNotice/myNotice' }) // } }, // // 我的课程 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, "kckckc") _this.setData({ kcArr: res.data.list }); let result = []; if (res.data.list) for (var i = 0; i < res.data.list.length; i++) { result.push({ courseTime: res.data.list[i].courseTime }); } const timesArr = result.map((item) => { return item.courseTime; }); let sfmArr = []; for (let i = 0; i < timesArr.length; i++) { let value = timesArr[i]; const resultValue = _this.handler(value); sfmArr.push({ courseTime: resultValue }) _this.setData({ sfmArr: sfmArr }) } } }) }, handler(value) { //换算为秒 进制1000 const second = Math.floor(value / 1000); //判断是否够1秒 if (second < 1) { return "0秒"; } const secondValue = second % 60; // 秒 const minutes = Math.floor(second / 60); //判断是否够1分钟 if (minutes < 1) { return `${secondValue}秒`; } const minutesValue = minutes % 60; //分 const hours = Math.floor(minutes / 60); //判断是否够1小时 if (hours < 1) { return `${minutesValue}分${secondValue}秒`; } const hoursValue = hours % 60; //小时 return `${hoursValue}时${minutesValue}分${secondValue}秒`; }, 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); } }) } }) } }) } })