const app = require('../../utils/util.js'); const tools = require('../../utils/tools.js'); // import WxValidate from '../../utils/WxValidate'; Page({ data: { active: 0, wdArr: [], ydArr: [], showNull: false, showNull1: false }, getArr(sessionKey) { let _this = this; wx.request({ url: app.globalData.publicUrl3 + '/wx/eduNoticeSee/list', method: "post", data: { sessionKey: sessionKey, isSee: 1, isNotice: 0 }, success: function (res) { if (res.data.code == 0) { if (res.data.list.length !== 0) { _this.setData({ showNull: false, wdArr: res.data.list }) } else { _this.setData({ wdArr: res.data.list, showNull: true }) } } else { _this.setData({ showNull: true }) } }, fail: function () { _this.setData({ showNull: true }) } }) }, getArr1(sessionKey) { let _this = this; wx.request({ url: app.globalData.publicUrl3 + '/wx/eduNoticeSee/list', method: "post", data: { sessionKey: sessionKey, isSee: 0, isNotice: 0 }, success: function (res) { if (res.data.code == 0) { if (res.data.list.length !== 0) { _this.setData({ showNull1: false, ydArr: res.data.list }) } else { _this.setData({ ydArr: res.data.list, showNull1: true }) } } else { _this.setData({ showNull1: true }) } }, fail: function () { _this.setData({ showNull1: true }) } }) }, async onChange(event) { // var _this = this; if (event.detail.index == 1) { const sessionKey = await tools.checkSessionAndLogin(); this.getArr1(sessionKey); // 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.getArr1(sessionKey); // } // }) // } // }) // } else { // _this.getArr1(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.getArr1(sessionKey); // // _this.socketConnect(sessionKey); // } // }) // } // }) // } // }) } else { const sessionKey = await tools.checkSessionAndLogin(); this.getArr(sessionKey); // 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.getArr(sessionKey); // } // }) // } // }) // } else { // _this.getArr(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.getArr(sessionKey); // // _this.socketConnect(sessionKey); // } // }) // } // }) // } // }) } }, meRead(sessionKey, noticeId) { var _this = this; wx.request({ url: app.globalData.publicUrl3 + '/wx/eduNoticeSee/edit', method: "post", data: { sessionKey: sessionKey, isSee: 0, noticeId: noticeId }, success: function (res) { _this.getArr(sessionKey) } }) }, async btn(e) { console.log(e.currentTarget.dataset.item.noticeId, "99999") let noticeId = e.currentTarget.dataset.item.noticeId; const sessionKey = await tools.checkSessionAndLogin(); this.meRead(sessionKey, noticeId); // 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.meRead(sessionKey, noticeId); // } // }) // } // }) // } else { // _this.meRead(sessionKey, noticeId); // } // }, // 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.meRead(sessionKey, noticeId); // // _this.socketConnect(sessionKey); // } // }) // } // }) // } // }) }, async onLoad () { const sessionKey = await tools.checkSessionAndLogin(); this.getArr(sessionKey); // 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.getArr(sessionKey); // } // }) // } // }) // } else { // _this.getArr(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.getArr(sessionKey); // // _this.socketConnect(sessionKey); // } // }) // } // }) // } // }) } })