const systemInfo = wx.getSystemInfoSync();
const {
statusBarHeight,
windowWidth,
windowHeight,
model,
screenHeight,
safeArea,
} = systemInfo;
// 胶囊按钮位置信息
const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
this.globalData.menuButtonInfo = menuButtonInfo;
const {
top,
height,
width
} = menuButtonInfo;
// 导航栏高度 = 状态栏到胶囊的间距(胶囊距上距离-状态栏高度) * 2 + 胶囊高度 + 状态栏高度
this.globalData.navBarHeight =
(top - statusBarHeight) * 2 + height + statusBarHeight;
this.globalData.menuTop = top;
this.globalData.menuHeight = height;
this.globalData.menuWidth = width;
this.globalData.windowWidth = windowWidth;
this.globalData.windowHeight = windowHeight;
this.globalData.screenHeight = screenHeight;
// 判断iphoneX及以上机型
this.globalData.isIphoneX = screenHeight - safeArea.bottom == 34;
// 判断iphone
this.globalData.isIphone = model.indexOf('iPhone') != -1
微信小程序获取一些常用的参数
最新推荐文章于 2024-07-19 14:50:24 发布