yangan
2024-08-02 78252f8407345ffceed8157a1c1685c09cdec029
pages/tabbar-page/index-tabbar/index-tabbar.vue
@@ -7,8 +7,9 @@
               <u-badge :isDot="true"
                  type="error"
                  v-if="dotShow"></u-badge>
               <u-icon name="chat"
                  color="#fff"
               <u-icon
            name="chat"
                  :color="[roleType == 4 ? '#3b56eb' : '#fff']"
                  size="50"></u-icon>
            </view>
         </view>
@@ -38,11 +39,11 @@
<script>
   import customerIndex from '@/pages/customer-page/customer-index/customer-index.vue';
   // import driverIndex from '@/pages/driver-page/driver-index/driver-index.vue';
    import driverIndex from '@/pages/driver-page/driver-index/test-index.vue'
   import driverIndex from '@/pages/driver-page/driver-index/driver-index.vue';
   //  import driverIndex from '@/pages/driver-page/driver-index/test-index.vue'
   import inspectionIndex from '@/pages/driver-page/driver-index/bill-of-lading-details/selectOrderPlan/selectOrderPlan.vue'
   import freightForwarderIndex from '@/pages/freight-forwarder-page/freightForwarder-index/freightForwarder-index.vue';
   import { mapState, mapMutations } from 'vuex';
   import { mapState, mapMutations, mapGetters } from 'vuex';
   import { webSocketUrl } from '@/api/request.js';
   let socket = null;
   export default {
@@ -55,7 +56,8 @@
      computed: {
         ...mapState(['globalweighHouseCode', 'globalweigh', 'globalisconnect', 'globalSocket', 'websocketData',
            'globalIntervalId'
         ])
         ]),
      ...mapGetters(['websocketData'])
      },
      //首页下拉刷新
      onPullDownRefresh() {
@@ -146,35 +148,43 @@
         };
      },
      watch: {
         '$store.state.websocketData'(v) {
            console.log(v, '接受的ws数据');
            if (v.startsWith('weigh')) {
               let nowWeighObj = JSON.parse(v.slice(7));
               if (this.globalweighHouseCode && nowWeighObj.eqCode == this.globalweighHouseCode) {
                  if (nowWeighObj.eqInfraredStatus) {
                     this.changeinfraredStatus(true);
                     this.changeWeigh(nowWeighObj.weigh);
                     let warningState = nowWeighObj.warning == 1
                     this.changeWarning(warningState)
                  } else {
                     this.changeinfraredStatus(false);
                     this.changeWeigh(nowWeighObj.weigh);
                     let warningState = nowWeighObj.warning == 1
                     this.changeWarning(warningState)
                  }
               }
            } else if (v.startsWith('msg')) {
               function removeTags(str) {
                  return str.replace(/<\/?[^>]+>/gi, '');
               }
               this.messageList = JSON.parse(v.slice(5));
               this.messageList = {
                  ...this.messageList,
                  title: this.messageList.title.slice(0, 8) + '...',
                  content: removeTags(this.messageList.content).trim().slice(0, 8) + '...'
               }
               this.messagePushShow = true;
            } else {}
         'websocketData': {
        handler(v) {
          console.log(v, '接受的ws数据');
          if(v) {
            if (v.startsWith('weigh')) {
              let nowWeighObj = JSON.parse(v.slice(7));
              console.log(nowWeighObj,'nowWeighObj-----')
              console.log(this.globalweighHouseCode,'this.globalweighHouseCode-----')
              if (this.globalweighHouseCode && nowWeighObj.eqCode == this.globalweighHouseCode) {
                if (nowWeighObj.eqInfraredStatus) {
                  this.changeinfraredStatus(true);
                  this.changeWeigh(nowWeighObj.weigh);
                  let warningState = nowWeighObj.warning == 1
                  this.changeWarning(warningState)
                } else {
                  this.changeinfraredStatus(false);
                  this.changeWeigh(nowWeighObj.weigh);
                  let warningState = nowWeighObj.warning == 1
                  this.changeWarning(warningState)
                }
              }
            } else if (v.startsWith('msg')) {
              function removeTags(str) {
                return str.replace(/<\/?[^>]+>/gi, '');
              }
              this.messageList = JSON.parse(v.slice(5));
              this.messageList = {
                ...this.messageList,
                title: this.messageList.title.slice(0, 8) + '...',
                content: removeTags(this.messageList.content).trim().slice(0, 8) + '...'
              }
              this.messagePushShow = true;
            } else {}
          }
        },
        deep: true,
        immediate: true
         }
      },
      onShow() {
@@ -335,4 +345,4 @@
         }
      }
   }
</style>
</style>