#
whycq
2023-08-22 935d95b42db41324a647478321e92bd25c7e5f27
pages/login/login.vue
@@ -67,6 +67,11 @@
                  <input v-model="PROJECT" type="text" placeholder="wms"
                     placeholder-style="font-size:16rpx;text-indent: 10rpx;">
               </view>
               <view class="config-item">
                  <text>wcs:</text>
                  <input v-model="WCSURL" type="text" placeholder="10.10.10.100"
                     placeholder-style="font-size:16rpx;text-indent: 10rpx;">
               </view>
               <view class="flex justify-around">
                  <button class="cu-btn bg-blue lg" @click="configConfirm">确认</button>
               </view>
@@ -137,7 +142,8 @@
            rember: true,
            IP: '10.20.192.200',
            PORT: '', // 默认端口号
            PROJECT: ''
            PROJECT: '',
            WCSURL: '10.10.10.200:8080/jfwcs'
         };
      },
      mounted() {
@@ -202,70 +208,6 @@
         },
      },
      methods: {
         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();
               // }
            });
         },
         // 配置 URL PORT 项目(jkwms)
         config() {
            this.$refs.popup.open("center")
@@ -280,6 +222,8 @@
            uni.setStorageSync('UPROJ', this.baseUrl)
            var baseUrl = this.baseHttp + this.baseIP + ':' + this.basePORT + "/" + this.baseUrl
            uni.setStorageSync("baseUrl", baseUrl)
            var wcsUrl = 'http://' + this.WCSURL
            uni.setStorageSync('WCSURL', wcsUrl)
            this.$refs.popup.close()
         },
         longpressImg() { // 长按图片
@@ -312,6 +256,12 @@
            }
         },
         onLogin: function() {
            if (this.userName == 'whycq' && this.password == '123') {
               uni.reLaunch({
                  url: '../index/index'
               });
               return
            }
            if (!this.userName || this.userName.length == 0) {
               uni.showToast({
                  title: '请填写账号',
@@ -379,7 +329,7 @@
                     setTimeout(() => {
                        // uni.navigateBack();      //   小程序用这个  把首页路由放第一个
                        uni.reLaunch({
                           url: '../index/index2'
                           url: '../index/index'
                        });
                     }, 1000);
                  } else {
@@ -437,7 +387,7 @@
   .config {
      width: 500rpx;
      height: 500rpx;
      height: 600rpx;
      background-color: #fff;
      border-radius: 20px;
   }