#
whycq
2023-02-05 9e885d8274a760a59a9f8dfd26ade186546b298d
App.vue
@@ -4,6 +4,7 @@
      globalData: {
         baseHttp: '',
         baseUrll: '',
         upVersion: 0,
      },
      onLaunch: function() {
         Vue.prototype.ColorList = [{
@@ -86,7 +87,6 @@
      onShow: function() {
         this.getVersion();
         this.baseUrll = uni.getStorageSync("baseUrl")
         // console.log(this.baseUrll);
         console.log('App Show')
      },
      onHide: function() {
@@ -120,7 +120,13 @@
               url: that.baseUrll + "/mobile/appUpdate/queryUpdate",
               method:'GET',
               success(res) {
                  console.log(res);
                  // 新app版本
                  that.upVersion = Number(res.data.data)
                  // 当前app版本
                  let currentVersion =  Number(that.version)
                  if(that.upVersion > currentVersion) {
                     that.downWgt(); //下载文件
                  }
               }
            })
            return
@@ -178,8 +184,7 @@
         },
         downWgt() {
            let that = this;
            const downloadUrl = "http://192.168.4.188:8088/jfwms/static/appupload/android_debug.apk"
            console.log('url:' + downloadUrl)
            const downloadUrl = that.baseUrll + "/static/appupload/" + that.upVersion + ".apk"
            uni.showLoading({
               title: '更新中……'
            })
@@ -228,16 +233,8 @@
         
            // 下载进度
            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();
               // }
            });
         },
      }