app.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. // app.js
  2. App({
  3. onLaunch() {
  4. // 展示本地存储能力
  5. const logs = wx.getStorageSync('logs') || []
  6. logs.unshift(Date.now())
  7. wx.setStorageSync('logs', logs)
  8. // 登录
  9. wx.login({
  10. success: res => {
  11. // 发送 res.code 到后台换取 openId, sessionKey, unionId
  12. wx.setStorageSync('wxCode', res.code)
  13. }
  14. });
  15. //获取胶囊按钮位置信息
  16. wx.getSystemInfo({
  17. success: e => {
  18. this.globalData.StatusBar = e.statusBarHeight;
  19. let capsule = wx.getMenuButtonBoundingClientRect();
  20. if (capsule) {
  21. this.globalData.Custom = capsule;
  22. this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
  23. } else {
  24. this.globalData.CustomBar = e.statusBarHeight + 50;
  25. }
  26. }
  27. });
  28. },
  29. globalData: {
  30. userInfo: null
  31. }
  32. })