cuiqian2004
2024-06-12 6050beb7c315bb0450e7c039a0455b96d4c1ce8f
pages/login/index.vue
@@ -283,47 +283,94 @@
               });
               return;
            }
            var dataInfo = {
               server: this.userServer
            };
            this.$store.dispatch('GetApkVersionInfo', dataInfo).then(success => {
               console.log(success);
               if (success.code == '00000') {
                  let resp = success.data;
                  if (resp) {
                     // const obj = resp.data.filter(item => {
                     //    return item.groupName == 'version'
                     // })
                     //获取当前版本号
                     const VersionName = resp.VersionName; //更新包名称
                     const VersionCode = resp.VersionCode; //版本编码
                     const versionNum = resp.Version; //服务端版本号
                     // this.downloadUrl = resp.PdaUrl+"/"+VersionName; //app下载链接
                     this.downloadUrl = "http://" + this.userServer + "/Program/" + VersionName; //app下载链接this.
                     var isver = this.compare(versionNum,version);
                     if (isver) {
                        this.$refs.promotion.open();
            var ser = this.userServer.split('/');
            var $this = this;
            if(ser[1] == 'mobox3'){ //判断当前网址是否是mobox3
               var url = 'http://'+this.userServer+'/Program/version.txt';
               // console.log(url);
               uni.request({
                  url: url, // 指定JS文件的完整路径
                  method: 'GET',
                  success(res) {
                     console.log(res);
                     if (res && res.statusCode === 200) {
                        //获取当前版本号
                        var VersionName = res.data; //更新包名称
                        var versionInfo = res.data.split('_');
                        var versionNum = versionInfo[2].replace(".apk", ""); //版本编码
                        var VersionCode = versionInfo[2].replace(".apk", "").replace(".", "").replace(".", ""); //服务端版本号
                        // this.downloadUrl = resp.PdaUrl+"/"+VersionName; //app下载链接
                        $this.downloadUrl = "http://" + $this.userServer + "/Program/" + VersionName; //app下载链接this.
                        var isver = $this.compare(versionNum,version);
                        if (isver) {
                           $this.$refs.promotion.open();
                        } else {
                           console.log('当前已是最新版本')
                        }
                     } else {
                        console.log('当前已是最新版本')
                        // if(res.statusCode === 404){
                        //    uni.showModal({
                        //       title: "提示",
                        //       content: '请求失败,找不到更新包版本文档:'+url,
                        //       showCancel: false,
                        //       confirmText: "取消"
                        //    });
                        // }
                     }
                  },
                  fail(err) {
                     // 错误处理逻辑
                     uni.showModal({
                        title: "错误",
                        content: '获取'+url+'文件失败:'+ err,
                        showCancel: false,
                        confirmText: "取消"
                     });
                  }
               } else {
               });
            }else{
               var dataInfo = {
                  server: this.userServer
               };
               this.$store.dispatch('GetApkVersionInfo', dataInfo).then(success => {
                  console.log(success);
                  if (success.code == '00000') {
                     let resp = success.data;
                     if (resp) {
                        // const obj = resp.data.filter(item => {
                        //    return item.groupName == 'version'
                        // })
                        //获取当前版本号
                        const VersionName = resp.VersionName; //更新包名称
                        const VersionCode = resp.VersionCode; //版本编码
                        const versionNum = resp.Version; //服务端版本号
                        // this.downloadUrl = resp.PdaUrl+"/"+VersionName; //app下载链接
                        $this.downloadUrl = "http://" + $this.userServer + "/Program/" + VersionName; //app下载链接this.
                        var isver = $this.compare(versionNum,version);
                        if (isver) {
                           $this.$refs.promotion.open();
                        } else {
                           console.log('当前已是最新版本')
                        }
                     }
                  } else {
                     uni.showModal({
                        title: "错误",
                        content: success.msg,
                        showCancel: false,
                        confirmText: "取消"
                     });
                  }
               }).catch(ex => {
                  console.log(ex);
                  uni.showModal({
                     title: "错误",
                     content: success.msg,
                     content: ex.errMsg ? ex.errMsg : ex.message,
                     showCancel: false,
                     confirmText: "取消"
                  });
               }
            }).catch(ex => {
               console.log(ex);
               uni.showModal({
                  title: "错误",
                  content: ex.errMsg ? ex.errMsg : ex.message,
                  showCancel: false,
                  confirmText: "取消"
               });
            });
            }
         },
         compare(curV, reqV) {
            var arr1 = curV.toString().split('.');
@@ -553,6 +600,29 @@
         }
      },
      onLoad() {
         //获取mac地址
         var net = plus.android.importClass("java.net.NetworkInterface");
         var wl0 = net.getByName('wlan0');
         var macByte = wl0.getHardwareAddress();
         var deviceId = ''
         //下面这段代码来自网络
         for (var i = 0; i < macByte.length; i++) {
             var tmp = "";
             var num = macByte[i];
             if (num < 0) {
               tmp =(255+num+1).toString(16);
             } else {
               tmp = num.toString(16);
             }
             if (tmp.length == 1) {
               tmp = "0" + tmp;
             }
             deviceId += tmp;
         }
         //78b8d67511ca
         this.$store.commit("setDeviceId", deviceId);
         console.log('Android设备的deviceId:',  deviceId);
         plus.runtime.getProperty(plus.runtime.appid, (info) => {
            // console.log(info);
            this.$data.version = info.version;