var downloadTask = plus.downloader.createDownload(url, {
filename: path
}, function(d, status){
if(status == 200){
_this.hasProgress = false
plus.runtime.install(d.filename, {force: true}, function(success) {
uni.showToast({
title: '安装成功',
mask: false,
duration: 1500
});
}, function(error) {
uni.showToast({
title: '安装失败-01',
mask: false,
duration: 1500
});
})
}
}, () => { console.log('下载失败'); })
downloadTask.start()
var prg = 0;
downloadTask.addEventListener('statechanged', (task, status) => {
// 给下载任务设置一个监听 并根据状态 做操作
switch (task.state) {
case 1:
console.log('正在下载')
break;
case 2:
console.log("已连接到服务器");
break;
case 3:
prg = parseInt((parseFloat(task.downloadedSize) / parseFloat(task.totalSize)) * 100);
_this.hasProgress = true
_this.currentPercent = prg
break;
case 4:
//下载完成
break;
}
}, false)
2 个回复
pnpl
如果是离打包,记得添加sdk
install-apk-release.aar
6***@qq.com
解决了吗大佬 我也遇到同样的问题
甚至还报错 : “code“: -1201, “message“: “WGT/WGTU文件格式错误“