- app.js 通过 wx.getSystemInfoSync 获取 statusBarHeight 存入 globalData
- 所有12个自定义导航页面的 JS 读取 statusBarHeight
- WXML 通过 style="padding-top: {{statusBarHeight + 24}}px" 动态适配
- 普通手机和灵动岛手机都能正确显示
27 行
576 B
JavaScript
27 行
576 B
JavaScript
var app = getApp()
|
|
|
|
Page({
|
|
data: {
|
|
statusBarHeight: 44,
|
|
loading: false
|
|
},
|
|
|
|
onLoad: function () {
|
|
var app = getApp()
|
|
this.setData({ statusBarHeight: app.globalData.statusBarHeight })
|
|
},
|
|
|
|
onLogin: function () {
|
|
var self = this
|
|
self.setData({ loading: true })
|
|
|
|
app.doLogin().then(function () {
|
|
self.setData({ loading: false })
|
|
wx.switchTab({ url: '/pages/index/index' })
|
|
}).catch(function (err) {
|
|
self.setData({ loading: false })
|
|
wx.showToast({ title: err.message || '登录失败', icon: 'none' })
|
|
})
|
|
}
|
|
})
|