uniapp APP版本更新

复制代码
var dtask = plus.downloader.createDownload(userl.value, {}, function(d, status) {
		 
							if (status == 200) { // 下载完成-进行安装
								console.log('下载status', d, status)
								// console.log("Download success: " + d.filename);
								this.show_update = false
								plus.runtime.install(d.filename, {
									force: true
								}, function() {
									plus.runtime.restart();
								}, function(e) {
									console.log(e)
									uni.hideLoading()
									plus.nativeUI.toast("安装失败");
								});
							} else {
								console.log("Download failed: " + status);
							}
						});
					 
						dtask.start();

进度
onProgress(task) { //  获取下载进度
				console.log('下载中onProgress');
				this.show_update = true
				task.addEventListener('statechanged', e => {
					console.log('下载中', e)
					if (e && e.downloadedSize > 0) {
						const progress = ((e.downloadedSize / e.totalSize) * 100).toFixed(0)
						console.log('下载中111', progress)
						this.progress = progress
					}

p判断版本号是否小于当前线上版本

复制代码
plus.runtime.getProperty(plus.runtime.appid, function (inf) {
				console.log('当前应用版本号:',  parseInt(inf.versionCode), parseInt(res.data.apkVersion),parseInt(inf.versionCode) < parseInt(res.data.apkVersion))
				if (parseInt(inf.versionCode) < parseInt(res.data.apkVersion)) {
					uModal.value.open()
					console.log(res,"参数--")
					userl.value=res.data.path
				}
			})
相关推荐
是烟花哈3 小时前
【前端】React框架学习
前端·学习·react.js
qq4356947014 小时前
JavaWeb08
前端
2401_878454535 小时前
html和css的复习(1)
前端·css·html
@PHARAOH5 小时前
WHAT - git worktree 概念
前端·git
IT_陈寒6 小时前
我竟然被JavaScript的隐式类型转换坑了三天!
前端·人工智能·后端
我亚索贼六丶6 小时前
二十六. AI基础概念之如何更好的使用AI
前端
小码哥_常6 小时前
安卓启动页Logo适配秘籍:告别“奇形怪状”的展示
前端
我亚索贼六丶6 小时前
二十五.Electron 初体验与进阶
前端
当时只道寻常6 小时前
像使用 Redis 一样操作 LocalStorage
前端·前端工程化
RONIN6 小时前
UI组件库elementplus
前端