From a8cf1ec3eb69af71833a59c7b0f8adf5c4f5ad48 Mon Sep 17 00:00:00 2001 From: yangan <yangan0921@163.com> Date: 星期二, 02 七月 2024 16:02:45 +0800 Subject: [PATCH] fix:称重修改bug --- pages/tabbar-page/index-tabbar/index-tabbar.vue | 39 +++++++++++++++++++++++++-------------- 1 files changed, 25 insertions(+), 14 deletions(-) diff --git a/pages/tabbar-page/index-tabbar/index-tabbar.vue b/pages/tabbar-page/index-tabbar/index-tabbar.vue index d6216d9..42af2d3 100644 --- a/pages/tabbar-page/index-tabbar/index-tabbar.vue +++ b/pages/tabbar-page/index-tabbar/index-tabbar.vue @@ -45,7 +45,7 @@ import freightForwarderIndex from '@/pages/freight-forwarder-page/freightForwarder-index/freightForwarder-index.vue'; import LoadUnload from '@/pages/loadUnload-page/loadUnload-page.vue' import selectTarget from '@/pages/loadUnload-page/selectTarget/selectTarget.vue' - import { mapState, mapMutations } from 'vuex'; + import { mapState, mapMutations,mapGetters } from 'vuex'; import { webSocketUrl } from '@/api/request.js'; let socket = null; @@ -60,7 +60,8 @@ computed: { ...mapState(['globalweighHouseCode', 'globalweigh', 'globalisconnect', 'globalSocket', 'websocketData', 'globalIntervalId' - ]) + ]), + ...mapGetters(['websocketData']) }, //棣栭〉涓嬫媺鍒锋柊 onPullDownRefresh() { @@ -126,6 +127,7 @@ }, onShow() { this.init(); + this.messageReq(); }, onLoad() { this.$store.dispatch('websocketInit') @@ -167,16 +169,19 @@ }; }, watch: { - '$store.state.websocketData'(v) { + 'websocketData': { + handler(v){ console.log(v, '鎺ュ彈鐨剋s鏁版嵁'); - if (v.startsWith('weigh')) { + if(v){ + if (v.startsWith('weigh')) { //閲嶉噺锛堢О閲嶇殑鏉′欢锛� let nowWeighObj = JSON.parse(v.slice(7)); if (this.globalweighHouseCode && nowWeighObj.eqCode == this.globalweighHouseCode) { this.changeWeigh(nowWeighObj.weigh); this.changeinfraredStatus(!!nowWeighObj.eqInfraredStatus); - console.log(!!nowWeighObj.eqInfraredStatus, '绾㈠鐘舵��'); + let warningState = nowWeighObj.warning == 1 + this.changeWarning(warningState) } - } else if (v.startsWith('msg')) { + } else if (v.startsWith('msg')) { //娑堟伅 function removeTags(str) { return str.replace(/<\/?[^>]+>/gi, ''); } @@ -186,25 +191,31 @@ title: this.messageList.title.slice(0, 8) + '...', content: removeTags(this.messageList.content).trim().slice(0, 8) + '...' } - if (uni.getStorageSync('userId') === this.messageList.appUserId) { - this.messagePushShow = true; - } - } else if (v.startsWith('wsg')) { + this.messagePushShow = !this.messageList.appUserId || uni.getStorageSync('userId') === this.messageList + .appUserId; + } else if (v.startsWith('wsg')) { //鎻愰啋纾呮埧鏈夎溅 let wsgObj = JSON.parse(v.slice(5)); if (uni.getStorageSync('carNo') === wsgObj.carNo && !wsgObj.peopleWeigh) { - this.changewsgVisiable(true) - this.changewsgContent(wsgObj.content) + this.changewsgVisiable(true) //纾呮埧蹇欑鐨勫脊妗嗙殑鐜伴殣钘� + this.changewsgContent(wsgObj.content) //纾呮埧蹇欑鐨勫脊妗嗙殑鍐呭鎻愮ず } if (uni.getStorageSync('carNo') === wsgObj.carNo && wsgObj.peopleWeigh === 2) { this.changeconfirmWeighVisiable(true) this.changeconfirmWeighContent(wsgObj.content) } } + } + + }, + deep:true, + immediate:true + } }, methods: { ...mapMutations(['pushMessage', 'changeWeigh', 'changeinfraredStatus', 'changeisconnect', 'websocketInit', - 'changewsgVisiable', 'changewsgContent', 'changeconfirmWeighVisiable', 'changeconfirmWeighContent' + 'changewsgVisiable', 'changewsgContent', 'changeconfirmWeighVisiable', 'changeconfirmWeighContent', + 'changeWarning' ]), messagePage() { uni.navigateTo({ @@ -338,4 +349,4 @@ } } } -</style> \ No newline at end of file +</style> -- Gitblit v1.9.1