From f393d33f812b2614ce9e354d4858f0853a3d67d7 Mon Sep 17 00:00:00 2001 From: whycq <10027870+whycq@user.noreply.gitee.com> Date: 星期二, 07 二月 2023 08:17:32 +0800 Subject: [PATCH] Merge branch 'bfwms' of http://47.97.1.152:5880/r/wms_app into bfwms --- App.vue | 65 +++++++++++++++++++++++++++++++- 1 files changed, 63 insertions(+), 2 deletions(-) diff --git a/App.vue b/App.vue index 24cb416..8b90a69 100644 --- a/App.vue +++ b/App.vue @@ -4,6 +4,7 @@ globalData: { baseHttp: '', baseUrll: '', + upVersion: 0, }, onLaunch: function() { Vue.prototype.ColorList = [{ @@ -122,10 +123,15 @@ let that = this; uni.request({ url: that.baseUrll + "/mobile/appUpdate/queryUpdate", - // data: {combParam: 'asd'}, method:'GET', 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 @@ -181,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