app.ts 823 B

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