html进度条代码:html
<template> <div id="app" > <div v-show='proess' style="position: fixed;bottom:73px;left:0;width: 100%; z-index: 9999; "> <div style="width: 80%;margin: 0 auto; position: relative;"> <mt-progress :value="progressVal" :bar-height="5"></mt-progress> <p class="color-white">正在更新{{progressVal}}%</p> </div> </div> </div> </template> <script> export default { name: 'app', data() { return { progressVal:'0',proess:false } }, methods:{ // 下载wgt文件 downWgt(wgtUrl) { var that=this; that.proess=true; var dtask =plus.downloader.createDownload(wgtUrl, { filename: "_doc/update/" }, function(d, status) { console.log("下载和更新成功:" + d.filename); if (status == 200) { that.installWgt(d.filename); // 安装wgt资源包 } else { console.log("下载更新失败:" + d.filename); plus.nativeUI.toast("下载更新失败!"); } that.proess=false; }) dtask.addEventListener("statechanged", function(task, status){ if(task.state==3){ var progressVals = (task.downloadedSize / task.totalSize) * 100; that.progressVal=parseInt(progressVals); } }, false); dtask.start(); }, installWgt(path) { // 更新应用资源 plus.nativeUI.showWaiting("安装更新"); plus.runtime.install(path, {}, function() { plus.nativeUI.closeWaiting(); console.log("安装和更新成功!"); plus.nativeUI.alert("更新已完成!", function() { // 更新完成后重启应用 plus.runtime.restart(); }); }, function(e) { plus.nativeUI.closeWaiting(); plus.nativeUI.toast("安装更新失败![" + e.code + "]:" + e.message); }); }, } },mounted() { mui.plusReady(function() { plus.runtime.getProperty(plus.runtime.appid, function(inf) { var wgtVer = inf.version; //当前版本号 localStorage.setItem('dwgtVer', inf.version) //plus.nativeUI.toast("当前系统版本是什麼" + wgtVer); that.axios.get('version/update', { params: { version: wgtVer } }) .then(function(data) { console.log(JSON.stringify(data.data)); var datas=data.data; //wgtVer当前版本号 datas.version.versionNo最新版本号 var wgtVerattr = localStorage.getItem('wgtVer'); if(that.toNum(wgtVer)<that.toNum(datas.version.versionNo)){ if ((wgtVerattr == null || wgtVerattr == undefined) || wgtVerattr != data.version.versionNo) { if (datas.version.versionNo != wgtVer) { if (datas.version.forcedUpdate == 1) { //强制更新 //forcedUpdate ==1是强制更新 ==0是不强制更新 if (datas.version != null && datas.version != "") { mui.alert('检测到新版本'+datas.version.versionNo, '提示', function() { that.downWgt(datas.version.path); // 下载wgt资源包 }); } } else if (datas.version.forcedUpdate == 0) { //不强制更新 var btnArray = ['取消', '肯定']; mui.confirm('检测到新版本'+datas.version.versionNo+',是否进行升级?', '提示', btnArray, function(e) { if (e.index == 1) { //点击肯定 that.downWgt(datas.version.path); // 下载wgt资源包 } else { localStorage.setItem('wgtVer', datas.version.versionNo); //点击取消 /* that.proess=false; that.hiddees=false; localStorage.setItem('wgtVer', datas.version.versionNo);*/ } }) } } } } }) .catch(function(error) { console.log(error); }) }) }) } } </script>