From 149dab1e6cb8af57634d49e5467c467691635cc0 Mon Sep 17 00:00:00 2001 From: whycq <913841844@qq.com> Date: 星期三, 01 二月 2023 10:33:27 +0800 Subject: [PATCH] # --- App.vue | 68 +++++++++++++++++++++++++++++++++- 1 files changed, 66 insertions(+), 2 deletions(-) diff --git a/App.vue b/App.vue index 8589ba5..2b02d83 100644 --- a/App.vue +++ b/App.vue @@ -84,8 +84,8 @@ ] }, onShow: function() { - this.getVersion(); - this.baseUrll = uni.getStorageSync("baseUrl") + // this.getVersion(); + // this.baseUrll = uni.getStorageSync("baseUrl") // console.log(this.baseUrll); console.log('App Show') }, @@ -177,6 +177,70 @@ }); complete: () => {} }, + downWgt() { + let that = this; + const downloadUrl = "http://192.168.4.188:8088/jfwms/static/appupload/android_debug.apk" + console.log('url:' + downloadUrl) + 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.$u.toast(res.progress) + that.downloadNum = res.progress + console.log('涓嬭浇杩涘害' + that.downloadNum); + // console.log('宸茬粡涓嬭浇鐨勬暟鎹暱搴�' + res.totalBytesWritten); + // console.log('棰勬湡闇�瑕佷笅杞界殑鏁版嵁鎬婚暱搴�' + res.totalBytesExpectedToWrite); + + // 婊¤冻娴嬭瘯鏉′欢锛屽彇娑堜笅杞戒换鍔°�� + // if (res.progress > 50) { + // downloadTask.abort(); + // } + }); + }, } } </script> -- Gitblit v1.9.1