JMApp/app.js
XiaoMo 93a3cb9b58 fix: 更新会话cookie键名并添加随机会话生成
更新登录请求中的cookie键名从"_miucms_session"到"XPHP_SESSION_ID"
在应用启动时生成40位随机字符串作为会话ID
2025-06-24 18:53:41 +08:00

82 lines
2.5 KiB
JavaScript

var t = require("./utils/login.js");
// 引入
require("./utils/xstat.js");
function generateRandomCode(length) {
let result = '';
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const charactersLength = characters.length;
for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
App({
xstatConfig: {
appKey: wx.getAccountInfoSync().miniProgram.appId, // 自动获取 小程序appid
debug: true, //是否打开调试模式
// 上报地址
LOG_URL: 'https://t-jm.v0750.com/v2/stat/send',
},
onLaunch: function(e) {
// 40 位的随机码
if (!wx.getStorageSync("session")) {
wx.setStorageSync("session", generateRandomCode(40));
}
console.log("options", e), this.globalData.options = e, t.getLogin(this, !0);
try {
var o = wx.getSystemInfoSync();
this.computeNavigateBarHeight(o);
} catch (t) {
this.setData({
windowHeight: 812,
totalTopHeight: 68,
statusBarHeight: 20,
titleBarHeight: 48
});
}
},
onShow: function(e) {
console.log("onshowwwwwwwoptions", e);
var o = e.scene;
[ 1011, 1012, 1013, 1024, 1047, 1048, 1049 ].indexOf(o) > -1 && (console.log("扫码进入的"),
t.getDevicecode(this, e));
},
computeNavigateBarHeight: function(t) {
var e = wx.getMenuButtonBoundingClientRect(), o = e.bottom + 6, i = t.windowHeight, n = e.top, a = e.height;
i < 10 && (i = t.windowHeight, a = o - (n = t.statusBarHeight)), o < 10 && (console.log("更新"),
o = 68, /iPhone X|MI 8|PAAM00|COR-AL00/.test(t.model) ? o = 88 : /iPhone/.test(t.model) && (o = 64));
var s = t.windowWidth;
this.globalData.screen_data = {
windowWidth: s,
windowHeight: i,
totalTopHeight: o,
statusBarHeight: n,
titleBarHeight: a,
titleWidth: e.width
};
},
globalData: {
userInfo: null,
canGetData: !1,
screen_data: {},
options: {},
route: {},
user: {},
isUserAuthorization: 0,
servicetel: "",
code: "",
isneedUpload: !1,
needJumpUrl: !1,
devicecode: "",
protocol: {},
tips: ""
}
});