This commit is contained in:
2025-12-05 15:41:32 +08:00
commit 7339c71fc0
1433 changed files with 37574 additions and 0 deletions

54
app.js Normal file
View File

@@ -0,0 +1,54 @@
// app.js
App({
globalData: {
userInfo: null,
baseUrl: 'https://api.example.com', // API基础地址
token: ''
},
onLaunch() {
// 小程序启动时执行
this.initApp();
},
// 初始化应用
initApp() {
// 获取本地存储的token
const token = wx.getStorageSync('token');
if (token) {
this.globalData.token = token;
}
// 获取系统信息
this.getSystemInfo();
},
// 获取系统信息
getSystemInfo() {
try {
const systemInfo = wx.getSystemInfoSync();
this.globalData.systemInfo = systemInfo;
this.globalData.statusBarHeight = systemInfo.statusBarHeight;
this.globalData.navBarHeight = systemInfo.platform === 'ios' ? 44 : 48;
} catch (e) {
console.error('获取系统信息失败', e);
}
},
// 检查登录状态
checkLogin() {
return !!this.globalData.token;
},
// 设置Token
setToken(token) {
this.globalData.token = token;
wx.setStorageSync('token', token);
},
// 清除Token
clearToken() {
this.globalData.token = '';
wx.removeStorageSync('token');
}
});