yangan
13 小时以前 a28d0135ee42809b2c5863609da37155d3ecba5b
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
import Vue from 'vue'
import Vuex from 'vuex'
import { webSocketUrl,BaseUrl } from '@/api/request.js'
// 请求相关
import {
    reqGet
} from '@/api/index.js'
Vue.use(Vuex)
 
// 动态底部tabbar
const userRoleTabbar = {
    first: [{
            pagePath: 'pages/tabbar-page/index-tabbar/index-tabbar',
            //#ifdef MP-WEIXIN
            iconPath: '../../static/tabBar-icon/home.png',
            selectedIconPath: '../../static/tabBar-icon/homeblue.png',
            // #endif
            // #ifdef H5
            iconPath: '/static/tabBar-icon/home.png',
            selectedIconPath: '/static/tabBar-icon/homeblue.png',
            // #endif
            text: '首页'
        },
        {
            pagePath: 'pages/customer-page/customer-my/faYunstatistics/faYunstatistics',
            //#ifdef MP-WEIXIN
            iconPath: '../../static/tabBar-icon/statistics.png',
            selectedIconPath: '../../static/tabBar-icon/statisticsactive.png',
            // #endif
            // #ifdef H5
            iconPath: '/static/tabBar-icon/statistics.png',
            selectedIconPath: '/static/tabBar-icon/statisticsactive.png',
            // #endif
            text: '统计'
        },
        {
            pagePath: 'pages/tabbar-page/myPage-tabbar/myPage-tabbar',
            //#ifdef MP-WEIXIN
            iconPath: '../../static/tabBar-icon/Gmine10.png',
            selectedIconPath: '../../static/tabBar-icon/Bmine57.png',
            // #endif
            // #ifdef H5
            iconPath: '/static/tabBar-icon/Gmine10.png',
            selectedIconPath: '/static/tabBar-icon/Bmine57.png',
            // #endif
            text: '我的'
        }
    ],
    second: [{
            pagePath: 'pages/tabbar-page/index-tabbar/index-tabbar',
            //#ifdef MP-WEIXIN
            iconPath: '../../static/tabBar-icon/home.png',
            selectedIconPath: '../../static/tabBar-icon/homeblue.png',
            // #endif
            // #ifdef H5
            iconPath: '/static/tabBar-icon/home.png',
            selectedIconPath: '/static/tabBar-icon/homeblue.png',
            // #endif
            text: '首页'
        },
        {
            pagePath: 'pages/customer-page/customer-my/faYunstatistics/faYunstatistics',
            //#ifdef MP-WEIXIN
            iconPath: '../../static/tabBar-icon/statistics.png',
            selectedIconPath: '../../static/tabBar-icon/statisticsactive.png',
            // #endif
            //#ifdef H5
            iconPath: '/static/tabBar-icon/statistics.png',
            selectedIconPath: '/static/tabBar-icon/statisticsactive.png',
            // #endif
            text: '统计'
        },
        {
            pagePath: 'pages/tabbar-page/myPage-tabbar/myPage-tabbar',
            //#ifdef MP-WEIXIN
            iconPath: '../../static/tabBar-icon/Gmine10.png',
            selectedIconPath: '../../static/tabBar-icon/Bmine57.png',
            // #endif
            //#ifdef H5
            iconPath: '/static/tabBar-icon/Gmine10.png',
            selectedIconPath: '/static/tabBar-icon/Bmine57.png',
            // #endif
            text: '我的'
        }
    ],
    three: [{
            pagePath: 'pages/tabbar-page/index-tabbar/index-tabbar',
            //#ifdef MP-WEIXIN
            iconPath: '../../static/tabBar-icon/home.png',
            selectedIconPath: '../../static/tabBar-icon/homeblue.png',
            // #endif
            //#ifdef H5
            iconPath: '/static/tabBar-icon/home.png',
            selectedIconPath: '/static/tabBar-icon/homeblue.png',
            // #endif
            text: '首页'
        },
        {
            pagePath: 'pages/tabbar-page/myPage-tabbar/myPage-tabbar',
            //#ifdef MP-WEIXIN
            iconPath: '../../static/tabBar-icon/Gmine10.png',
            selectedIconPath: '../../static/tabBar-icon/Bmine57.png',
            // #endif
            //#ifdef H5
            iconPath: '/static/tabBar-icon/Gmine10.png',
            selectedIconPath: '/static/tabBar-icon/Bmine57.png',
            // #endif
            text: '我的'
        }
    ],
    fourth: [{
            pagePath: 'pages/tabbar-page/index-tabbar/index-tabbar',
            //#ifdef MP-WEIXIN
            iconPath: '../../static/tabBar-icon/home.png',
            selectedIconPath: '../../static/tabBar-icon/homeblue.png',
            // #endif
            //#ifdef H5
            iconPath: '/static/tabBar-icon/home.png',
            selectedIconPath: '/static/tabBar-icon/homeblue.png',
            // #endif
            text: '进场'
        },{
            pagePath: 'pages/doorkeeper-page/doorkeeper-index/exit-index',
            //#ifdef MP-WEIXIN
            iconPath: '../../static/tabBar-icon/home.png',
            selectedIconPath: '../../static/tabBar-icon/homeblue.png',
            // #endif
            //#ifdef H5
            iconPath: '/static/tabBar-icon/home.png',
            selectedIconPath: '/static/tabBar-icon/homeblue.png',
            // #endif
            text: '出场'
        },
        {
            pagePath: 'pages/tabbar-page/myPage-tabbar/myPage-tabbar',
            //#ifdef MP-WEIXIN
            iconPath: '../../static/tabBar-icon/Gmine10.png',
            selectedIconPath: '../../static/tabBar-icon/Bmine57.png',
            // #endif
            //#ifdef H5
            iconPath: '/static/tabBar-icon/Gmine10.png',
            selectedIconPath: '/static/tabBar-icon/Bmine57.png',
            // #endif
            text: '我的'
        },
 
    ],
    five:[{
        pagePath: 'pages/tabbar-page/index-tabbar/index-tabbar',
        //#ifdef MP-WEIXIN
        iconPath: '../../static/tabBar-icon/home.png',
        selectedIconPath: '../../static/tabBar-icon/homeblue.png',
        // #endif
        //#ifdef H5
        iconPath: '/static/tabBar-icon/home.png',
        selectedIconPath: '/static/tabBar-icon/homeblue.png',
        // #endif
        text: '首页'
    },
    {
        pagePath: 'pages/loadUnload-page/historyOrder/index',
        //#ifdef MP-WEIXIN
        iconPath: '../../static/tabBar-icon/home.png',
        selectedIconPath: '../../static/tabBar-icon/homeblue.png',
        // #endif
        //#ifdef H5
        iconPath: '/static/tabBar-icon/home.png',
        selectedIconPath: '/static/tabBar-icon/homeblue.png',
        // #endif
        text: '历史收发单'
    },
    {
        pagePath: 'pages/loadUnload-page/orderPlanList/index',
        //#ifdef MP-WEIXIN
        iconPath:  '../../static/tabBar-icon/statistics.png',
        selectedIconPath: '../../static/tabBar-icon/statisticsactive.png',
        // #endif
        //#ifdef  H5
        iconPath:  '/static/tabBar-icon/statistics.png',
        selectedIconPath: '/static/tabBar-icon/statisticsactive.png',
        // #endif
        text: '日计划'
    },
    {
        pagePath: 'pages/tabbar-page/myPage-tabbar/myPage-tabbar',
        //#ifdef MP-WEIXIN
        iconPath: '../../static/tabBar-icon/Gmine10.png',
        selectedIconPath: '../../static/tabBar-icon/Bmine57.png',
        // #endif
        //#ifdef H5
        iconPath: '/static/tabBar-icon/Gmine10.png',
        selectedIconPath: '/static/tabBar-icon/Bmine57.png',
        // #endif
        text: '我的'
    }
    ],
    six:[{
        pagePath: 'pages/tabbar-page/index-tabbar/index-tabbar',
        //#ifdef MP-WEIXIN
        iconPath: '../../static/tabBar-icon/home.png',
        selectedIconPath: '../../static/tabBar-icon/homeblue.png',
        // #endif
        //#ifdef  H5
        iconPath: '/static/tabBar-icon/home.png',
        selectedIconPath: '/static/tabBar-icon/homeblue.png',
        // #endif
        text: '首页'
    },
    {
        pagePath: 'pages/tabbar-page/myPage-tabbar/myPage-tabbar',
        //#ifdef MP-WEIXIN
        iconPath: '../../static/tabBar-icon/Gmine10.png',
        selectedIconPath: '../../static/tabBar-icon/Bmine57.png',
        // #endif
        //#ifdef  H5
        iconPath: '/static/tabBar-icon/Gmine10.png',
        selectedIconPath: '/static/tabBar-icon/Bmine57.png',
        // #endif
        text: '我的'
    }]
}
const store = new Vuex.Store({
    state: {
        // 用戶界面判斷
        userInfo: {},
        roleType: null, // 1客户,2货代,3司机 5装卸员
        userTabbar: [], // 用户所在角色底部菜单,
        // 称重时的重量
        globalweigh: 0,
        // 消息推送
        globalmessage: '',
        // 全局weihousecode
        globalweighHouseCode: '',
        // 全局红外状态
        globalinfraredStatus: false,
        // 司机修改个人信息
        globaluserInfo: {
            phone: '',
            name: '',
            username: '',
            type: 3,
            idCard: '',
            carNo: '',
            carImg: '',
            drivingImg: '',
            axleNum: '',
            weight: '',
            userId: ''
        },
        globalisconnect: true,
        globalisUploadimg: false,
        globalisLogin: false,
        socketTask: null,
        websocketData: null, // 存放从后端接收到的websocket数据
        globalIntervalId: null,
        is_open_socket: false, //避免重复连接
        connectNum: 1, //重连次数,
        reconnectTimeOut: null,  //重新链接的定时器
        // 打印出入门证  一次就可以有打印入门证,  两次可以有入门证 出门证  0次一张都没有
        ablePrintInduction: false, //入门证
        ablePrintOut: false, //出门证
        driverTourImgList: ['https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj1.png',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj2.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj3.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj4.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj5.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj6.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj7.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj8.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj9.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj10.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj11.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj12.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj13.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj14.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj15.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj16.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj17.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj18.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj19.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj20.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj21.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj22.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj23.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj24.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj25.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj26.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj27.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj28.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj29.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj30.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj31.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj32.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj33.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj33-1.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj34.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj35.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj36.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj37.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj38.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj39.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj40.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj41.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj42.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj43.jpg',
            'https://wrzs.czjlchem.com:9090/appimg/image/tour/driver/sj44.jpg',
        ],
        wsgVisiable: false, //磅房忙碌弹窗控制
        wsgContent: '',
        globalIsFirstWeighing: 1, //是否是第一次上磅
        confirmWeighVisiable: false, //磅房管理确认称重完成提示弹窗
        confirmWeighContent: '',
        // 称重稳定态  0/稳定 1/非稳定  非稳定态不能点称重
        globalWarning: false,
        filedId:'', //场地id
        bunkerList:'', //仓库list
        samplingPersonList:'', //采样员list
        pvcIdList:['1818242458023153665'],
    },
    mutations: {
        setUserInfo(state, identity) {
            state.userInfo = userObj[identity]
        },
        // 设置底部栏
        setUserTabbar(state, roleType) {
            state.roleType = roleType
            if (roleType == 1) {
                state.userTabbar = userRoleTabbar.first
                uni.setStorageSync('userTabbar', state.userTabbar)
            } else if (roleType == 2 || roleType == 3) {
                state.userTabbar = userRoleTabbar.second
                uni.setStorageSync('userTabbar', state.userTabbar)
            } else if (roleType == 5) {
                state.userTabbar = userRoleTabbar.five
                uni.setStorageSync('userTabbar', state.userTabbar)
            }else if (roleType == 6) {
                state.userTabbar = userRoleTabbar.fourth
                uni.setStorageSync('userTabbar', state.userTabbar)
            }else if (roleType == 7) {
                state.userTabbar = userRoleTabbar.six
                uni.setStorageSync('userTabbar', state.userTabbar)
            }
        },
        // 改变重量
        changeWeigh(state, payload) {
            state.globalweigh = payload
            console.log(state.globalweigh, '全局重量改变了')
        },
        // 消息推送
        pushMessage(state, payload) {
            state.globalmessage = payload
        },
        // 改变weighHouseCode
        changeweighHouseCode(state, payload) {
            state.globalweighHouseCode = payload
            console.log(state.globalweighHouseCode, 'globalweighHouseCode改变了')
        },
        // 改变红外状态
        changeinfraredStatus(state, payload) {
            state.globalinfraredStatus = payload
        },
        changeuserInfo(state, payload) {
            state.globaluserInfo = payload
        },
        changesocketTask(state, payload) {
            state.socketTask = payload
        },
        // 改版全局websocket状态(判断是否正常链接)
        changeisconnect(state, payload) {
            state.globalisconnect = payload
        },
        changeisUploadimg(state, payload) {
            state.globalisUploadimg = payload
        },
        changeisLogin(state, payload) {
            state.globalisLogin = payload
            console.log(state.globalisLogin, '全局登录状态改变了')
        },
        setWebsocketData(state, data) {
            console.log(data,'data-----')
            state.websocketData = data
        },
        // 改变重连状态
        changereconnectState(state, payload) {
            state.is_open_socket = payload
        },
        // 改变重连次数
        changereconnectNum(state, payload) {
            if (payload.isWeigh) {
                state.connectNum = payload.connectNum
            } else {
                if (state.connectNum < 6) {
                    state.connectNum += payload.connectNum
                } else {
                    state.connectNum = payload.connectNum
                }
            }
        },
        changeablePrintInduction(state, payload) {
            state.ablePrintInduction = payload
        },
        changeablePrintOut(state, payload) {
            state.ablePrintOut = payload
        },
        changewsgVisiable(state, payload) {
            state.wsgVisiable = payload
        },
        changewsgContent(state, payload) {
            state.wsgContent = payload
        },
        changeglobalIsFirstWeighing(state, payload) {
            state.globalIsFirstWeighing = payload
        },
        changeconfirmWeighVisiable(state, payload) {
            state.confirmWeighVisiable = payload
        },
        changeconfirmWeighContent(state, payload) {
            state.confirmWeighContent = payload
        },
        // 改变稳定态
        changeWarning(state, payload) {
            state.globalWarning = payload
        },
        // 场地filedId的获取
        getFiledId(state, payload) {
            console.log(payload,'filedId=====')
            state.filedId = payload
            uni.setStorageSync('filedId', state.filedId)
        },
        getBunkerList(state, payload) {
            state.bunkerList = payload
            uni.setStorageSync('bunkerList', state.bunkerList)
        },
        getSamplingPersonList(state, payload) {
            console.log('我执行了samplingPersonList====',payload)
            state.samplingPersonList = payload
            uni.setStorageSync('samplingPersonList', state.samplingPersonList)
        },
    },
    actions: {
        websocketInit({ state, dispatch, commit }) {
            // #ifdef H5
            let wsUrl = `${webSocketUrl}?UUID=${uni.getStorageSync('token')}`
            // #endif
            // #ifndef H5
            let wsUrl = `${webSocketUrl}?access_token=${uni.getStorageSync('token')}`
            // #endif
            state.socketTask = uni.connectSocket({
                url: wsUrl,
                header: {
                clientToc: 'Y' ,
                'CLIENT_TOC': 'Y',
            },
                success: res => {
                    console.log(res, 'socketSuccess')
                    if (res.errMsg === 'connectSocket:ok') {
                        commit('changeisconnect', true)
                        commit('changereconnectState', true)
                    }
                },
                fail: res => {
                    console.log(res, 'socketFail')
                    console.log('ws失败');
                    commit('changereconnectState', false)
                    dispatch('reconnect')
                    commit('changeisconnect', false)
                }
            })
            state.socketTask.onOpen(() => dispatch('websocketOnOpen'))
            state.socketTask.onMessage(result => dispatch('websocketOnMessage', result.data))
            state.socketTask.onClose(e => dispatch('websocketOnClose', e))
            state.socketTask.onError(e => dispatch('websocketOnError', e))
        },
        websocketOnOpen({ state, commit }) {
            console.log('ws打开')
            clearInterval(state.reconnectTimeOut) //清除上一次的定时器
            clearInterval(state.globalIntervalId)  //清除心跳
            state.globalIntervalId = setInterval(() => {
                state.socketTask.send({
                    data: JSON.stringify({ type: 'ping' }),
                    success(e) {
                        console.log(e, '发送心跳成功')
                    }
                })
            }, 30000)
        },
        websocketOnClose({ state, commit, dispatch }, e) {
            if (!state.socketTask) return
            console.log('ws关闭', e)
            state.socketTask.close(e => {
                commit('changeisconnect', false)
            })
            clearInterval(state.globalIntervalId)
            clearInterval(state.reconnectTimeOut)
            state.socketTask = null
            commit('changereconnectState', false)
            if ((state.connectNum < 6 || state.connectNum.connectNum < 6) && state.globalisLogin) {
                uni.showToast({
                    title: '连接失败,正在尝试重新连接',
                    icon: 'none'
                })
                commit('changereconnectNum', { connectNum: 1, isWeigh: false })
                dispatch('reconnect')
            } else if (state.connectNum >= 6 && state.globalisLogin) {
                commit('changereconnectNum', { connectNum: 1, isWeigh: false })
                uni.showToast({
                    title: '网络异常,请稍后重试',
                    icon: 'none'
                })
            } else {
                return
            }
        },
        websocketOnError({ state, commit, dispatch }, e) {
            // 如果重连状态为false则不进行重连,为true才会
            console.log('ws报错', e)
            clearInterval(state.globalIntervalId)
            clearInterval(state.reconnectTimeOut)
            state.socketTask = null
            commit('changereconnectState', false)
            if (state.connectNum < 6 || state.connectNum.connectNum < 6 && state.globalisLogin) {
                uni.showToast({
                    title: '连接失败,正在尝试重新连接',
                    icon: 'none'
                })
                commit('changereconnectNum', { connectNum: 1, isWeigh: false })
                dispatch('reconnect')
            } else if (state.connectNum > 6 && state.globalisLogin) {
                commit('changereconnectNum', { connectNum: 1, isWeigh: false })
                uni.showToast({
                    title: '网络异常,请稍后重试',
                    icon: 'none'
                })
            } else {
                return
            }
        },
        // 接收数据
        websocketOnMessage({ state, commit }, result) {
            commit('setWebsocketData', result)
        },
        // 重新连接
        reconnect({ state, commit, dispatch }) {
            console.log(state.is_open_socket, '重新连接socket状态');
            clearInterval(state.globalIntervalId)
            if (!state.is_open_socket && state.globalisLogin) {
                state.reconnectTimeOut = setInterval(() => {
                    dispatch('websocketInit')
                }, 5000)
            }
        },
 
        //filedId
        async getBunkerList({ state,dispatch, commit }) { //获取filedId
            // this.$reqGet(`getList/${this.deptId}`).then(res => {
            //   console.log(res,'想得到filedId')
            // })
            let deptId = uni.getStorageSync('userInfo').deptIds
            console.log(deptId,'deptId====')
            await uni.request({  //获取deptId
                url: `/wrzs/jccoalfiled/list/${deptId}`,
                method: 'GET',
                header: {
                    Authorization: 'Bearer' + ' ' + uni.getStorageSync('token'),
                    clientToc: 'Y',
                    'CLIENT_TOC': 'Y',
                },
                success: res => {
                    console.log(res,'filedId接口000000000000')
                    commit('getFiledId',res.data.data[0].id || '')
                    dispatch('getFiledIdCoalBunker')
                    // console.log(res,'shuj------')
                    // this.filedId = res.data?.data.length > 0 ? res.data.data[0].id : '';
                    // this.getFiledIdCoalBunker()
                }
            })
 
        },
        getSamplingPerson({ state, commit }) {  //采样人
            let params = {
                current: 1,
                size: 999,
                type: 7
            }
            reqGet('pageCarAndHuoDai',params).then(res => {
              console.log(res,'pageCarAndHuoDai======')
                if(res.code == 0) {
                    let temp = res.data.records
                    commit('getSamplingPersonList',temp)
                }
            })
        },
        getFiledIdCoalBunker({ state, commit }) {  //仓库列表(采样地点)
            let filedId = uni.getStorageSync('filedId')
            console.log(filedId,'最终的filedId=============')
            reqGet('getFiledIdCoalBunker', {filedId: filedId}).then(res => {
                console.log(res,'res----仓库')
                commit('getBunkerList',res.data)
            })
        },
    },
    getters:{
        websocketData:(state) => state.websocketData,
        samplingPersonList: (state) => state.samplingPersonList
 
    }
})
 
export default store