silence-update.js 857 B

123456789101112131415161718192021222324252627282930313233
  1. export default function silenceUpdate(data) {
  2. const url = data.edition_url;
  3. uni.downloadFile({
  4. url,
  5. success: res => {
  6. if (res.statusCode === 200) {
  7. plus.runtime.install(
  8. res.tempFilePath, {
  9. force: true //true表示强制安装,不进行版本号的校验;false则需要版本号校验,
  10. },
  11. function() {
  12. uni.showModal({
  13. title: '更新提示',
  14. content: '新版本已经准备好,请重启应用',
  15. showCancel: false,
  16. success: function(res) {
  17. if (res.confirm) {
  18. // console.log('用户点击确定');
  19. uni.setStorageSync("edition_number",data.edition_number);
  20. plus.runtime.restart()
  21. }
  22. }
  23. });
  24. // console.log('install success...');
  25. },
  26. function(e) {
  27. console.error('install fail...');
  28. }
  29. );
  30. }
  31. }
  32. });
  33. }