You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.2 KiB
34 lines
1.2 KiB
4 months ago
|
// app.js
|
||
|
App({
|
||
|
onLaunch: function (options) {
|
||
|
//获取设备顶部窗口的高度(不同设备窗口高度不一样,根据这个来设置自定义导航栏的高度)
|
||
|
//这个最初我是在组件中获取,但是出现了一个问题,当第一次进入小程序时导航栏会把
|
||
|
//页面内容盖住一部分,当打开调试重新进入时就没有问题,这个问题弄得我是莫名其妙
|
||
|
//虽然最后解决了,但是花费了不少时间
|
||
|
let code = [1011, 1017, 1025, 1047, 1124, 1001, 1038, 1041, 1089, 1090, 1104, 1131, 1187];
|
||
|
if (code.includes(options.scene)) {
|
||
|
this.globalData.share = true
|
||
|
} else {
|
||
|
this.globalData.share = false
|
||
|
}
|
||
|
const menuButtonInfo = wx.getMenuButtonBoundingClientRect()
|
||
|
wx.getSystemInfo({
|
||
|
success: (res) => {
|
||
|
this.globalData.height = res.statusBarHeight
|
||
|
this.globalData.deviceInfo.statusHeight = res.statusBarHeight
|
||
|
this.globalData.deviceInfo.navigationHeight = menuButtonInfo.height + (menuButtonInfo.top - res.statusBarHeight) * 2
|
||
|
}
|
||
|
})
|
||
|
wx.hideTabBar()
|
||
|
},
|
||
|
globalData: {
|
||
|
userInfo: null,
|
||
|
deviceInfo: {
|
||
|
statusHeight: 19,
|
||
|
navigationHeight: 40
|
||
|
},
|
||
|
selected: 0
|
||
|
},
|
||
|
|
||
|
})
|