zengh
2022-05-16 63ad2c3598400370dd7da5534659fd7e768a0a4a
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
<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../style/FlareClusterLayer_v3.css">
    <script src='../../lib/jquery.js'></script>
    <script src='../js/FlareClusterLayer_v3.js'></script>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.12"></script>
    <!-- element ui -->
    <link rel="stylesheet" href="../../lib/elementUi.css">
    <script src="../../lib/elementUi.js"></script>
    <!-- axios -->
    <script src='../../lib/axios.js'></script>
    <!-- 视频 -->
    <script src='../../../realVideo/hls.js'></script>
    <!-- layui -->
    <link rel="stylesheet" href="../../lib/layui/css/layui.css" media="all">
    <style>
        a:hover {
            color: white;
        }
 
        body {
            width: 360px;
            height: 484px;
            overflow: hidden;
        }
 
        #appliutwo {
            width: 330px;
            height: 484px;
            border-radius: 10px;
            margin: 16px 15px 16px 15px;
            overflow: hidden;
            /* border: springgreen solid 0.5px; */
        }
 
        .flare-liu-top {
            width: 330px;
            height: 90px;
            /* border: rgb(211, 154, 31) solid 0.5px; */
            display: flex;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            color: white;
            border-radius: 5px 5px 5px 5px;
        }
 
        .f-l-t-heard {
            width: 300px;
            height: 30px;
            font-size: 18px;
            font-family: PingFangSC-Regular;
        }
 
        .f-l-t-right {
            width: 300px;
            height: 28px;
            display: flex;
            align-items: center;
            color: white;
            justify-content: space-around;
        }
 
        .f-l-t-center {
            width: auto;
            position: relative;
            left: -103px;
            top: 5px;
        }
 
        .f-l-t-r-msg {
            width: 200px;
            height: 28px;
            position: relative;
            top: 10px;
            left: -5px;
        }
 
        .f-l-t-r-but {
            width: 72.531px;
            height: 28px;
            line-height: 28px;
            text-align: center;
            background: rgba(255, 255, 255, .2);
            color: white;
            /* border: wheat 1px solid; */
        }
 
        .f-l-t-r-but a {
            color: white;
            width: 48.52px;
            height: 16px;
        }
 
        .flare-liu-body {
            width: 330px;
            height: 361px;
            /* border: rgb(106, 20, 187) solid 0.5px; */
 
        }
 
        .r-b-top {
            height: 250px;
            display: flex;
            display: flex;
            flex-direction: column;
        }
 
        .r-b-t-main {
            display: flex;
            align-items: center;
            justify-content: space-between;
 
            padding: 10px 0 10px 0;
            /* border: rgb(211, 154, 31) solid 0.5px; */
 
            margin-bottom: 5px;
        }
 
        .r-b-t-left {
            display: block;
            width: 27%;
 
        }
 
        .r-b-t-right {
            display: block;
            width: 70%;
            color: #5d5d5d;
            font-size: 12px;
 
        }
 
        .r-b-t-r-label {
            float: left;
            margin-right: 10px;
            padding: 0 10px 0 10px;
            /* border: 1px solid rgba(0, 0, 0, 0.5); */
            border-radius: 5px;
        }
 
        .r-b-t-r-imgsl {
 
            float: left;
            padding: 0 3px 0 3px;
        }
 
        .el-tabs__content {
            height: 360px;
        }
 
        .el-tabs__active-bar {
            background-color: aquamarine;
        }
 
        .el-tabs__item.is-active,
        .el-tabs__item:hover {
            color: #5d5d5d;
        }
 
        video::-webkit-media-controls-timeline {
            display: none;
        }
    </style>
</head>
 
<body>
    <div id="appliutwo" class='police-details-box' class="layui-anim" data-anim="layui-anim-down">
        <!-- 从layui传值给iframe 的占位input -->
        <!-- <div class="aaa bbb">13223456745</div> -->
        <input type="text" id="sidIput" ref="sidIput" style="display: none;">
        <div class="flare-liu-top">
            <div class="f-l-t-heard">{{name}}</div>
            <div class="f-l-t-center">{{machineCode}}</div>
            <div class="f-l-t-right">
                <div class="f-l-t-r-msg">{{statesss}}</div>
                <div class="f-l-t-r-but"> <a href="#" @click="looks">查看详情</a> </div>
            </div>
        </div>
        <div class="flare-liu-body" v-if="'start'">
            <el-tabs v-model="activeName" @tab-click="handleClick">
                <el-tab-pane label="基本信息" name="first">
                    <div class="r-b-top">
                        <div class="r-b-t-main">
                            <span class="r-b-t-left">设备名称</span>
                            <span class="r-b-t-right">{{ name }}</span>
                        </div>
                        <div class="r-b-t-main">
                            <span class="r-b-t-left">使用方</span>
                            <span class="r-b-t-right">{{ deptname }}</span>
                        </div>
                        <div class="r-b-t-main">
                            <span class="r-b-t-left">设备联系人</span>
                            <span class="r-b-t-right">{{ contacts }}: {{ calls }}</span>
                        </div>
                        <!-- 设备标签待定 -->
                        <!-- <div class="r-b-t-main">
                            <span class="r-b-t-left">设备标签</span>
                            <span class="r-b-t-right">
                                <div
                                class="r-b-t-r-label"
                                v-for="(value,index) in labels"
                                :key="index"
                                >
                                     {{value}}
                                </div>
                            </span>
                        </div> -->
                        <!-- 图暂时没有 -->
                        <div class="r-b-t-main">
                            <span class="r-b-t-left" style="position: relative; top: -27px">部署图片</span>
                            <span class="r-b-t-right">
                                <div class="r-b-t-r-imgsl" v-for="(value, index) in imgsl" :key="index">
                                    <!-- <el-image style="width: 68px; height: 68px" :src="value" :preview-src-list="imgsl"
                                        v-show="value != 'no'"> -->
                                    <el-image style="width: 68px; height: 68px" :src="value" v-show="value != 'no'">
                                    </el-image>
                                    <div v-show="value == 'no'" style="
                                        width: 68px;
                                        height: 68px;
                                        text-algin: center;
                                        color: rgba(0, 0, 0, 0.5);
                                        ">
                                        无图片
                                    </div>
                                </div>
                            </span>
                        </div>
                        <div class="r-b-t-main">
                            <span class="r-b-t-left">部署时间</span>
                            <span class="r-b-t-right">{{ deploymentTime }}</span>
                        </div>
                    </div>
                </el-tab-pane>
                <el-tab-pane label="现场视频" name="second">
                    <video style="height: auto;width: 100%;" controls="controls" id="real_video_conversation" src="">
                    </video>
                </el-tab-pane>
                <!-- <el-tab-pane label="other" name="second">other</el-tab-pane> -->
            </el-tabs>
        </div>
    </div>
    <script src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script>
            // var index = parent.layer.getFrameIndex(window.name);
 
    </script>
    <script>
        var me = new Vue({
            el: '#appliutwo',
            data: {
                num: '',
                name: '',
                statesss: '',
                // start:false,
                //详细信息data
                ourData: '',
                // names: '',
                contacts: '',
                deptname: '',//使用方
                ourd: '',//视频data
                calls: '',
                imgsl: [],
                deploymentTime: '',
                oldtime: '',
                newtime: '',
                machineCode: '',
 
                a: true,
                activeName: 'first'
            },
            methods: {
                looks() {
                    window.parent.parent.location.hash = `#/dataL/dataL?id=${this.ourData.id}&deviceName=${this.ourData.deviceName}&deviceNumber=${this.ourData.deviceNumber}&deviceType=${this.ourData.deviceType}&ownership=${this.ourData.ownership}&ownerId=&devicestate=${this.ourData.devicestate}&stime=${this.ourData.stime}&parentId=${this.ourData.parentId}&jd=${this.ourData.jd}&wd=${this.ourData.wd}&street=${this.ourData.street}&dtype=${this.ourData.dtype}&serialNumber=${this.ourData.serialNumber}&stype=&channelNumber=${this.ourData.channelNumber}&pay=&expireTime=${this.ourData.expireTime}&heartbeat=${this.ourData.heartbeat}&province=${this.ourData.province}&city=${this.ourData.city}&district=${this.ourData.district}&state=${this.ourData.state}&reason=&deptId=${this.ourData.deptId}&onePhone=${this.ourData.onePhone}&twoPhone=${this.ourData.twoPhone}&oneId=${this.ourData.oneId}&twoId=&threeId=&oneContacts=${this.ourData.oneContacts}&twoContacts=${this.ourData.twoContacts}&type=${this.ourData.type}&beginTime=&endTime=&pid=${this.ourData.pid}&onlineStatus=${this.ourData.onlineStatus}&jtype=${this.ourData.jtype}&threePhone=${this.ourData.threePhone}&threeContacts=${this.ourData.threeContacts}`;
                },
                getdatas(dat) {
 
                    var xhr = null
                        , my = this
                        , url = '/api/depl/selectInfo?deviceNumber=' + dat.deviceNumber;
                    if (XMLHttpRequest) { //http请求
                        xhr = new XMLHttpRequest();
                    } else {
                        xhr = new ActiveXObject("Microsoft.XMLHTTP");
 
                    }
                    xhr.open("post", url, true);
                    xhr.send();
                    xhr.onreadystatechange = function () {
                        if (xhr.readyState === 4) {
                            if (xhr.status === 200) {
                                // 判断isJson是否传进来了
                                var imgD = JSON.parse(xhr.responseText);// JSON转js
                                // console.log(imgD)
                                var imgdatas = [];
                                if (imgD.data.length != 0) {
                                    if (imgD.data[0].paddress.length != 0) {
                                        imgdatas = imgD.data[0].paddress.split(',');
                                    } else {
                                        my.imgsl = imgdatas.length == 0 ? ['no'] : imgdatas;
                                    }
                                } else {
 
                                }
                                // var imgdatas = imgD.data[0].paddress.split(',');
                                my.imgsl = imgdatas.length == 0 ? ['no'] : imgdatas;
                                // my.imgsl = [ //最多3张照片
                                //     "https://resource-city.sensoro.com/B8D675A3C4F71C5C8DE2FD764881BE57",
 
                                //     "https://resource-city.sensoro.com/1723C1A66DB44F792564F3648E5AA1EE",
                                //     "https://resource-city.sensoro.com/6E0FB78DC42C35F3B8FF0F6A03472433",
                                // ]
                                // console.log(imgD, my.imgsl);
                            }
                        }
                    }
                    this.name = dat.deviceName.length >= 15 ? dat.deviceName.substring(0, 15) + '···' : dat.deviceName;
                    me.num = dat.deviceNumber;
                    this.evaluate = "空气质量";
                    this.machineCode = "无数据" && dat.deviceNumber;
                    this.smoke = "烟雾";
                    this.proportion = "电量";
                    this.ReportTime = "最近上报:" + dat.heartbeat;
                    this.contacts = "无数据" && dat.oneContacts;
                    this.calls = "无数据" && dat.onePhone;
                    this.labels = ["无数据"] && [dat.deviceType];
                    // var imgD = ["no"];
                    // this.imgsl = ["no"] && imgD;
                    this.deploymentTime = "无数据" && dat.stime;
 
                    var ct = document.getElementsByClassName('flare-liu-top')[0];
                    var cordActive = document.getElementsByClassName('el-tabs__active-bar')[0];//滑块背景颜色
 
                    // if (dat.state != '') {
                    //     ct.style.backgroundImage = 'linear-gradient(to right, #F49966 , #F49966';
                    //     cordActive.style.backgroundImage = 'linear-gradient(to right, #F49966 , #F49966';
                    //     this.statesss = '故障';
                    // } else {
                    //     if (dat.jtype != 1) {
                    //         if (dat.onlineStatus == 1) {//el-tabs__active-bar
                    //             ct.style.backgroundImage = 'linear-gradient(to right, #32C1A2 , #32C1A2';
                    //             cordActive.style.backgroundImage = 'linear-gradient(to right, #32C1A2 , #32C1A2';
                    //             this.statesss = '在线';
                    //         } else {
                    //             ct.style.backgroundImage = 'linear-gradient(to right, #CDCDCD , #CDCDCD';
                    //             cordActive.style.backgroundImage = 'linear-gradient(to right, #CDCDCD , #CDCDCD';
                    //             this.statesss = '离线';
                    //         }
                    //     } else {
                    //         ct.style.backgroundImage = 'linear-gradient(to right, #F35B5B , #F35B5B';
                    //         cordActive.style.backgroundImage = 'linear-gradient(to right, #F35B5B , #F35B5B';
                    //         this.statesss = '警报';
                    //     }
                    // }
                    if (dat.dtype == 3) {
                        ct.style.backgroundImage = 'linear-gradient(to right, #F49966 , #F49966';
                        cordActive.style.backgroundImage = 'linear-gradient(to right, #F49966 , #F49966';
                        this.statesss = '故障';
                    } else if (dat.dtype == 1) {//el-tabs__active-bar
                        ct.style.backgroundImage = 'linear-gradient(to right, #32C1A2 , #32C1A2';
                        cordActive.style.backgroundImage = 'linear-gradient(to right, #32C1A2 , #32C1A2';
                        this.statesss = '正常';
                    } else if (dat.dtype == 0) {
                        ct.style.backgroundImage = 'linear-gradient(to right, #CDCDCD , #CDCDCD';
                        cordActive.style.backgroundImage = 'linear-gradient(to right, #CDCDCD , #CDCDCD';
                        this.statesss = '离线';
 
                    } else if (dat.dtype == 2) {
                        ct.style.backgroundImage = 'linear-gradient(to right, #F35B5B , #F35B5B';
                        cordActive.style.backgroundImage = 'linear-gradient(to right, #F35B5B , #F35B5B';
                        this.statesss = '预警';
                    }
 
 
                },
                getUser(dat) {
                    var xhr = null
                        , my = this
                        , url = '/api/equipment/equipment/detail?id=' + dat;
                    // if (XMLHttpRequest) { //http请求
                    //     xhr = new XMLHttpRequest();
                    // } else {
                    //     xhr = new ActiveXObject("Microsoft.XMLHTTP");
 
                    // }
                    // xhr.open("get", url, true);
                    // xhr.send();
                    // xhr.onreadystatechange = function () {
                    //     if (xhr.readyState === 4) {
                    //         if (xhr.status === 200) {
                    //             // 判断isJson是否传进来了
                    //             var data = JSON.parse(xhr.responseText);// JSON转js
                    //             my.ourd = data.data;
                    //             my.deptname = my.ourd.deptName;
                    //         }
                    //     }
                    // }
                    axios.get(url).then((res) => {
                        console.log(typeof res,34234534345341)
                        var data = JSON.parse(res);// JSON转js
                        my.ourd = data.data;
                        my.deptname = my.ourd.deptName;
                    })
 
                },
                handleClick(tab, event) {//标签tab点击事件
                    // console.log(tab, event);
                },
                openRealVideoBox(serialNumber, channelNumber) {
                    var that = this;
                    var newAxios = axios.create({
                        baseURL: "https://web.byisf.com:18000",
                        withCredentials: false,
                        headers: {
                            "Content-type": "application/x-www-form-urlencoded",
                        },
                    });
 
                    //this.form.serialNumber
                    newAxios
                        .post(
                            "/api_control",
                            {},
                            {
                                params: {
                                    param: JSON.stringify({ PktType: "GetAccessToken" }),
                                },
                            }
                        )
                        .then((res) => {
                            newAxios
                                .get(
                                    `https://web.byisf.com:18000/GetPlayUrl?deviceCode=${serialNumber}&chl=${channelNumber}`
                                )
                                .then((result) => {
                                    that.videoSource = result.data.data.m3u8;
                                    if (Hls.isSupported()) {
                                        var dom = document.getElementById("real_video_conversation");
                                        that.hls = new Hls();
                                        var m3u8Url = decodeURIComponent(that.videoSource);
                                        that.hls.loadSource(m3u8Url);
                                        that.hls.attachMedia(dom);
                                        that.hls.on(Hls.Events.MANIFEST_PARSED, function () {
                                            dom.play();
                                        });
                                        that.hls.on(Hls.Events.ERROR, function (event, data) {
                                            // console.log(data, 4566824159, "视频播放有问题!!!");
                                            if (data.fatal) {
                                                switch (data.type) {
                                                    case Hls.ErrorTypes.NETWORK_ERROR:
                                                        // try to recover network error
                                                        console.log(
                                                            "fatal network error encountered, try to recover"
                                                        );
                                                        that.hls.startLoad();
                                                        break;
                                                    case Hls.ErrorTypes.MEDIA_ERROR:
                                                        console.log(
                                                            "fatal media error encountered, try to recover"
                                                        );
                                                        that.hls.recoverMediaError();
                                                        break;
                                                }
                                            }
                                        })
                                    }
                                })
                        })
                }
            },
            watch: {
                activeName() {
                    if (this.activeName == "second") {
                        this.i++;
                        this.openRealVideoBox(this.ourd.serialNumber, this.ourd.channelNumber);
                    } else {
                        var dom = document.getElementById("real_video_conversation");
                        if (dom.getAttribute("src") != "") {
                            dom.pause();
                            dom.setAttribute("src", "");
                            this.hls.destroy();
                        }
                    }
                },
            },
            mounted() {
                this.oldtime = setTimeout(() => {//需要同步数据处理,input中value在mounted中没有直接传值
                    clearTimeout(this.oldtime);
                    // console.log(this.$refs.sidIput.value)
                    this.ourData = JSON.parse(this.$refs.sidIput.value);//json对象转js对象
                    this.getUser(this.ourData.id);
                    // console.log(this.ourData);
                    this.getdatas(this.ourData);
                }, 50);
 
 
            }
        })
    </script>
</body>
 
</html>