查询是否需要热更新
getupdate() {
var that = this;
this.$minApi
.updateconf()
.then(res => {
console.log(res);
console.log('检测更新');
if (res.data) {
that.getHotUpdate(res.data);
}
})
.catch(err => {
console.log(err);
});
},
// 热更新
getHotUpdate(data) {
//对比版本号
let test_v = Version(plus.runtime.version, data.hotupdate_version);
console.log(plus.runtime.version)
if (!test_v && data.android_download2_url) {
console.log('有热更新下载热更新文件')
uni.downloadFile({
url: data.android_download2_url,
success: downloadResult => {
if (downloadResult.statusCode === 200) {
plus.runtime.install(
downloadResult.tempFilePath,
{
force: false
},
function() {
console.log('install success...');
// 记录热更新文件的版本号
uni.setStorageSync('version2', data.hotupdate_version);
uni.showModal({
title: 'app更新已就绪是否立即更新',
content: '',
success: showResult => {
if (showResult.confirm) {
plus.runtime.restart();
}
}
});
},
function(e) {
console.error('install fail...');
}
);
}
}
});
}
},