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
				}
			})
相关推荐
JarvanMo22 分钟前
Dart 3.13:小版本,大动作
前端
纯粹的热爱24 分钟前
Ubuntu 安装 Node.js 22.x(通过 NodeSource 官方源)
前端
Highcharts26 分钟前
如何选择正确的图表:驱动理解和洞察力的三部分框架(第3部分)
前端·数据可视化
JavaGuide1 小时前
Github 史诗级故障,与此同时,Cursor 版「GitHub」正式上线!
前端·后端
郭邯1 小时前
用 AI 写了一个经纬度格式转换工具,从需求到落地的完整过程
前端
不一样的少年_1 小时前
修了 Bug、做了重构,为什么老板还是觉得你没产出?
前端·后端·程序员
马可家的菠萝1 小时前
Vue3 + Canvas 手绘笔记工程化实践:别把画布只当成一张 PNG
前端·vue.js·算法
IMPYLH1 小时前
HTML 的 <h1>–<h6> 元素
前端·javascript·html
IMPYLH1 小时前
HTML 的 <head> 元素
前端·html
卸任1 小时前
AI英语学习助手:从翻译工具到 AI 英语学习助手
前端·electron