This commit is contained in:
2024-01-24 21:26:15 +08:00
parent efc4bff1e0
commit d534334c5c
23 changed files with 411 additions and 763 deletions

View File

@@ -90,6 +90,15 @@
getSign: function (e, t, n) {
return getSign(e, t, n);
},
generateSecureSessionId: function (length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for (var i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
},
request: function (e) {
require("underscore.js");
var t,
@@ -118,9 +127,21 @@
wx.removeStorageSync(u);
}
}
var userInfo = wx.getStorageSync("userInfo") || {};
if (!userInfo.sessionid) {
userInfo.sessionid = util.generateSecureSessionId(32);
wx.setStorageSync("userInfo", userInfo);
}
wx.request(
(_defineProperty((t = { url: i, data: e.data ? e.data : {}, header: e.header ? e.header : {}, method: e.method ? e.method : "GET", }),
"header", { "content-type": "application/json", "token": wx.getStorageSync("userInfo").sessionid }
"header", {
"content-type": "application/json",
"token": userInfo.sessionid
}
),
_defineProperty(t, "success", function (t) {
@@ -189,10 +210,7 @@
method: "POST",
cachetime: 0,
success: function (e) {
e.data.code == 200 ||
((n.memberInfo = e.data.data),
wx.setStorageSync("userInfo", n)),
"function" == typeof t && t(n);
e.data.code == 200 || ((n.memberInfo = e.data.data), wx.setStorageSync("userInfo", n)), "function" == typeof t && t(n);
},
});
},
@@ -239,17 +257,10 @@
a = wx.getStorageSync("userInfo") || {};
a.sessionid ? util.checkSession({
success: function () {
t
? util.upadteUser(t, function (t) {
"function" == typeof e && e(t);
})
: "function" == typeof e && e(a);
t ? util.upadteUser(t, function (t) { "function" == typeof e && e(t); }) : "function" == typeof e && e(a);
},
fail: function () {
(a.sessionid = ""),
console.log("relogin"),
wx.removeStorageSync("userInfo"),
n();
(a.sessionid = ""), console.log("relogin"), wx.removeStorageSync("userInfo"), n();
},
}) : n();
},