yangan
2024-07-12 72f2abafea3ce8c91d9b689821a4508bdc0f7d9f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<template>
<view style="display:flex;justify-content: center;fontSize:20px;flex-direction: column;">
   <h2 style="font-size:30px;text-align:center"> {{globalweigh}}</h2>
       <button style="margin-top:90%" @click="rest">点击重连</button>
    </view>  
</template>
 
<script>
import { mapState, mapMutations } from 'vuex';
export default {
    data() {
        return {
                roleType: null,
                orderPlanDataStore: [],
                indexHuoDaiOrderPlanData: [],
                indexHistoryCoalData: [],
                indexdriverBillOfLoadingData: {},
                messagePushShow: false,
                messageList: {
                    title: '',
                    content: "",
                },
                isconnect: false,
                dotShow: false,
                appHide: false,
                phone: ''
        }
    },
    computed: {
            ...mapState(['globalweighHouseCode', 'globalweigh', 'globalisconnect', 'globalSocket', 'websocketData',
                'globalIntervalId'
            ])
        },
        watch:{
                '$store.state.websocketData'(v) {
                console.log(v,'接受的ws数据');
                if (v.startsWith('weigh')) {
                    let nowWeighObj = JSON.parse(v.slice(7));
                    console.log(v, this.globalweighHouseCode == false , nowWeighObj.eqCode,'接受的ws数据');
                    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 {}
            }
 
        },
        onShow(){
                this.$store.dispatch('websocketInit')
        },
        rest(){
            this.$store.dispatch('websocketInit')
        }
    
}
</script>
 
<style>
 
</style>