<template>
|
<view class="pages-my-version-update">
|
<view class="group">
|
<view class="item">
|
<view>自动更新</view>
|
<view class="right"></view>
|
<switch :checked="autoUpdate" @change="switchChangeAutoUpdate" />
|
</view>
|
|
</view>
|
<view class="tip">
|
开启后,设备将在2:00-6:00自动更新软件版本
|
</view>
|
<view class="group" v-if="newPack.size > 0">
|
<view class="item big-text ">
|
可更新版本{{newPack.version}}
|
</view>
|
<view class="item gray-text">
|
{{newVersionSize}}
|
</view>
|
<view class="item">
|
有更新的版本{{newPack.version}}
|
</view>
|
<view class="item">
|
当前版本为{{appVersion}}
|
</view>
|
</view>
|
<view class="no-version gray-text" v-else>
|
<uni-icons type="upload-filled" size="150" color="#888"></uni-icons>
|
当前为最新版本{{appVersion}}
|
</view>
|
|
<view class="button-group" v-if="newPack.size > 0">
|
<a-button type="primary" class="button" @click="clickNowUpdate">现在更新</a-button>
|
</view>
|
</view>
|
</template>
|
<script>
|
import {
|
session,
|
showToast,
|
showModal
|
} from "@/comm/utils.js"
|
import {
|
Button
|
} from 'antd-mobile-vue-next'
|
export default {
|
name: "PagesMyVersionUpdate",
|
components: {
|
'a-button': Button
|
},
|
data() {
|
return {
|
autoUpdate:false,
|
appVersion: "1.0.0",
|
newPack:{}
|
// newPack: {
|
// version: "1.0.0",
|
// size: 200 * 1024 * 1024,
|
// }
|
}
|
},
|
onLoad() {
|
this.loadData()
|
|
},
|
computed: {
|
newVersionSize() {
|
const packSize = this.newPack?.size || 0
|
let size = 0
|
if (packSize < 1024) {
|
size = Math.round(packSize * 100)
|
return `${size/100} KB`
|
} else if (packSize < 1024 * 1024) {
|
size = Math.round(packSize * 100 / 1024)
|
return `${size/100} MB`
|
} else {
|
size = Math.round(packSize * 100 / (1024 * 1024 * 1024))
|
return `${size/100} GB`
|
}
|
}
|
|
},
|
methods: {
|
setData(obj) {
|
let that = this;
|
let keys = [];
|
let val, data;
|
|
Object.keys(obj).forEach(function(key) {
|
keys = key.split(".");
|
val = obj[key];
|
data = that.$data;
|
keys.forEach(function(key2, index) {
|
if (index + 1 == keys.length) {
|
that.$set(data, key2, val);
|
} else {
|
if (!data[key2]) {
|
that.$set(data, key2, {});
|
}
|
}
|
data = data[key2];
|
});
|
});
|
},
|
loadData() {
|
|
this.autoUpdate = session.getValue("auto_update") ? true :false
|
const _this = this
|
// #ifdef APP-PLUS
|
plus.runtime.getProperty(plus.runtime.appid, (info) => {
|
// console.log(info);
|
_this.setData({
|
appVersion: info.version
|
})
|
});
|
//#endif
|
},
|
|
|
switchChangeAutoUpdate(e) {
|
this.autoUpdate = e.detail.value
|
session.setValue("auto_update", this.autoUpdate ? 1 :0)
|
},
|
|
clickNowUpdate() {
|
|
},
|
|
}
|
}
|
</script>
|
|
<style lang="scss">
|
.pages-my-version-update {
|
display: flex;
|
width: 750rpx;
|
height: 100vh;
|
flex-direction: column;
|
|
.group {
|
width: calc(100% - 40rpx);
|
border: 2rpx solid #ccc;
|
background-color: #fff;
|
border-radius: 20rpx;
|
margin: 20rpx;
|
padding: 0 10rpx;
|
display: flex;
|
flex-direction: column;
|
|
.item {
|
width: 100%;
|
padding: 20rpx 10rpx;
|
display: flex;
|
flex-direction: row;
|
align-items: center;
|
|
.right {
|
flex: 1;
|
text-align: right;
|
color: #888;
|
}
|
}
|
|
|
}
|
.tip{
|
color: #888;
|
padding: 10rpx;
|
margin-left: 50rpx;
|
}
|
.gray-text {
|
color: #888;
|
}
|
|
.big-text {
|
font-size: 40rpx;
|
}
|
.no-version{
|
margin: auto;
|
display: flex;
|
flex-direction: column;
|
}
|
|
.button-group {
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
flex-direction: column;
|
font-size: 30rpx !important;
|
|
.am-button {
|
border-radius: 30px;
|
}
|
|
}
|
|
.button {
|
margin: auto;
|
margin-top: 20rpx;
|
border-radius: 4rpx;
|
width: 500rpx;
|
}
|
|
|
}
|
</style>
|