查看当前版本
plus.runtime.getProperty(plus.runtime.appid, (info) => {
this.currentVersion = info.version;
})
发起请求进行判断
// 判断是否有新版本
if (!res.data.update) {
uni.showToast({
title: "已是最新版本",
icon: "none"
})
} else {
uni.showModal({
content: '当前有新版本更新,是否前往更新?',
success: () => {
// 判断运行环境 ios 传appid 直接跳转AppleStore
if (uni.getSystemInfoSync().platform === 'ios') {
let appleId = '6446674622';
plus.runtime.launchApplication({
action: `itms-apps://itunes.apple.com/cn/app/id${appleId}?mt=8`
},
function(e) {
console.log('Open system default browser failed: ' + e.message);
}
)
} else
// 安卓跳转网页下载
if (uni.getSystemInfoSync().platform === 'android') {
plus.runtime.openURL(this.$baseUrl + res.data.apkUrl);
}
}
})
this.newVersion = res.data.versionsnum
}