JMApp/app.js
XiaoMo fec4276cc8 feat(设备管理): 重构设备数据管理逻辑,统一使用deviceData对象
- 将分散的设备信息存储改为统一的deviceData对象
- 更新相关API请求参数传递方式
- 增加设备类型支持,动态构建API路径
- 修复设备信息初始化问题,确保数据一致性
2025-06-25 12:43:31 +08:00

85 lines
2.6 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: "",
deviceData: {
type: 'machine',
devicecode: '',
options: {}
},
protocol: {},
tips: ""
}
});