system.js 955 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //获取系统信息
  2. function getSystemInfoAsync() {
  3. return new Promise((resolve, reject) => {
  4. uni.getSystemInfo({
  5. success: res => {
  6. resolve(res);
  7. },
  8. fail: err => {
  9. reject(err);
  10. },
  11. complete: () => {},
  12. });
  13. });
  14. }
  15. // 更新系统
  16. function updateVersion() {
  17. const updateManager = wx.getUpdateManager();
  18. updateManager.onCheckForUpdate(function (res) {
  19. // 请求完新版本信息的回调
  20. });
  21. updateManager.onUpdateReady(function () {
  22. wx.showModal({
  23. title: '更新提示',
  24. content: '新版本已经准备好,是否重启应用?',
  25. success(res) {
  26. if (res.confirm) {
  27. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  28. updateManager.applyUpdate();
  29. }
  30. },
  31. });
  32. });
  33. updateManager.onUpdateFailed(function () {
  34. // 新版本下载失败
  35. });
  36. }
  37. export { getSystemInfoAsync, updateVersion };