app.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //app.js
  2. App({
  3. onLaunch: function () {
  4. // 展示本地存储能力
  5. var logs = wx.getStorageSync('logs') || []
  6. logs.unshift(Date.now())
  7. wx.setStorageSync('logs', logs)
  8. this.getNaviInfo()
  9. },
  10. // 获取菜单按钮(右上角胶囊按钮)的布局位置信息
  11. getNaviInfo: function() {
  12. let menuRect = wx.getMenuButtonBoundingClientRect();
  13. wx.getSystemInfo({
  14. success: (res) => {
  15. let naviInfo = this.globalData.naviInfo;
  16. naviInfo.naviHeight = res.statusBarHeight + menuRect.height + (menuRect.top - res.statusBarHeight) * 2;
  17. naviInfo.naviWidth = res.windowWidth;
  18. naviInfo.menuTop = menuRect.top;
  19. naviInfo.menuHeight = menuRect.height;
  20. naviInfo.menuWidth = menuRect.width;
  21. naviInfo.menuRight = res.width - menuRect.width - menuRect.left;
  22. naviInfo.statusBarHeight = res.statusBarHeight;
  23. },
  24. })
  25. },
  26. globalData: {
  27. userInfo: null,
  28. o2oa: {
  29. centerHost: "43.154.125.245",
  30. centerContext: "/x_program_center",
  31. centerPort: 8089,
  32. httpProtocol: "http"
  33. },
  34. naviInfo: {
  35. naviHeight: 0,
  36. naviWidth: 0,
  37. menuTop: 0,
  38. menuHeight: 0,
  39. menuWidth: 0,
  40. menuRight: 0,
  41. statusBarHeight: 0,
  42. }
  43. }
  44. })