app.js 937 B

123456789101112131415161718192021222324252627282930
  1. // app.js
  2. App({
  3. onLaunch() {
  4. /* 计算tabbar+iphone安全距离 tabbar页面+100rpx*/
  5. let safeAreaBottom = 0,
  6. capsule = wx.getMenuButtonBoundingClientRect(),
  7. height = 200,
  8. that = this;
  9. wx.getSystemInfo({
  10. success(res) {
  11. //计算底部安全距离高度
  12. safeAreaBottom += res.screenHeight - res.safeArea.height;
  13. //计算自定义导航的高度
  14. height = capsule.height + res.statusBarHeight + (capsule.top - res.statusBarHeight) + 8;
  15. that.globalData.safeAreaBottom = safeAreaBottom;
  16. //判断是否为平板
  17. if (res.model.slice(0, 4) == "iPad") return that.globalData.myNavBorHeight = height;
  18. that.globalData.myNavBorHeight = height * 2;
  19. }
  20. })
  21. //返回数据
  22. },
  23. globalData: {
  24. myNavBorHeight: null, //自定义头部导航高度
  25. safeAreaBottom: 0, //底部安全距离
  26. accountList: [], //角色列表
  27. }
  28. })