#
zhou zhou
昨天 da27ee7966358d48ac8f9bb0c0d78327d2c5d934
Monitor-APP/pages/home/home.vue
@@ -143,7 +143,7 @@
                        <view style="height: 2%"></view>
                        <view style="height: 18%; display: flex; justify-content: space-around; align-items: center">
                           <view style="height: 50%">
                              <image style="height: 100%" src="../../static/img/logo-bai.png" mode="aspectFit"></image>
                              <image style="height: 100%; opacity: 0;" src="../../static/img/logo-bai.png" mode="aspectFit"></image>
                           </view>
                        </view>
                     </view>
@@ -230,29 +230,17 @@
                  </view>
               </view>
               <view class="item">
                  <view class="desc">Wcsport:</view>
                  <view class="desc">port:</view>
                  <view class="input">
                     <input type="text" v-model="basePort" />
                  </view>
               </view>
               <view class="item">
                  <view class="desc">WcsUrl:</view>
                  <view class="desc">Url:</view>
                  <view class="input">
                     <input type="text" v-model="baseUrl" />
                  </view>
               </view>
               <view class="item">
                  <view class="desc">Wmsport:</view>
                  <view class="input">
                     <input type="text" v-model="wmsPort" />
                  </view>
               </view>
               <view class="item">
                  <view class="desc">WmsUrl:</view>
                  <view class="input">
                     <input type="text" v-model="wmsUrl" />
                  </view>
               </view>
               </view>
               <view class="item">
                  <view class="desc">ledId:</view>
                  <view class="input">
@@ -348,7 +336,8 @@
         wmsUrl: '',
         wmsPort: '',
         switchDebounceTimer: null,
         viewSwitchInProgress: false
         viewSwitchInProgress: false,
         getConfigUrl:"http://192.168.1.198:8080/wms/rpc/getLedInfos"
      };
   },
   onShow() {
@@ -357,8 +346,7 @@
      plus.navigator.setFullscreen(true);
      // #endif
      this.getVersion();
      var ip = this.getIp();
      console.log(ip);
   },
   mounted() {
      let that = this;
@@ -393,6 +381,9 @@
      that.baseCrnId = BaseCrnId;
      that.wmsUrl = WMSURL;
      that.wmsPort = WMSPORT;
      that.getIPConfig();
      that.uniWebSocket();
      // that.webSockerInit()
   },
@@ -421,54 +412,29 @@
            this.oldData = [];
         }
      }, 30000 * 10); // 每小时执行一次
   },
   methods: {
      getIp() {
         var ip = null;
         if (plus.os.name === 'Android') {
            try {
               const InetAddress = plus.android.importClass('java.net.InetAddress');
               const NetworkInterface = plus.android.importClass('java.net.NetworkInterface');
               const Collections = plus.android.importClass('java.util.Collections');
               let interfaces = NetworkInterface.getNetworkInterfaces();
               let en = Collections.list(interfaces); // Java ArrayList
               let ipEth = null; // 有线
               let ipWifi = null; // Wi-Fi
               let ipOther = null; // 兜底
               let size = plus.android.invoke(en, 'size');
               for (let i = 0; i < size; i++) {
                  let intf = plus.android.invoke(en, 'get', i);
                  let name = plus.android.invoke(intf, 'getName'); // eth0 / wlan0 / lo 等
                  let enumIpAddr = plus.android.invoke(intf, 'getInetAddresses');
                  let enumList = Collections.list(enumIpAddr);
                  let listSize = plus.android.invoke(enumList, 'size');
                  for (let j = 0; j < listSize; j++) {
                     let inetAddress = plus.android.invoke(enumList, 'get', j);
                     if (!plus.android.invoke(inetAddress, 'isLoopbackAddress')) {
                        let hostAddress = plus.android.invoke(inetAddress, 'getHostAddress');
                        // 只取 IPv4
                        if (hostAddress.indexOf(':') === -1) {
                           if (name.startsWith('eth') && !ipEth) {
                              ipEth = hostAddress;
                           } else if (name.startsWith('wlan') && !ipWifi) {
                              ipWifi = hostAddress;
                           } else if (!ipOther) {
                              ipOther = hostAddress;
                           }
                        }
                     }
                  }
      getIPConfig(){
         const that = this
            console.log(that.baseIP)
            uni.request({
               url: that.getConfigUrl,
               method:'GET',
               success(result) {
                  console.log(result)
                  const res = result.data
                  uni.setStorageSync('BaseIp', res.data.ledIp);
                  uni.setStorageSync('BaseLedId', res.data.ledId);
                  uni.setStorageSync('BasePort', res.data.ledPort);
                  uni.setStorageSync('UPROJ', res.data.ledUrl);
               }
               ip = ipEth || ipWifi || ipOther || null;
               return ip;
            } catch (e) {
               console.log('获取IP失败:', e);
               return ip;
            }
         } else {
            return ip;
         }
            });
      },
      uniWebSocket() {
         let that = this;
@@ -597,7 +563,10 @@
               that.infoText.sourceLocNo = data.taskList[0].sourceLocNo;
               that.infoText.staNo = data.taskList[0].staNo;
               that.swiperList = data.taskList[0].matDtos;
            } else {
            }else if(data.type === 'NoData'){
               that.infoType = 0;
            }
             else {
               if (that.infoType == 2 || that.infoType == 3) {
                  return;
               }