index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <van-popup class="upgrade" :show="show" @click-overlay="back">
  3. <view class="upgrade-box d-flex flex-col overflow-hidden">
  4. <view class="overflow-scroll p-md flex-fill">
  5. <view>version:{{ detail.version }}</view>
  6. <view v-html="detail.update_log"></view>
  7. </view>
  8. <view class="d-flex justify-center p-y-md" v-if="load">
  9. <van-circle
  10. :value="progress"
  11. color="#ea3131"
  12. :rate="100"
  13. size="40"
  14. :text="progress + '%'"
  15. />
  16. </view>
  17. <view
  18. v-else-if="detail.url"
  19. class="fn-center p-md bg-theme-1 color-plain"
  20. @click="toUp"
  21. >
  22. 升级
  23. </view>
  24. </view>
  25. </van-popup>
  26. </template>
  27. <script>
  28. import upgrade from "@/plugins/upgrade.js";
  29. export default {
  30. data() {
  31. return {
  32. detail: {
  33. is_must: 1,
  34. },
  35. progress: 0,
  36. load: false,
  37. show: false,
  38. };
  39. },
  40. created() {
  41. this.show = true;
  42. upgrade.isUpdate((data) => {
  43. this.show = true;
  44. if (upgrade.osName() == "Android") {
  45. this.detail = data.android;
  46. } else if (upgrade.osName() == "iOS") {
  47. this.detail = data.ios;
  48. }
  49. });
  50. },
  51. methods: {
  52. async toUp() {
  53. if (upgrade.osName() == "Android") {
  54. let path = await upgrade.downloadFile({
  55. url: this.detail.url,
  56. before: () => {
  57. this.load = true;
  58. this.progress = 0;
  59. },
  60. update: (e) => {
  61. this.progress = e;
  62. },
  63. after() {
  64. this.load = false;
  65. },
  66. });
  67. upgrade.install(path);
  68. } else if (upgrade.osName() == "iOS") {
  69. upgrade.install(this.detail.url);
  70. }
  71. },
  72. back() {
  73. if (this.detail.is_must != 1) {
  74. uni.reLaunch({
  75. url: "/",
  76. });
  77. }
  78. },
  79. },
  80. };
  81. </script>
  82. <style lang="scss" scoped>
  83. /deep/ uni-canvas{
  84. width: 90rpx;
  85. height: 90rpx;
  86. }
  87. /deep/ .uni-cover-view{
  88. font-size: 24rpx;
  89. }
  90. .upgrade {
  91. /deep/ .van-popup {
  92. background-color: transparent !important;
  93. }
  94. }
  95. .upgrade-box {
  96. width: 275px;
  97. height: 350px;
  98. background: #fff url("../../assets/img/shengji.png") no-repeat center top;
  99. background-size: 100% auto;
  100. box-sizing: border-box;
  101. border-radius: 23px;
  102. padding-top: 125px;
  103. overflow: hidden;
  104. }
  105. </style>