From e2b07afb71e112babef573c8dad089d0a2aef5da Mon Sep 17 00:00:00 2001 From: whycq <10027870+whycq@user.noreply.gitee.com> Date: 星期二, 07 二月 2023 16:45:05 +0800 Subject: [PATCH] # --- App.vue | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 55 insertions(+), 0 deletions(-) diff --git a/App.vue b/App.vue index 6aeb746..33ce0b1 100644 --- a/App.vue +++ b/App.vue @@ -181,6 +181,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