upApp.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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, {}, (e) => {
  44. plus.runtime.restart();
  45. console.log(e)
  46. }, (e) => {
  47. uni.showModal({
  48. content: "update error [" +
  49. e
  50. .code + "]:" + e
  51. .message,
  52. showCancel: false,
  53. });
  54. });
  55. } else {
  56. uni.showModal({
  57. content: "api error update fail!",
  58. showCancel: false,
  59. });
  60. }
  61. }
  62. });
  63. downloadTask.onProgressUpdate((res) => {
  64. console.log(res.progress);
  65. that.schedule = res.progress
  66. });
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. .content {
  73. position: absolute;
  74. height: 100%;
  75. width: 100%;
  76. background-color: #7f7f7f;
  77. display: flex;
  78. justify-content: center;
  79. align-items: center;
  80. }
  81. .up-wrap {
  82. width: 522rpx;
  83. height: 499rpx;
  84. background: #FFFFFF;
  85. border-radius: 28rpx;
  86. position: relative;
  87. .upapp-bg {
  88. width: 345rpx;
  89. height: 307rpx;
  90. position: absolute;
  91. left: 0;
  92. right: 0;
  93. top: -150rpx;
  94. margin: auto;
  95. }
  96. .tit {
  97. margin-top: 190rpx;
  98. font-size: 39rpx;
  99. font-weight: 500;
  100. color: #FF443F;
  101. text-align: center;
  102. }
  103. .val {
  104. font-size: 31rpx;
  105. font-weight: 500;
  106. color: #A5A5A5;
  107. text-align: center;
  108. margin-top: 10rpx;
  109. }
  110. .btn444 {
  111. width: 357rpx;
  112. height: 83rpx !important;
  113. background: #FF443F;
  114. border-radius: 41rpx;
  115. text-align: center;
  116. line-height: 83rpx;
  117. font-size: 34rpx;
  118. font-weight: 500;
  119. color: #FFFFFF;
  120. margin: 10rpx auto 0;
  121. }
  122. }
  123. </style>