app.ts 779 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // app.ts
  2. App({
  3. globalData: {
  4. /// iPhone底部安全区域
  5. safeBottom: 0,
  6. /// 窗口高度
  7. windowHeight: 0
  8. },
  9. onLaunch() {
  10. /// 获取iPhone底部安全区域
  11. wx.getSystemInfo({
  12. success: res=> {
  13. console.log(res)
  14. this.globalData.safeBottom = res.screenHeight-res.safeArea.bottom
  15. this.globalData.windowHeight = res.windowHeight
  16. },
  17. fail(err) {
  18. console.log(err)
  19. }
  20. })
  21. // 展示本地存储能力
  22. const logs = wx.getStorageSync('logs') || []
  23. logs.unshift(Date.now())
  24. wx.setStorageSync('logs', logs)
  25. // 登录
  26. wx.login({
  27. success: res => {
  28. console.log(res.code)
  29. // 发送 res.code 到后台换取 openId, sessionKey, unionId
  30. },
  31. })
  32. },
  33. })