app.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //app.js
  2. const AUTH = require('utils/auth')
  3. App({
  4. initUiGlobal() {
  5. wx.getSystemInfo({
  6. success: e => {
  7. const { statusBarHeight: StatusBar, screenHeight, windowWidth } = e
  8. this.globalData.StatusBar = StatusBar
  9. this.globalData.screenHeight = screenHeight
  10. this.globalData.windowWidth = windowWidth
  11. const capsule = wx.getMenuButtonBoundingClientRect()
  12. if (capsule) {
  13. this.globalData.Custom = capsule
  14. this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight
  15. } else {
  16. this.globalData.CustomBar = StatusBar + 50
  17. }
  18. console.log(capsule,"hah",this.globalData.StatusBar,"18")
  19. }
  20. })
  21. },
  22. checkUpdate(){
  23. const updateManager = wx.getUpdateManager()
  24. updateManager.onCheckForUpdate(function (res) {
  25. // 请求完新版本信息的回调
  26. console.log(res.hasUpdate)
  27. })
  28. updateManager.onUpdateReady(function () {
  29. wx.showModal({
  30. title: '更新提示',
  31. content: '新版本已经准备好,是否重启应用?',
  32. success(res) {
  33. if (res.confirm) {
  34. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  35. updateManager.applyUpdate()
  36. }
  37. }
  38. })
  39. })
  40. updateManager.onUpdateFailed(function () {
  41. // 新版本下载失败
  42. })
  43. },
  44. onLaunch:async function () {
  45. this.initUiGlobal();
  46. this.checkUpdate();
  47. },
  48. globalData: {
  49. StatusBar: null,
  50. Custom: null,
  51. CustomBar: null,
  52. screenHeight: null,
  53. windowWidth: null,
  54. userInfo: null,
  55. hasUserInfo:false,
  56. openId:null,
  57. userId:null,
  58. projectId:"",
  59. tenantId:"",
  60. remote:false,
  61. tenants:[],
  62. projectName:null,
  63. topSpace:null,
  64. changeTenantId:false,
  65. goHome:false,
  66. picInitUrl:"../../static/images/initpic.png",
  67. imgbaseUrl:"http://api.sagacloud.cn/dp-auxiliary/image-service/common/image_get?systemId=dataPlatform&key=",
  68. envNamelist:{
  69. // temperature:{
  70. // name:"温度",
  71. // unit:"°C",
  72. // funcid:"Tdb"
  73. // imgSrc:"../../static/images/Temp.png"
  74. // },
  75. humidity:{
  76. name:"湿度",
  77. localName:"湿度",
  78. unit:"%",
  79. funcid:"RH",
  80. imgSrc:"../../static/images/RH.png"
  81. },
  82. co2:{
  83. name:"CO₂",
  84. unit:"ppm",
  85. localName:"CO₂",
  86. funcid:"CO2",
  87. imgSrc:"../../static/images/CO2.png"
  88. },
  89. pm25:{
  90. name:"PM2.5",
  91. localName:"PM2.5",
  92. unit:"μg/m³",
  93. funcid:"PM2d5",
  94. baseNumer:1000,
  95. imgSrc:"../../static/images/PM2.5.png"
  96. },
  97. hcho:{
  98. name:"甲醛",
  99. localName:"甲醛",
  100. unit:"mg/m³",
  101. funcid:"HCHO",
  102. imgSrc:"../../static/images/HCHO.png"
  103. },
  104. },
  105. }
  106. })