文件
jw-beauty/miniprogram/app.js
T
Guoguo 52cb1f72dc fix: resolve header overlap on Dynamic Island iPhones
- app.js 通过 wx.getSystemInfoSync 获取 statusBarHeight 存入 globalData
- 所有12个自定义导航页面的 JS 读取 statusBarHeight
- WXML 通过 style="padding-top: {{statusBarHeight + 24}}px" 动态适配
- 普通手机和灵动岛手机都能正确显示
2026-04-24 22:20:10 +08:00

55 行
1.2 KiB
JavaScript

var http = require('./utils/request')
App({
globalData: {
userInfo: null,
userId: null,
connectedDevice: null,
currentTreatment: null,
statusBarHeight: 44
},
onLaunch: function () {
var sysInfo = wx.getSystemInfoSync()
this.globalData.statusBarHeight = sysInfo.statusBarHeight || 44
if (!wx.cloud) {
console.error('请使用 2.2.3 或以上的基础库以使用云能力')
return
}
wx.cloud.init({
traceUser: true
})
this.checkLogin()
},
checkLogin: function () {
var token = wx.getStorageSync('token')
if (!token) {
this.globalData.userInfo = null
return
}
this.loadProfile()
},
loadProfile: function () {
var self = this
http.get('/api/v1/user/profile').then(function (profile) {
self.globalData.userInfo = profile
self.globalData.userId = String(profile.user_id)
}).catch(function () {
wx.removeStorageSync('token')
})
},
doLogin: function () {
return http.post('/api/v1/auth/login', {}).then(function (data) {
wx.setStorageSync('token', data.token)
var app = getApp()
app.globalData.userInfo = data.user_info
app.globalData.userId = data.user_id
return data
})
}
})