index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import common from '../../utils/util';
  2. import server from '../../utils/main';
  3. const app = getApp()
  4. Page({
  5. data: {
  6. version: app.globalData.version,
  7. FileUrl: app.globalData.fileUrl,
  8. },
  9. onLoad: function () {
  10. this.setData({
  11. Containnerheight: server.getWindowHeight(),
  12. });
  13. this.updateProgram();
  14. },
  15. updateProgram: function () {
  16. if (wx.canIUse("getUpdateManager")) {
  17. const updateManager = wx.getUpdateManager();
  18. updateManager.onCheckForUpdate(function (res) {
  19. // 请求完新版本信息的回调
  20. console.log(res.hasUpdate)
  21. });
  22. updateManager.onUpdateReady(function () {
  23. wx.showModal({
  24. title: '更新提示',
  25. content: '新版本已经准备好,是否重启应用?',
  26. success: function (res) {
  27. if (res.confirm) {
  28. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  29. updateManager.applyUpdate()
  30. }
  31. }
  32. });
  33. });
  34. }
  35. },
  36. onShareAppMessage: function () {
  37. return {
  38. title: '',
  39. path: 'pages/index/index',
  40. success: function (res) {
  41. },
  42. fail: function (err) {
  43. console.log(err);
  44. },
  45. complete: function (res) {
  46. console.log(res);
  47. },
  48. }
  49. },
  50. })