zjj
2025-07-02 ab478c5acee01dc7fcd319c5715fc38b8342219c
Monitor-APP/pages/home/home.vue
@@ -203,10 +203,10 @@
                           vertical 滑动方向是否为纵向 
                           display-multiple-items 同时显示的滑块数量 -->
                           <swiper class="swiper-body-main" vertical="true" 
                           display-multiple-items="2"
                           display-multiple-items="1"
                           circular="true" :autoplay="true" :interval="3000" :duration="2000">
                              <swiper-item class="swiper-item" v-for="(item,i) in swiperList" :key="i">
                                 <view style="width: 30%;">{{i+1}} / {{swiperList.length}}</view>
                                 <view style="width: 100%;">{{i+1}} / {{swiperList.length}}</view>
                                 <!-- <view style="width: 30%;">料号: {{item.matnr}}</view> -->
                                 <view style="width: 50%; font-size: 3vw;">物料编码: {{item.matnr}}</view>
                                 <view style="width: 50%; font-size: 3vw;">名称: {{item.maknx}}</view>
@@ -317,9 +317,9 @@
</template>
<!-- {"msg":"操作成功","code":200,"data":[{"title":"全板出库","workNo":7460,"staNo":110,"sourceStaNo":null,"locNo":null,"sourceLocNo":"0807102","matDtos":[{"matNo":"50460834","maknx":"200x60桌面","count":26.0}],"emptyMk":false,"ioType":101}]} -->
<script>
   import demodata from '@/mockdata/demodata.json';
   import ycqdata from '@/pages/index/data.json';
   import {WebSocketClient} from "@/static/js/WebSocketClient"
   import WebSocketUtil from './uniWebSocket';
   let socket;
   export default {
@@ -332,6 +332,10 @@
            homeMode: [],
            infoMode: [],
            errorInfoMode: [],
            needUpdateCharts: false,
            viewSwitchTimer: null, // 视图切换定时器
            viewSwitchInProgress: false, // 添加这一行来跟踪视图切换状态
            timerIds: [], // 存储定时器ID
            baseInfo: {
               xDistance: 1,
               yDistance: 2,
@@ -446,7 +450,8 @@
         // that.webSockerInit()
      },
      onLoad() {         
         setInterval(()=>{
         // 存储定时器ID以便后续清理
         const timerId1 = setInterval(()=>{
            this.getServerData()
            // this.initlineChart()
            // this.initPieChart()
@@ -463,28 +468,48 @@
            // 测试用
            
         },1000)
         this.timerIds.push(timerId1)
         
         setInterval(()=> {
         const timerId2 = setInterval(()=> {
            setTimeout(()=>{
               plus.runtime.restart();
            },100)
            
         },1000*60*60*4)
         this.timerIds.push(timerId2)
         //安卓内存占用打印
         // setInterval(()=> {
         //    setTimeout(()=>{
         //       var time = new Date();
         //       var hh = time.getHours();
         //       var mm = time.getMinutes();
         //       if(hh > this.oldHours && mm >this.oldMin && this.oldMin - mm < 55){
         //          plus.runtime.restart();
         //       }
         //       if(mm >this.oldMin && mm - this.oldMin >2){
         //          plus.runtime.restart();
         //       }
         //    },100)
         //    plus.android.importClass('android.os.Debug');
         //              const mem = plus.android.invoke(
         //                'android.os.Debug',
         //                'getNativeHeapAllocatedSize'
         //              ) / 1048576;
         //              console.log(mem.toFixed(1))
            
         // },1000*30)
         //    }, 2000)
      },
      onUnload() {
         // 清理所有定时器
         this.timerIds.forEach(id => clearInterval(id))
         this.timerIds = []
      },
      beforeDestroy() {
         // 清理WebSocket连接
         if (this.socketClient) {
            this.socketClient.close()
            this.socketClient = null
         }
         // 清理所有定时器
         this.timerIds.forEach(id => clearInterval(id))
         this.timerIds = []
         // 清理视图切换定时器
         if (this.viewSwitchTimer) {
            clearTimeout(this.viewSwitchTimer)
            this.viewSwitchTimer = null
         }
      },
      methods: {
         uniWebSocket(){
@@ -584,6 +609,8 @@
         showDate(data){
            const that = this
            if(data.type === "default"){
               // 设置标记,表示数据已更新,需要重新渲染图表
               that.needUpdateCharts = true
               that.chartsData.Pie.series[0].data = data.pie
               that.baseInfo.stockCount = data.stockCunt
               that.baseInfo.emptyCount = data.emptyCount
@@ -680,8 +707,12 @@
            this.commonUrl = this.baseHttp + this.baseIP + ':' +this.basePort + "/" +this.baseUrl            
         },
         getServerData() {
            // 只在数据变化时才进行深拷贝
            if (this.needUpdateCharts) {
            this.chartsDataLine1=JSON.parse(JSON.stringify(this.chartsData.Line))
            this.chartsDataPie2=JSON.parse(JSON.stringify(this.chartsData.Pie))
               this.needUpdateCharts = false
            }
         },
         // 获取错误信息
         getInfo2() {
@@ -839,47 +870,83 @@
         },
         // 控制器
         controller() {
    // 如果视图切换正在进行中,不要中断
    if (this.viewSwitchInProgress) {
        return;
    }
    // 清除之前的视图切换定时器
    if (this.viewSwitchTimer) {
        clearTimeout(this.viewSwitchTimer)
        this.viewSwitchTimer = null
    }
            switch(this.infoType) {
               // 有信息 但 没有错误信息
               case 0: 
                  if (this.errorInfoViewShow) {
                this.viewSwitchInProgress = true;
                     this.errorInfoViewShow = false
                     this.errorInfoMode = ['fade', 'slide-bottom']
                     setTimeout(()=>{
                this.viewSwitchTimer = setTimeout(()=>{
                        this.homeViewShow = true
                        this.homeMode = ['fade', 'slide-bottom']
                    // 设置另一个定时器来重置进行中标志
                    setTimeout(() => {
                        this.viewSwitchInProgress = false;
                    }, 1000);
                     },1000)
                  } else if (this.infoViewShow) {
                this.viewSwitchInProgress = true;
                     this.infoViewShow = false
                     this.infoMode = ['fade', 'slide-bottom']
                     setTimeout(()=>{
                this.viewSwitchTimer = setTimeout(()=>{
                        this.homeViewShow = true
                        this.homeMode = ['fade', 'slide-bottom']
                    // 设置另一个定时器来重置进行中标志
                    setTimeout(() => {
                        this.viewSwitchInProgress = false;
                    }, 1000);
                     },1000)
                  } else if (this.errorInfoViewShow && this.infoViewShow) {
                this.viewSwitchInProgress = true;
                     this.errorInfoViewShow = false
                     this.infoViewShow = false
                     this.infoMode = ['fade', 'slide-bottom']
                     setTimeout(()=>{
                this.viewSwitchTimer = setTimeout(()=>{
                        this.homeViewShow = true
                        this.homeMode = ['fade', 'slide-bottom']
                    // 设置另一个定时器来重置进行中标志
                    setTimeout(() => {
                        this.viewSwitchInProgress = false;
                    }, 1000);
                     },1000)
                  }
                  return;
               case 1: 
                  if (this.homeViewShow) {
                this.viewSwitchInProgress = true;
                     this.homeViewShow = false
                     this.homeMode = ['fade', 'slide-bottom']
                     setTimeout(()=>{
                this.viewSwitchTimer = setTimeout(()=>{
                        this.infoViewShow = true
                        this.infoMode = ['fade', 'slide-bottom']
                    // 设置另一个定时器来重置进行中标志
                    setTimeout(() => {
                        this.viewSwitchInProgress = false;
                    }, 1000);
                     },1000)
                  } else if (this.errorInfoViewShow) {
                this.viewSwitchInProgress = true;
                     this.errorInfoViewShow = false
                     this.errorInfoMode = ['fade', 'slide-bottom']
                     setTimeout(()=>{
                this.viewSwitchTimer = setTimeout(()=>{
                        this.infoViewShow = true
                        this.infoMode = ['fade', 'slide-bottom']
                    // 设置另一个定时器来重置进行中标志
                    setTimeout(() => {
                        this.viewSwitchInProgress = false;
                    }, 1000);
                     },1000)
                  }
                  
@@ -887,36 +954,56 @@
                  // 有信息 且 有错误信息
               case 2:
                  if (this.homeViewShow) {
                this.viewSwitchInProgress = true;
                     this.homeViewShow = false
                     this.homeMode = ['fade', 'slide-bottom']
                     setTimeout(()=>{
                this.viewSwitchTimer = setTimeout(()=>{
                        this.errorInfoViewShow = true
                        this.errorInfoMode = ['fade', 'slide-bottom']
                    // 设置另一个定时器来重置进行中标志
                    setTimeout(() => {
                        this.viewSwitchInProgress = false;
                    }, 1000);
                     },1000)
                  } else if (this.infoViewShow) {
                this.viewSwitchInProgress = true;
                     this.infoViewShow = false
                     this.infoMode = ['fade', 'slide-bottom']
                     setTimeout(()=>{
                this.viewSwitchTimer = setTimeout(()=>{
                        this.errorInfoViewShow = true
                        this.errorInfoMode = ['fade', 'slide-bottom']
                    // 设置另一个定时器来重置进行中标志
                    setTimeout(() => {
                        this.viewSwitchInProgress = false;
                    }, 1000);
                     },1000)
                  }
                  return;
               // 有信息 且 有错误信息
               case 3:
                  if (this.homeViewShow) {
                this.viewSwitchInProgress = true;
                     this.homeViewShow = false
                     this.homeMode = ['fade', 'slide-bottom']
                     setTimeout(()=>{
                this.viewSwitchTimer = setTimeout(()=>{
                        this.errorInfoViewShow = true
                        this.errorInfoMode = ['fade', 'slide-bottom']
                    // 设置另一个定时器来重置进行中标志
                    setTimeout(() => {
                        this.viewSwitchInProgress = false;
                    }, 1000);
                     },1000)
                  } else if (this.infoViewShow) {
                this.viewSwitchInProgress = true;
                     this.infoViewShow = false
                     this.infoMode = ['fade', 'slide-bottom']
                     setTimeout(()=>{
                this.viewSwitchTimer = setTimeout(()=>{
                        this.errorInfoViewShow = true
                        this.errorInfoMode = ['fade', 'slide-bottom']
                    // 设置另一个定时器来重置进行中标志
                    setTimeout(() => {
                        this.viewSwitchInProgress = false;
                    }, 1000);
                     },1000)
                  }
                  return;