182 lines
3.8 KiB
Vue
182 lines
3.8 KiB
Vue
<template>
|
|
<view class="content">
|
|
<view class="info">
|
|
<view class="logo">
|
|
<image src="../../static/logo2.png"></image>
|
|
<view>青测</view>
|
|
<text>V{{phoneInfo.info.version}}</text>
|
|
</view>
|
|
<view class="list">
|
|
<view class="item" @click="handleVersion">
|
|
<view class="left">版本更新</view>
|
|
<view class="right">
|
|
<text class="new" v-if="phoneInfo.info.version !== phoneInfo.versionUrl.version">新版本</text>
|
|
<uni-icons type="right"></uni-icons>
|
|
</view>
|
|
</view>
|
|
<view class="item">
|
|
<a href="http://tc.pcxbc.com/technology/privacy_index" class="href">
|
|
<text class="left">隐私协议</text>
|
|
<uni-icons type="right"></uni-icons>
|
|
</a>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<!-- <view class="xieyi">
|
|
<a>《隐私协议》</a>
|
|
</view> -->
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
mapState
|
|
} from "vuex";
|
|
let dtask;
|
|
export default {
|
|
data() {
|
|
return {}
|
|
},
|
|
computed: {
|
|
...mapState(["phoneInfo"]),
|
|
},
|
|
onLoad() {
|
|
console.log("版本号", this.phoneInfo)
|
|
},
|
|
onBackPress() {
|
|
console.log("dtask", dtask)
|
|
if (dtask != undefined) {
|
|
dtask.onProgressUpdate((res) => {
|
|
if (res.progress != 100) {
|
|
dtask.abort();
|
|
}
|
|
});
|
|
}
|
|
},
|
|
methods: {
|
|
handleVersion() {
|
|
let that = this
|
|
if (that.phoneInfo.info.version === that.phoneInfo.versionUrl.version) {
|
|
that.$tools.msg("已经是最新版本了!")
|
|
} else {
|
|
if (that.phoneInfo.platform === 'android') {
|
|
uni.setStorageSync('VERSION', that.phoneInfo.versionUrl.version)
|
|
let showLoading = plus.nativeUI.showWaiting('正在下载')
|
|
dtask = uni.downloadFile({
|
|
url: that.phoneInfo.versionUrl.url,
|
|
success: (downloadRes) => {
|
|
if (downloadRes.statusCode === 200) {
|
|
plus.nativeUI.closeWaiting()
|
|
plus.runtime.install(
|
|
downloadRes.tempFilePath, {
|
|
force: false
|
|
},
|
|
function() {
|
|
console.log('install success...');
|
|
plus.runtime.restart();
|
|
},
|
|
function(e) {
|
|
console.error('install fail...');
|
|
});
|
|
}
|
|
},
|
|
fail: () => {
|
|
uni.showToast({
|
|
title: '升级失败',
|
|
icon: 'none'
|
|
});
|
|
}
|
|
});
|
|
dtask.onProgressUpdate((res) => {
|
|
showLoading.setTitle(" 正在下载" + res.progress + "% ");
|
|
console.log('下载进度' + res.progress + '%');
|
|
});
|
|
// that.downloadNewVersion(that.phoneInfo.versionUrl.url);
|
|
} else {
|
|
uni.showModal({
|
|
title: '发现新版本 ' + that.phoneInfo.versionUrl.version,
|
|
content: '请到App store进行升级',
|
|
showCancel: false
|
|
})
|
|
}
|
|
}
|
|
},
|
|
downloadNewVersion(downloadUrl) {
|
|
let that = this
|
|
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.content {
|
|
min-height: calc(100vh - 30px);
|
|
padding: 15px;
|
|
display: flex;
|
|
align-items: center;
|
|
flex-direction: column;
|
|
justify-content: space-between;
|
|
background-color: #f7f7f7;
|
|
}
|
|
|
|
.info {
|
|
width: 100%;
|
|
}
|
|
|
|
.logo {
|
|
width: 100%;
|
|
text-align: center;
|
|
font-size: 40rpx;
|
|
line-height: 30px;
|
|
|
|
image {
|
|
width: 60px;
|
|
height: 60px;
|
|
border-radius: 5px;
|
|
}
|
|
|
|
text {
|
|
display: block;
|
|
font-size: 32rpx;
|
|
color: #999;
|
|
}
|
|
}
|
|
|
|
.list {
|
|
width: calc(100% - 20px);
|
|
margin: 50px 0;
|
|
|
|
.item {
|
|
width: 100%;
|
|
height: 50px;
|
|
line-height: 50px;
|
|
margin-bottom: 15px;
|
|
display: flex;
|
|
background-color: #fff;
|
|
border-radius: 10px;
|
|
padding: 0 10px;
|
|
justify-content: space-between;
|
|
|
|
.new {
|
|
color: #fff;
|
|
background-color: red;
|
|
font-size: 32rpx;
|
|
border-radius: 10px;
|
|
padding: 3px 5px;
|
|
}
|
|
|
|
.href {
|
|
display: flex;
|
|
width: 100%;
|
|
color: #000;
|
|
text-decoration: none;
|
|
justify-content: space-between;
|
|
}
|
|
}
|
|
}
|
|
|
|
.xieyi {
|
|
color: $textcolor;
|
|
}
|
|
</style> |