app.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. autoRefreshTime:5000,
  50. specialProject:["VOTn11010802592ab7d57ca79b47ee95a0b9eb1cd6a902"],
  51. StatusBar: null,
  52. Custom: null,
  53. CustomBar: null,
  54. screenHeight: null,
  55. windowWidth: null,
  56. userInfo: null,
  57. hasUserInfo:false,
  58. openId:null,
  59. userId:null,
  60. projectId:"",
  61. tenantId:"",
  62. remote:false,
  63. tenants:[],
  64. projectName:null,
  65. topSpace:null,
  66. changeTenantId:false,
  67. goHome:false,
  68. picInitUrl:"../../static/images/initpic.png",
  69. imgbaseUrl:"http://api.sagacloud.cn/dp-auxiliary/image-service/common/image_get?systemId=dataPlatform&key=",
  70. envNamelist:{
  71. // temperature:{
  72. // name:"温度",
  73. // unit:"°C",
  74. // funcid:"Tdb"
  75. // imgSrc:"../../static/images/Temp.png"
  76. // },
  77. humidity:{
  78. name:"湿度",
  79. localName:"湿度",
  80. unit:"%",
  81. funcid:"RH",
  82. imgSrc:"../../static/images/RH.png"
  83. },
  84. co2:{
  85. name:"CO₂",
  86. unit:"ppm",
  87. localName:"CO₂",
  88. funcid:"CO2",
  89. imgSrc:"../../static/images/CO2.png"
  90. },
  91. pm25:{
  92. name:"PM2.5",
  93. localName:"PM2.5",
  94. unit:"μg/m³",
  95. funcid:"PM2d5",
  96. baseNumer:1000,
  97. imgSrc:"../../static/images/PM2.5.png"
  98. },
  99. hcho:{
  100. name:"甲醛",
  101. localName:"甲醛",
  102. unit:"mg/m³",
  103. funcid:"HCHO",
  104. imgSrc:"../../static/images/HCHO.png"
  105. },
  106. },
  107. }
  108. })