客户要求app自动更新,然后看了看文档,仅供参考
init(conf) {
var that = this
plus.runtime.getProperty(plus.runtime.appid, function(info) {
let version = info.version
//判断当前apk版本号是否与后端返回的版本号一致
if (version !=conf.system_name) {
uni.getSystemInfo({
success: (result) => {
if (result.platform != 'ios') {
uni.showModal({
title: '温馨提示',
content: '发现有新版安装包可更新,是否更新?',
success: (k) => {
if (k.confirm) {
let dtask = uni.downloadFile({
url: that.httpUrl + conf.system_logo,
success: (downResult) => {
console.log(downResult)
plus.runtime.install(downResult.tempFilePath)
that.isupdate = false
}
})
dtask.onProgressUpdate((percent) => {
// downloadFile下载进度
that.percent =percent.progress
})
}
}
})
}
}
})
}
})
},