pages.json:
{
"path": "pages/garden/gardenback4",
"style": {
"navigationBarTitleText": "打印送货单",
"enablePullDownRefresh": false,
"app-plus": {
"titleNView": {
"titleAlign": "left",
"buttons": [{
"fontSrc": "/static/uni.ttf",
"text": "\ue404"
}]
}
}
}
}
升级代码:用的是 https://ext.dcloud.net.cn/plugin?id=3931 下载的《APP升级,在线升级支持android、ios》插件
升级部分的代码如下:
let that = this
let downloadurl = that.wgt_flag == 1 ? that.wgt_url : that.version_url
//let downloadurl = that.version_url
this.update_confirm = true
this.downloadTask = uni.downloadFile({
url: downloadurl,
success: function(res) {
console.error(res);
if (res.statusCode == 200) {
//开始安装
plus.runtime.install(res.tempFilePath, {
force: false
}, function() {
//console.log('install success...');
plus.runtime.restart();
}, function(e) {
console.error(e);
uni.showToast({
title: '升级失败:'+e.message,
icon: 'none'
});
});
} else {
uni.showToast({
title: '下载失败,网络错误',
icon: 'none'
});
}
},
fail: function(e) {
//console.log("下载失败",e)
uni.showToast({
title: '下载失败:' + e.errMsg,
icon: 'none'
});
this.update_flag = false
},
complete: function() {}
})
this.downloadTask.onProgressUpdate(function(res) {
that.update_process = res.progress
if (res.progress == Infinity) {
//使用size计算
//console.log("计算size");
let progress = (res.totalBytesWritten / that.size) * 100
if (progress > 100) {
progress = 100
}
that.update_process = progress
}
})