init
This commit is contained in:
56
app.js
Normal file
56
app.js
Normal file
@@ -0,0 +1,56 @@
|
||||
// app.js
|
||||
App({
|
||||
onLaunch() {
|
||||
// const { statusBarHeight, platform, windowHeight }=wx.getSystemInfoSync()
|
||||
// const { top, height } = wx.getMenuButtonBoundingClientRect()
|
||||
// // 状态栏高度
|
||||
// wx.setStorageSync('statusBarHeight', statusBarHeight)
|
||||
// // 屏幕高度
|
||||
// wx.setStorageSync('windowHeight', windowHeight)
|
||||
// // 胶囊按钮高度 一般是32 如果获取不到就使用32
|
||||
// wx.setStorageSync('menuButtonHeight', height ? height : 32)
|
||||
// // 判断胶囊按钮信息是否成功获取
|
||||
// if (top && top !== 0 && height && height !== 0) {
|
||||
// const navigationBarHeight = (top - statusBarHeight) * 2 + height
|
||||
// // 导航栏高度
|
||||
// wx.setStorageSync('navigationBarHeight', navigationBarHeight)
|
||||
// } else {
|
||||
// wx.setStorageSync('navigationBarHeight', platform === 'android' ? 48 : 40)
|
||||
// }
|
||||
|
||||
|
||||
|
||||
const that = this;
|
||||
// 获取系统信息
|
||||
const systemInfo = wx.getSystemInfoSync();
|
||||
// 胶囊按钮位置信息
|
||||
const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
|
||||
// 导航栏高度 = 状态栏高度 + 44
|
||||
that.globalData.navBarHeight = systemInfo.statusBarHeight + 44;
|
||||
that.globalData.menuRight = systemInfo.screenWidth - menuButtonInfo.right;
|
||||
that.globalData.menuTop = menuButtonInfo.top;
|
||||
that.globalData.menuHeight = menuButtonInfo.height;
|
||||
|
||||
|
||||
|
||||
// wx.loadFontFace({
|
||||
// family: 'YouSheBiaoTiHei',
|
||||
// source: 'url("https://19year.cn/YouSheBiaoTiHei-2.ttf")',
|
||||
// success: res => {
|
||||
// console.log('font load success', res)
|
||||
// },
|
||||
// fail: err => {
|
||||
// console.log('font load fail', err)
|
||||
// }
|
||||
// })
|
||||
},
|
||||
// 数据都是根据当前机型进行计算,这样的方式兼容大部分机器
|
||||
globalData: {
|
||||
navBarHeight: 0, // 导航栏高度
|
||||
menuRight: 0, // 胶囊距右方间距(方保持左、右间距一致)
|
||||
menuTop: 0, // 胶囊距顶部间距
|
||||
menuHeight: 0, // 胶囊高度(自定义内容可与胶囊高度保证一致)
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
Reference in New Issue
Block a user