|
@@ -1,4 +1,5 @@
|
|
const app = require('../../utils/util.js');
|
|
const app = require('../../utils/util.js');
|
|
|
|
+const tools = require('../../utils/tools.js');
|
|
// import WxValidate from '../../utils/WxValidate';
|
|
// import WxValidate from '../../utils/WxValidate';
|
|
Page({
|
|
Page({
|
|
data: {
|
|
data: {
|
|
@@ -80,119 +81,118 @@ Page({
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
- onChange(event) {
|
|
|
|
- var _this = this;
|
|
|
|
|
|
+ async onChange(event) {
|
|
|
|
+ // var _this = this;
|
|
if (event.detail.index == 1) {
|
|
if (event.detail.index == 1) {
|
|
- 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);
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ 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 {
|
|
} else {
|
|
- 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);
|
|
|
|
- }
|
|
|
|
|
|
+ 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);
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ // },
|
|
|
|
+ // 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);
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
}
|
|
}
|
|
-
|
|
|
|
- // wx.showToast({
|
|
|
|
- // title: `切换到标签 ${event.detail.name}`,
|
|
|
|
- // icon: 'none',
|
|
|
|
- // });
|
|
|
|
},
|
|
},
|
|
meRead(sessionKey, noticeId) {
|
|
meRead(sessionKey, noticeId) {
|
|
var _this = this;
|
|
var _this = this;
|
|
@@ -209,116 +209,120 @@ Page({
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
- btn(e) {
|
|
|
|
|
|
+ async btn(e) {
|
|
console.log(e.currentTarget.dataset.item.noticeId, "99999")
|
|
console.log(e.currentTarget.dataset.item.noticeId, "99999")
|
|
let noticeId = e.currentTarget.dataset.item.noticeId;
|
|
let noticeId = e.currentTarget.dataset.item.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);
|
|
|
|
- }
|
|
|
|
|
|
+ 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);
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ // },
|
|
|
|
+ // 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);
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
},
|
|
},
|
|
- onLoad: function () {
|
|
|
|
- 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);
|
|
|
|
- }
|
|
|
|
|
|
+ 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);
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ // },
|
|
|
|
+ // 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);
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
}
|
|
}
|
|
})
|
|
})
|