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