app.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // app.js
  2. import {
  3. AllSDK
  4. } from "./tqlsdk/allSDK"
  5. App({
  6. globalData: {
  7. statusBarHeight: 0,
  8. // 导航栏高度
  9. navigationBarHeight: 0,
  10. // 内容区高度
  11. contentAreaHeight: 0,
  12. // iOS底部控制条高度
  13. bottomControlStripHeight: 0,
  14. // canvas 宽
  15. canvasWidth: 0,
  16. // canvas 高
  17. canvasHeight: 0,
  18. tqlSDK: null,
  19. deviceId: null,
  20. deviceName: null,
  21. deviceMac: null,
  22. SrcExUrl: 'https://scratch.baca-ai.com'
  23. },
  24. onLaunch() {
  25. // 展示本地存储能力
  26. this.globalData.tqlSDK = new AllSDK(0)
  27. // chende start
  28. wx.getSystemInfo({
  29. success: res => {
  30. console.log('系统信息', res)
  31. const {
  32. // 状态栏高度
  33. statusBarHeight,
  34. safeArea: {
  35. // 安全区域高度
  36. bottom: safeAreaBottom
  37. },
  38. // 屏幕高度
  39. screenHeight
  40. } = res
  41. const {
  42. // 顶部胶囊按钮高度
  43. height: topMenuButtonHeight,
  44. // 顶部胶囊按钮顶部距离
  45. top: topMenuButtonTop,
  46. } = wx.getMenuButtonBoundingClientRect()
  47. // 系统状态栏高度
  48. this.globalData.statusBarHeight = statusBarHeight
  49. // 计算顶部导航栏高度
  50. this.globalData.navigationBarHeight = topMenuButtonHeight + (topMenuButtonTop - statusBarHeight) * 2
  51. // 计算iOS底部控制条高度
  52. this.globalData.bottomControlStripHeight = screenHeight - safeAreaBottom
  53. // 计算内容区高度
  54. this.globalData.contentAreaHeight = screenHeight - statusBarHeight - this.globalData.navigationBarHeight - this.globalData.bottomControlStripHeight
  55. console.log('全局数据', this.globalData)
  56. }
  57. })
  58. // chende end
  59. wx.getSystemInfo({
  60. success: res => {
  61. let modelmes = res.model;
  62. // console.log('系统信息', res);
  63. if (modelmes.search('iPhone X') != -1) {
  64. console.log(modelmes.search('iPhone X') != -1);
  65. this.globalData.isIphoneX = true
  66. }
  67. wx.setStorageSync('modelmes', modelmes)
  68. }
  69. })
  70. },
  71. })