app.js 2.8 KB

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