app.js 2.7 KB

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