update.js 674 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. module.exports = {
  2. update: update
  3. }
  4. var isShowed = false;
  5. //检测版本是否更新
  6. function update() {
  7. if (isShowed) {
  8. return;
  9. }
  10. //检测版本更新
  11. const manager = wx.getUpdateManager();
  12. //检测版本是否更新
  13. manager.onCheckForUpdate(function (e) {
  14. });
  15. //版本更新
  16. manager.onUpdateReady(function (e) {
  17. isShowed = true;
  18. wx.showModal({
  19. title: '更新提示',
  20. content: '新版本已准备好,是否重启应用?',
  21. success: function (res) {
  22. if (res.confirm) {
  23. manager.applyUpdate();
  24. }
  25. }
  26. });
  27. });
  28. //版本更新失败
  29. manager.onUpdateFailed(function (e) {
  30. });
  31. };