app.js 834 B

12345678910111213141516171819202122232425262728293031323334353637
  1. //app.js
  2. import {
  3. wxSetSessionKey,
  4. } from "./utils/wxUtils"
  5. App({
  6. onLaunch: function () {
  7. const updateManager = wx.getUpdateManager()
  8. updateManager.onCheckForUpdate(function (res) {
  9. // 请求完新版本信息的回调
  10. })
  11. updateManager.onUpdateReady(function () {
  12. wx.showModal({
  13. title: '更新提示',
  14. content: '新版本已经准备好,是否重启应用?',
  15. success: function (res) {
  16. if (res.confirm) {
  17. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  18. updateManager.applyUpdate()
  19. }
  20. }
  21. })
  22. })
  23. updateManager.onUpdateFailed(function () {
  24. // 新版本下载失败
  25. })
  26. wx.cloud.init({
  27. traceUser: true
  28. })
  29. wxSetSessionKey()
  30. this.globalData = {}
  31. },
  32. })