app.js 917 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. //app.js
  2. App({
  3. onLaunch: function() {
  4. var info = wx.getSystemInfoSync()
  5. this.config.ua = 'ProgramPool#' + info.system + '~' + info.version + '~' + info.SDKVersion + '#100'
  6. this.config.width = info.screenWidth;
  7. this.update();
  8. },
  9. config: {
  10. debug: false,
  11. width: 0,
  12. ua: '',
  13. code: '',
  14. key: '',
  15. loginTime: 0,
  16. },
  17. log: function(text) {
  18. if (this.config.debug) {
  19. console.log(text);
  20. }
  21. },
  22. update: function() {
  23. const updateManager = wx.getUpdateManager();
  24. updateManager.onUpdateReady(function() {
  25. wx.showModal({
  26. title: '更新提示',
  27. content: '新版本已经准备好,是否重启应用?',
  28. success: function(res) {
  29. if (res.confirm) {
  30. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  31. updateManager.applyUpdate()
  32. }
  33. }
  34. })
  35. })
  36. }
  37. })