Houjie
2025-07-07 0a48655d2162b709ecb80d249a4085971add6140
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<template name="home">
    <view>
        <scroll-view>
            <!-- 轮播 -->
            <swiper class="screen-swiper square-dot" :indicator-dots="true" :circular="true" :autoplay="true"
                interval="5000" duration="500" :style="[{animation: 'show 0.2s 1'}]">
                <swiper-item v-for="(item,index) in swiperList" :key="index">
                    <image :src="item.url" mode="aspectFill" v-if="item.type=='image'"></image>
                    <video :src="item.url" autoplay loop muted :show-play-btn="false" :controls="false"
                        objectFit="cover" v-if="item.type=='video'"></video>
                </swiper-item>
            </swiper>
 
            <!-- 设备维修 -->
            <view class="cu-bar bg-white solid-bottom" :style="[{animation: 'show 0.5s 1'}]">
                <view class="action">
                    <text class='cuIcon-title text-blue'></text>工作台
                </view>
            </view>
 
            <!--             <view class="cu-list grid col-4 text-sm">
                <view class="cu-item animation-slide-bottom" :style="[{animationDelay: (index + 1)*0.05 + 's'}]" v-for="(item,index) in usList" :key="index" @tap="goPage(item.page)">
                    <view class="padding text-center">
                        <image :src="item.icon" style="width:28px;height:28px;">
                            <view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" v-if="getTtemDotInfo(item)">
                               <block v-if="getTtemDotInfo(item)">{{getTtemDotInfo(item)}}</block>
                            </view>
                        </image>
                        <view class="margin-top-xs">{{item.title}}</view>
                    </view>
                </view>
            </view> -->
            <view class="cu-list grid col-4 text-sm">
                <view class="cu-item animation-slide-bottom" :style="[{animationDelay: (index + 1)*0.05 + 's'}]"
                    v-for="(item, index) in usList" :key="index" @tap="goPage(item.page)">
                    <view class="padding text-center">
                        <image :src="item.icon" style="width:28px;height:28px;">
                            <view class="cu-tag badge margin-top-sm" style="margin-left:1.2em"
                                v-if="getTtemDotInfo(item)"></view>
                        </image>
                        <view class="margin-top-xs">{{ item.title }}</view>
                    </view>
                </view>
            </view>
 
            <!-- 设备保养 -->
            <view class="cu-bar bg-white solid-bottom margin-top" :style="[{animation: 'show 0.6s 1'}]">
                <view class="action">
                    <text class='cuIcon-title text-yellow'></text>保养
                </view>
            </view>
            <view class="cu-list grid col-4 text-sm">
                <view class="cu-item animation-slide-bottom" :style="[{animationDelay: (index + 1)*0.1 + 's'}]"
                    v-for="(item,index) in osList" :key="index" @tap="goPage(item.page)">
                    <view class="padding text-center">
                        <image :src="item.icon" style="width:28px;height:28px;" />
                        <view class="margin-top-xs">{{item.title}}</view>
                    </view>
                </view>
            </view>
 
 
            <!-- 设备维修 -->
            <view class="cu-bar bg-white solid-bottom margin-top" :style="[{animation: 'show 0.6s 1'}]">
                <view class="action">
                    <text class='cuIcon-title text-blue'></text>维修
                </view>
            </view>
            <view class="cu-list grid col-4 text-sm">
                <view class="cu-item animation-slide-bottom" :style="[{animationDelay: (index + 1)*0.1 + 's'}]"
                    v-for="(item,index) in wsList" :key="index" @tap="goPage(item.page)">
                    <view class="padding text-center">
                        <image :src="item.icon" style="width:28px;height:28px;" />
                        <view class="margin-top-xs">{{item.title}}</view>
                    </view>
                </view>
            </view>
 
        </scroll-view>
        <view class="cu-tabbar-height margin-top"></view>
    </view>
</template>
 
<script>
    import {
        ACCESS_TOKEN
    } from '@/common/util/constants.js'
    import {
        us,
        os,
        ws
    } from '@/common/util/work.js'
    import socket from '@/common/js-sdk/socket/socket.js'
    export default {
        name: 'home',
        props: {
            cur: String,
        },
        watch: {
            cur: {
                immediate: true,
                handler: function(val, oldVal) {
                    console.log('cur', val, oldVal)
                    this.initMenu()
                },
            },
        },
        data() {
            return {
                url: {
                    bindingThirdPhone: '/sys/permission/getUserPermissionByToken',
                    countItem: '/assign/flow/taskCountBySelf'
                },
                swiperList: [{
                        id: 1,
                        type: 'image',
                        url: '/static/banner/eam_banner1.png',
                        link: ''
                    },
                    {
                        id: 2,
                        type: 'image',
                        url: '/static/banner/eam_banner2.png',
                        link: ''
                    },
                    {
                        id: 3,
                        type: 'image',
                        url: '/static/banner/eam_banner3.png',
                        link: ''
                    },
                    {
                        id: 4,
                        type: 'image',
                        url: '/static/banner/eam_banner4.png',
                        link: ''
                    },
                ],
                middleApps: [{
                        icon: 'line2_icon1.png',
                        title: '审批',
                        'text': '个人审批'
                    },
                    {
                        icon: 'line2_icon2.png',
                        title: '审批稿',
                        'text': '审批草稿箱'
                    },
                ],
                usList: us.data,
                osList: os.data,
                wsList: ws.data,
                msgCount: 0,
                toDomsgCount: 0,
 
                dot: {
                    mailHome: false
                }
            }
        },
        methods: {
            initMenu() {
                console.log("-----------home------------")
                this.onSocketOpen()
                this.onSocketReceive()
                this.saveClientId()
                this.taskCountBySelf();
                this.loadCount(0);
            },
            goPage(page) {
                if (!page) {
                    return false;
                }
                if (page === 'annotationList') {
                    this.msgCount = 0
                }
                this.dot[page] = false
                this.$Router.push({
                    name: page
                })
            },
            // 启动webSocket
            onSocketOpen() {
                socket.init('websocket');
            },
            onSocketReceive() {
                var _this = this
                socket.acceptMessage = function(res) {
                    // console.log("页面收到的消息", res);
                    if (res.cmd == "topic") {
                        //系统通知
                        _this.loadCount('1')
                    } else if (res.cmd == "user") {
                        //用户消息
                        _this.loadCount('2')
                    } else if (res.cmd == 'email') {
                        //邮件消息
                        _this.loadEmailCount()
                    }
                }
            },
 
            taskCountBySelf() {
                let token = uni.getStorageSync(ACCESS_TOKEN)
                this.$http.get(this.url.countItem).then(res => {
                    this.toDomsgCount = res.data.result
                })
            },
            loadCount(flag) {
                console.log("loadCount::flag", flag)
                let url = '/sys/annountCement/listByUser';
                this.$http.get(url).then(res => {
                    console.log("res::", res)
                    if (res.data.success) {
                        let msg1Count = res.data.result.anntMsgTotal;
                        let msg2Count = res.data.result.sysMsgTotal;
                        this.msgCount = msg1Count + msg2Count
                        console.log("this.msgCount", this.msgCount)
                    }
                })
            },
            saveClientId() {
                let token = uni.getStorageSync(ACCESS_TOKEN)
                this.$http.get(this.url.bindingThirdPhone, {
                    params: {
                        token: token
                    }
                }).then(res => {
                    const authData = res.data.result.auth
 
                    // 确保是数组
                    if (!Array.isArray(authData)) {
                        console.warn('auth 不是数组:', authData)
                        return
                    }
 
                    // 存入 store
                    this.$store.dispatch('saveAuth', authData)
                    console.log('当前 store 中的 auth:', this.$store.getters.getAuth)
                }).catch(err => {
                    console.error("获取 auth 失败:", err)
                })
            },
 
            loadEmailCount() {
                this.dot.mailHome = true
            },
            getTtemDotInfo(item) {
                if (item.page === 'ToDoList' && this.toDomsgCount > 0) {
                    // return this.toDomsgCount
                    return true
                }
                return false;
            }
        }
    }
</script>
 
<style scoped>
    .cu-list.grid>.cu-item {
        padding: 0px 0px;
    }
 
    .line2-icon {
        width: 60px;
        height: 60px;
    }
</style>