upApp.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view class="content">
  3. <view class="up-wrap">
  4. <image src="../../static/img/upapp.png" mode="" class="upapp-bg"></image>
  5. <view class="tit">
  6. 新版本升级
  7. </view>
  8. <view class="val">
  9. 客户端体验优化
  10. </view>
  11. <view class="btn444" @click="upApp">
  12. {{is_up?(schedule + '%'): '马上更新'}}
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. downurl: '',
  22. schedule: 0,
  23. is_up: false,
  24. }
  25. },
  26. onLoad(opt) {
  27. this.downurl = opt.downurl
  28. },
  29. onShow() {
  30. },
  31. onBackPress() {
  32. return true
  33. },
  34. methods: {
  35. upApp() {
  36. let that = this
  37. that.is_up = true
  38. let downloadTask = uni.downloadFile({
  39. url: that.downurl,
  40. success: (res1) => {
  41. // wgtWaiting.close();
  42. if (res1.statusCode === 200) {
  43. plus.runtime.install(res1.tempFilePath, {}, () => {
  44. plus.runtime.restart();
  45. }, (e) => {
  46. uni.showModal({
  47. content: "update error [" +
  48. e
  49. .code + "]:" + e
  50. .message,
  51. showCancel: false,
  52. });
  53. });
  54. } else {
  55. uni.showModal({
  56. content: "api error update fail!",
  57. showCancel: false,
  58. });
  59. }
  60. }
  61. });
  62. downloadTask.onProgressUpdate((res) => {
  63. console.log(res.progress);
  64. that.schedule = res.progress
  65. });
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang="scss" scoped>
  71. .content {
  72. position: absolute;
  73. height: 100%;
  74. width: 100%;
  75. background-color: #7f7f7f;
  76. display: flex;
  77. justify-content: center;
  78. align-items: center;
  79. }
  80. .up-wrap {
  81. width: 522rpx;
  82. height: 499rpx;
  83. background: #FFFFFF;
  84. border-radius: 28rpx;
  85. position: relative;
  86. .upapp-bg {
  87. width: 345rpx;
  88. height: 307rpx;
  89. position: absolute;
  90. left: 0;
  91. right: 0;
  92. top: -150rpx;
  93. margin: auto;
  94. }
  95. .tit {
  96. margin-top: 190rpx;
  97. font-size: 39rpx;
  98. font-weight: 500;
  99. color: #FF443F;
  100. text-align: center;
  101. }
  102. .val {
  103. font-size: 31rpx;
  104. font-weight: 500;
  105. color: #A5A5A5;
  106. text-align: center;
  107. margin-top: 10rpx;
  108. }
  109. .btn444 {
  110. width: 357rpx;
  111. height: 83rpx !important;
  112. background: #FF443F;
  113. border-radius: 41rpx;
  114. text-align: center;
  115. line-height: 83rpx;
  116. font-size: 34rpx;
  117. font-weight: 500;
  118. color: #FFFFFF;
  119. margin: 10rpx auto 0;
  120. }
  121. }
  122. </style>