app.js 701 B

1234567891011121314151617181920212223242526272829
  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. }
  13. })
  14. //获取设备顶部窗口的高度(不同设备窗口高度不一样,根据这个来设置自定义导航栏的高度
  15. wx.getSystemInfo({
  16. success: (res) => {
  17. this.globalData.height = res.statusBarHeight
  18. this.globalData.windowHeight = res.windowHeight
  19. }
  20. })
  21. },
  22. globalData: {
  23. userInfo: null,
  24. height: 0,
  25. windowHeight: 0
  26. }
  27. })