uniapp热更新

// #ifdef APP-PLUS
plus.runtime.getProperty(plus.runtime.appid, widgetInfo => {
//TODO 使用的调试基座,暂时我也不想研究怎么去弄自定义基座
this.version = widgetInfo.version;
if (widgetInfo.appid == 'HBuilder') {
this.versionCode = this.version.replace(/\./g, '');
} else {
this.versionCode = widgetInfo.versionCode;
}
let localVersion = uni.getStorageSync('config_version');
if (this.serverVer.versionNum > this.versionCode && localVersion != this.serverVer.versionNum) {
let that = this;
//保存到本地,同一个版本只提醒一次
// uni.setStorageSync('config_version', this.serverVer.versionNum);
uni.showModal({
title: '有新版本可以更新',
content: '当前版本' + this.version + ',最新版本' + this.serverVer.versionName,
cancelText: '以后再说',
confirmText: '去更新',
success: function(res) {
if (!res.cancel) {
if (plus.os.name == 'Android') {

//安卓下载地址
plus.runtime.openURL('https://a.app.qq.com/o/simple.jsp?pkgname=*********',
function(result) {
console.log(result);
});
} else if (plus.os.name == 'iOS') {

//ios下载地址
plus.runtime.openURL('https://itunes.apple.com/cn/app/apple-store/id**********', function(
result) {
console.log(result);
});
}
}
}
});
}
});
// #endif

posted @ 2020-10-13 14:20  karen555  阅读(427)  评论(0编辑  收藏  举报