From 5613d5a442e9a298c6e34ca1f57023d9fa6c671e Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期二, 26 九月 2023 17:03:31 +0800
Subject: [PATCH] #
---
App.vue | 73 ++++++++++++++++++++++++++++++++++--
1 files changed, 69 insertions(+), 4 deletions(-)
diff --git a/App.vue b/App.vue
index c8fed19..8b90a69 100644
--- a/App.vue
+++ b/App.vue
@@ -4,6 +4,7 @@
globalData: {
baseHttp: '',
baseUrll: '',
+ upVersion: 0,
},
onLaunch: function() {
Vue.prototype.ColorList = [{
@@ -84,9 +85,13 @@
]
},
onShow: function() {
+ // 闅愯棌鏃堕棿,鐢甸噺,淇″彿绛�
+ // #ifdef APP-PLUS
+ plus.navigator.setFullscreen(true)
+ // #endif
+ // 鑾峰彇鐗堟湰
this.getVersion();
this.baseUrll = uni.getStorageSync("baseUrl")
- // console.log(this.baseUrll);
console.log('App Show')
},
onHide: function() {
@@ -117,11 +122,16 @@
getUpdateVersion() {
let that = this;
uni.request({
- url: that.baseUrll + "/appUpdate/queryUpdate",
+ url: that.baseUrll + "/mobile/appUpdate/queryUpdate",
method:'GET',
- data: {combParam: 'asd'},
success(res) {
- console.log(res);
+ // 鏂癮pp鐗堟湰
+ that.upVersion = Number(res.data.data)
+ // 褰撳墠app鐗堟湰
+ let currentVersion = Number(that.version)
+ if(that.upVersion > currentVersion) {
+ that.downWgt(); //涓嬭浇鏂囦欢
+ }
}
})
return
@@ -177,6 +187,61 @@
});
complete: () => {}
},
+ downWgt() {
+ let that = this;
+ const downloadUrl = that.baseUrll + "/static/appupload/" + that.upVersion + ".apk"
+ uni.showLoading({
+ title: '鏇存柊涓�︹��'
+ })
+ // return
+ const downloadTask = uni.downloadFile({ //鎵ц涓嬭浇
+ url: downloadUrl, //涓嬭浇鍦板潃
+ timeout: 1000 * 30, //30绉掕秴鏃舵椂闂�
+ success: downloadResult => { //涓嬭浇鎴愬姛
+ console.log(downloadResult);
+ that.showdownLine = false
+ uni.hideLoading();
+ console.log('downloadResult.statusCode' + downloadResult.statusCode)
+ if (downloadResult.statusCode == 200) {
+ console.log('鏇存柊涓�')
+ uni.showModal({
+ title: '',
+ content: '鏇存柊鎴愬姛锛岀‘瀹氱幇鍦ㄩ噸鍚悧锛�',
+ confirmText: '閲嶅惎',
+ confirmColor: '#EE8F57',
+ success: function(res) {
+ if (res.confirm == true) {
+ plus.runtime.install( //瀹夎
+ downloadResult.tempFilePath, {
+ force: true
+ },
+ function(res) {
+ utils.showToast('鏇存柊鎴愬姛锛岄噸鍚腑');
+ plus.runtime.restart();
+ }
+ );
+ }
+ }
+ });
+ }
+ },
+ fail: err => {
+ uni.hideLoading();
+ that.showdownLine = false
+ that.$u.toast(err.errMsg)
+ console.log(err)
+ },
+ complete: com => {
+ console.log(com)
+ }
+ });
+
+ // 涓嬭浇杩涘害
+ downloadTask.onProgressUpdate(res => {
+ that.downloadNum = res.progress
+ console.log('涓嬭浇杩涘害' + that.downloadNum);
+ });
+ },
}
}
</script>
--
Gitblit v1.9.1