plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
let currentVersion = widgetInfo.version.replace(/./g, ""); //获取当前版本号
getVersion().then(resData =>{
console.log("http版本信息", resData)
let newVersion = resData.version.replace(/./g, "");
console.log("版本信息", currentVersion, newVersion)
if (Number(currentVersion) < Number(newVersion)) {
console.log("更新")
uni.showModal({
title: '发现新版本',
content: '请进行热更新',
showCancel: false,
success: function(res) {
if (res.confirm) {
uni.showLoading({
mask: true,
title: '正在更新中,请稍等',
})
uni.downloadFile({
url: resData.url,
success: (downloadResult) => {
uni.hideLoading()
plus.runtime.install(
downloadResult
.tempFilePath, { force: true },
function() {
// 应用热重启,重新启动进入首页。
uni.showModal({
title: '安装成功!',
content: '请点击重启按钮,重新进入应用',
showCancel: false,
confirmText: '重启',
success: function(res) {
if (res.confirm) {
plus.runtime.restart();
} else if(res.cancel) {
plus.runtime.quit(); // 退出应用
}
}
});
},
function(e) {
console.log("安装失败", e)
uni.showToast({
title: '安装失败',
icon: 'none'
})
plus.runtime.quit(); // 退出应用
})
},
fail: (err) => {
uni.hideLoading()
uni.showToast({
title: '下载失败',
icon: 'none'
})
plus.runtime.quit(); // 退出应用
}
})
} else if (res.cancel) {
uni.showToast({
title: '已取消',
icon: 'none'
})
plus.runtime.quit(); // 退出应用
}
}
})
}
}).catch(e =>{
console.log("获取http版本失败", e)
})
})
uni大法好
我改了后依然还是 报这样的错
2024-08-19 18:09