1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321 |
- var app = new THING.App({
- url: '/api/scene/00c8b14766e1616e3bf14604',
-
- background: '/uploads/wechat/163607/file/广西东盟项目/Image/op0.png'
- });
- app.camera.xAngleLimitRange = [0, 90];
- $("#div3d").css("cursor", "pointer");
- var miniMapCtrl = null;
- var panel;
- var panel_;
- var ui;
- var uis = []
- var uis_array = []
- var uis_list = []
- var uis_name = {}
- var floorID;
- var ev_name = "";
- var floorName = '';
- var floorName1 = '';
- var truck = null;
- var panelArr = [];
- var webSocket;
- var tileLayer1 = null;
- var box = null;
- var fpsCtrl = null;
- var cameraInitPos = null;
- var fullScreenState = false;
- var skyBox = null;
- var hiddenControlTimer = null;
- var showControlTimer = null;
- var cameraDistace = [];
- var building = null;
- var mainPanle;
- var restartTime = 5000;
- var rotateTimer = null;
- var sidebar = {
- znyg: false,
- znjk: false,
- znsx: false,
- enterBuilding: false,
- expandBuilding: false,
- deviceShow: false,
- electricalFire: false,
- equipment: false,
- device_add: false
- };
- var stateArray = []
- var dataObj = {
- checkbox: {},
- };
- var device = null;
- var dome;
- var ev_object;
- var position;
- var baseURL = "https://s3.ax1x.com/2021/01/28/";
- var iconUrl = "/uploads/wechat/163607/file/广西东盟项目/iconfont/";
- var filePath = '/uploads/wechat/5oiR5pyJ5pyA6ZW/55qE572R5ZCN5LiN5L+h5L2g5pWw5pWw/file/ScenePreview/';
- var api = 'http://121.40.217.77:8081';
- var fileArr = [
- "https://www.layuicdn.com/layui/layui.js",
- 'https://www.layuicdn.com/layui/css/layui.css',
- filePath + 'assets/css/index.css',
- filePath + 'assets/font-awesome-4.7.0/css/font-awesome.min.css',
- filePath + 'assets/css/myAlert.css',
- filePath + 'assets/css/sweetalert2.min.css',
- filePath + 'assets/js/sweetalert2.all.min.js',
- filePath + 'assets/js/myAlert.js',
- filePath + 'assets/js/posTransform.js',
- filePath + 'assets/js/expandFloor.js',
- '/guide/lib/echarts.min.js',
- '/uploads/wechat/163607/file/广西东盟项目/JS/Character.js',
- '/uploads/wechat/163607/file/广西东盟项目/JS/UIAnchor.js',
- '/uploads/wechat/163607/file/广西东盟项目/JS/FloorClick.js',
- '/uploads/wechat/163607/file/广西东盟项目/JS/CreateHtml.js',
-
- '/uploads/wechat/163607/file/广西东盟项目/JS/RegisterEvent.js',
- ];
- THING.Utils.dynamicLoad(fileArr, function () {
- app.on('load', function (ev) {
-
- var campus = ev.campus;
- skyBox = app.skyBox;
- app.level.change(ev.campus);
- ev.campus.azimuth = '180';
- mainPanle = new MainPanel(app);
- mainPanle.createToolsPanel();
- creatFloorChoose();
-
-
- let tjsLnglat = app.root.defaultCampus.extraData;
- if (tjsLnglat != undefined && tjsLnglat != null) {
- tjsLnglat = tjsLnglat.coordinates;
- if (tjsLnglat != undefined && tjsLnglat != null) {
- tjsLnglat = tjsLnglat.split(",");
- }
- } else {
- ev.campus.extraData = { coordinates: "116.4641,39.98606" }
- }
- createHtml();
- restarRotate();
- });
- });
- function select_device(){
- var url = ""
- var type = ""
- var bool;
- $.ajax({
- type: "POST",
- url: api + '/thingjs/thingjsDeviceQuery',
- dataType: "json",
- data:{thingjsFloorId:floorID},
- async: false,
- success: function (object) {
- var data = object.data
- for(let i=0;i<data.length;i++){
- if(data[i].bool === "true"){
- bool = true
- }else{
- bool = false
- }
- if (data[i].deviceType === 'IPC') {
- url = 'https://model.3dmomoda.com/models/2DBD1DCD7B5F49BDA43CC6444FC5CBD0/0/gltf'
- type = "摄像头"
- }
- var abc = app.query('#' + floorID)[0]
- var deviceUuid = app.query('#' + data[i].deviceUuid)[0]
- if(deviceUuid != undefined){
- deviceUuid.destroy();
- }
-
- var device_array = app.create({
- name: data[i].name,
- id: data[i].deviceUuid,
- type: 'Thing',
- url: url,
- position: [parseFloat(data[i].position.split(',')[0]),parseFloat(data[i].position.split(',')[1]),parseFloat(data[i].position.split(',')[2])],
- angle: parseFloat(data[i].angle.split(',')[1]),
- parent: abc,
- scale: [parseFloat(data[i].scale.split(',')[0]),parseFloat(data[i].scale.split(',')[1]),parseFloat(data[i].scale.split(',')[2])],
- complete:function(ev){
- ev.object.userData.bool = bool;
- ev.object.userData.物体类型 = type;
- }
- })
- }
- }
- })
- }
- function btnadd_device(type, name, id) {
- var url = ""
- if (type === '摄像头') {
- url = 'https://model.3dmomoda.com/models/2DBD1DCD7B5F49BDA43CC6444FC5CBD0/0/gltf'
- }
- var abc = app.query('#' + floorID)[0]
- device = app.create({
- name: name,
- id: id,
- type: 'Thing',
- url: url,
- position: [0, 0, 0],
- angle: 180,
- parent: abc,
- scale: [1.7, 1.7, 1.7],
- complete:function(ev){
- ev.object.userData.bool = true;
- ev.object.userData.物体类型 = type;
- }
- });
- }
- function equipment(key) {
- if (key === "设备选择器") {
- if (sidebar.device_add == true) {
- sidebar.device_add = false
- panel_.destroy();
- }
- } else if (key === "模型创建") {
- if (sidebar.equipment == true) {
- sidebar.equipment = false
- panel_.destroy();
- }
- }
-
- panel_ = new THING.widget.Panel({
- titleText: key,
- closeIcon: false,
- dragable: true,
- retractable: true,
- opacity: 1,
- hasTitle: true,
- zIndex: 999
- });
-
-
-
- panel_.position = [0, '40%'];
- $('head').append($(`
- <style>
- .ThingJS_wrap .panel{
- border: 1px solid rgb(24 118 208 / 55%);
- box-shadow: 0px 2px 21px 0px rgb(24 118 208 / 55%);
- background: rgba(2,17,50,0.9);
- }
- .ThingJS_wrap .panel .title{
- background: rgba(27,57,130,1);
- border-bottom:none;
- text-align: center;
- }
- .ThingJS_wrap .panel .title .text{
- padding-left: 0px;
- }
-
- .ThingJS_wrap .panel .main{
- border: none;
- }
- .ThingJS_wrap .panel .dv-input .dv33{
- border-top:none;
- }
- </style>
- `));
- if (key === "设备选择器") {
-
- if (JSON.stringify(dataObj.checkbox) != "{}") {
- var check = panel_.addCheckbox(dataObj, 'checkbox');
-
- for (let i = 0; i < check.length; i++) {
- check[i].on('change', function (ev) {
- app.query("#" + floorID)[0].query('["userData/物体类型"="' + check[i].property + '"]').forEach(function (obj, index) {
- if (ev) {
- var myElement = document.getElementById(obj.name);
- if (!myElement) {
- equipment_ajax(obj);
- }
- } else {
- if (ev_name == null || ev_name == "") {
- equipment_ajax(obj);
- } else {
- for (let i = 0; i < uis_list.length; i++) {
- if (ev_name === uis_list[i].name) {
- var box = document.getElementById(uis_list[i].name);
- box.remove();
- var box1 = document.getElementById(uis_list[i].name);
- box1.remove();
- uis_array.splice(i, 1)
- uis.splice(i, 1)
- uis_list.splice(i, 1)
- uis_name[obj.userData.物体类型]++
- }
- }
- }
- }
- })
- });
- }
- }
- } else if (key === "模型创建") {
- var html;
- var type;
- var templaet = `
- <div id="flex_content" style="display:flex;margin-bottom: 15px;flex-wrap:wrap;">
- </div>
- `
- $('.ThingJS_UI').append($(templaet));
- $.ajax({
- type: "POST",
- url: api + '/thingjs/queryLocalDevice',
- dataType: "json",
- data: { thingjsFloorId: floorID },
- async: false,
- success: function (obj) {
- var data = obj.data
- if (data.length > 0) {
- for (let i = 0; i < data.length; i++) {
- if (data[i].deviceType === 'IPC') {
- type = '摄像头'
- }
- html = `
- <button class="custom-btn btn-3" onclick="btnadd_device('${type}','${data[i].deviceName}','${data[i].uuid}')">
- <span>${data[i].deviceName}</span>
- </button>
- `
- $('#flex_content').append($(html));
- }
- } else {
- html = `
- <div style="width: 100%;color: #fff;text-align: center;margin-top: 1rem;">暂无数据</div>
- `
- $('#flex_content').append($(html));
- }
- }
- });
- $('head').append($(`
- <style>
- .custom-btn {
- width: 130px;
- height: 40px;
- color: #fff;
- border-radius: 5px;
- padding: 10px 25px;
- font-family: "Lato", sans-serif;
- font-weight: 500;
- background: transparent;
- cursor: pointer;
- transition: all 0.3s ease;
- position: relative;
- display: inline-block;
- }
- /* 3 */
- .btn-3 {
- background: #4368ca;
- width: 130px;
- height: 40px;
- line-height: 42px;
- padding: 0;
- border: none;
- margin: 0 auto;
- margin-top: 15px;
- overflow: hidden;
- }
- .btn-3 span {
- position: relative;
- display: block;
- width: 100%;
- height: 100%;
- }
- .btn-3:before,
- .btn-3:after {
- position: absolute;
- content: "";
- right: 0;
- top: 0;
- background: rgba(2, 126, 251, 1);
- transition: all 0.3s ease;
- }
- .btn-3:before {
- height: 0%;
- width: 2px;
- }
- .btn-3:after {
- width: 0%;
- height: 2px;
- }
- .btn-3:hover {
- background: transparent;
- box-shadow: none;
- }
- .btn-3:hover:before {
- height: 100%;
- }
- .btn-3:hover:after {
- width: 100%;
- }
- .btn-3 span:hover {
- color: rgba(2, 126, 251, 1);
- }
- .btn-3 span:before,
- .btn-3 span:after {
- position: absolute;
- content: "";
- left: 0;
- bottom: 0;
- background: rgba(2, 126, 251, 1);
- transition: all 0.3s ease;
- }
- .btn-3 span:before {
- width: 2px;
- height: 0%;
- }
- .btn-3 span:after {
- width: 0%;
- height: 2px;
- }
- .btn-3 span:hover:before {
- height: 100%;
- }
- .btn-3 span:hover:after {
- width: 100%;
- }
- </style>
- `));
- }
- }
- app.on(THING.EventType.SingleClick, function (ev) {
- if (ev.picked) {
- if (ev.object.type === "Thing") {
- if (position == undefined) {
- position = ev.object.position[1]
- }
- ev.pickedPosition[1] = 0
- ev_object = "";
- ev_object = ev
- add_dome(ev);
- ev_name = ev.object.name
- if (dataObj.checkbox[ev.object.userData.物体类型] == true) {
- dataObj.checkbox[ev.object.userData.物体类型] = false
- } else {
- equipment_ajax(ev.object)
- }
- }
- }
- });
- function add_dome(ev) {
- dome = document.getElementsByClassName('widget')
- var userData = ev.object.userData
- if ('bool' in userData) {
- if (userData.bool == true) {
- var object = ev_object.object
-
- delete_dome();
- var widget =
- `
- <div class="widget">
- <div class="widget_title">设备编辑器</div>
- <div class="widget_content">
- <ul style="width: 20%;text-align: center;">
- <li class="content_li">设备类别:</li>
- <li class="content_li">设备编号:</li>
- <li class="content_li">设备位置:</li>
- <li class="content_li">设备方向:</li>
- <li class="content_li">设备大小:</li>
- </ul>
- <ul style="width: 80%;text-align: center;">
- <li class="content_li">
- <input id="userData" class="content_input" type="text"
- value="${object.userData.物体类型}" disabled="disabled">
- </li>
- <li class="content_li">
- <input id="device_id" class="content_input" type="text"
- value="${object.id}" disabled="disabled">
- </li>
- <li class="content_li" style="display:flex;">
- <input id="position_1" class="content_input"
- type="text" value="${object.position[0]}"
- style="width:40%;" onchange="change_dome()"
- onkeyup="if(isNaN(value))execCommand('undo')"
- onafterpaste="if(isNaN(value))execCommand('undo')">
- <input id="position_2" class="content_input"
- type="text" value="${ev.pickedPosition[1]}"
- style="width:20%;" onchange="change_dome()"
- onkeyup="if(isNaN(value))execCommand('undo')"
- onafterpaste="if(isNaN(value))execCommand('undo')">
- <input id="position_3" class="content_input" type="text"
- value="${object.position[2]}"
- style="width:40%;" onchange="change_dome()"
- onkeyup="if(isNaN(value))execCommand('undo')"
- onafterpaste="if(isNaN(value))execCommand('undo')">
- </li>
- <li class="content_li">
- <input id="angles" class="content_input" type="text"
- value="${object.angles[1]}"
- onchange="change_dome()"
- onkeyup="if(isNaN(value))execCommand('undo')"
- onafterpaste="if(isNaN(value))execCommand('undo')">
- </li>
- <li class="content_li">
- <input id="scale" class="content_input"
- type="text" value="${object.scale[0]}"
- onchange="change_dome()"
- onkeyup="if(isNaN(value))execCommand('undo')"
- onafterpaste="if(isNaN(value))execCommand('undo')">
- </li>
- </ul>
- </div>
- <div class="widget_header">
- <div>
- <button class="btn_1" onclick="insert_dome()">保存</button>
- </div>
- <div>
- <button class="btn_2" onclick="delete_dome()">取消</button>
- </div>
- <div>
- <button class="btn_3" onclick="delete_device()">删除</button>
- </div>
- </div>
- </div>
- `
- $('#div2d').append($(widget));
- $('head').append($(`
- <style>
- .widget{
- width: 35rem;
- position: fixed;
- border-radius: 5px;
- bottom: 5.5rem;
- right: 10px;
- color: #fff;
- }
- .widget_title{
- width: 100%;
- text-align: center;
- padding: 10px;
- background: rgba(27,57,130,1);
- border-radius: 5px 5px 0px 0px;
- }
- .widget_content{
- width: 100%;
- background: rgba(2,17,50,0.9);
- display: flex;
- }
- .content_li{
- margin-top: 1rem;
- margin-bottom: 1rem;
- }
- .content_input{
- width: 98%;
- padding-left: 10px;
- border: 1px solid #3486da;
- background: rgba(27,31,81,0.60);
- color: #fff;
- margin-right: 10px;
- }
- .widget_header{
- width: 100%;
- display:flex;
- background: rgba(2,17,50,0.9);
- border-radius: 0px 0px 5px 5px;
- padding-bottom: 1rem;
- }
- .widget_header div{
- width: 33.33%;
- text-align: center;
- }
- .widget_header div button{
- width: 78px;
- height: 32px;
- color: #ffff;
- cursor: pointer;
- }
- .btn_1{
- opacity: 1;
- background: #2f52ae;
- border-radius: 6px;
- border: 0px;
- }
- .btn_2{
- background: transparent;
- border-radius: 6px;
- border: 1px solid #dadada;
- }
- .btn_3{
- border: 1px solid #ff4848;
- color: #ff4848 !important;
- border-radius: 7px;
- background: transparent;
- }
- </style>
- `));
- }
- } else {
-
- delete_dome();
- }
- }
- function insert_dome(){
- var object=ev_object.object
- var type = "";
- if(object.userData.物体类型 === '摄像头'){
- type = 'IPC'
- }
- $.ajax({
- type: "POST",
- url: api + '/thingjs/thingjsDeviceRegister',
- dataType: "json",
- data:{
- deviceUuid:object.id,
- name:object.name,
- deviceType:type,
- angle:""+object.angles[0]+","+object.angles[1]+","+object.angles[2]+"",
- bool:object.userData.bool,
- position:""+object.position[0]+","+object.position[1]+","+object.position[2]+"",
- scale:""+object.scale[0]+","+object.scale[1]+","+object.scale[2]+"",
- del:0
- },
- async: false,
- success: function (data) {
- object.destroy();
- delete_dome();
- select_device();
- }
- })
- }
- function delete_device(){
- var object=ev_object.object
- var type = "";
- if(object.userData.物体类型 === '摄像头'){
- type = 'IPC'
- }
- $.ajax({
- type: "POST",
- url: api + '/thingjs/thingjsDeviceRegister',
- dataType: "json",
- data:{
- deviceUuid:object.id,
- name:object.name,
- deviceType:type,
- angle:""+object.angles[0]+","+object.angles[1]+","+object.angles[2]+"",
- bool:object.userData.bool,
- position:""+object.position[0]+","+object.position[1]+","+object.position[2]+"",
- scale:""+object.scale[0]+","+object.scale[1]+","+object.scale[2]+"",
- del:1
- },
- async: false,
- success: function (data) {
- object.destroy();
- delete_dome();
- select_device();
- }
- })
- }
- function change_dome() {
- var userData_dome = document.getElementById('userData')
- var angles = document.getElementById('angles')
- var scale = document.getElementById('scale')
- var position_1 = document.getElementById('position_1')
- var position_2 = document.getElementById('position_2')
- var position_3 = document.getElementById('position_3')
- if (userData_dome != null && userData_dome != '') {
- angles.value != null && angles.value != "" ? angles = angles.value : angles = 0;
- ev_object.object.angles = [0, angles, 0];
- scale.value != null && scale.value != "" ? scale = scale.value : scale = 1;
- ev_object.object.scale = [scale, scale, scale];
- position_1.value != null && position_1.value != "" ? position_1 = position_1.value : position_1 = 0;
-
- if (position_2.value != null && position_2.value != "") {
- ev_object.pickedPosition[1] = position_2.value
- position_2 = position + parseInt(position_2.value)
- } else {
- ev_object.pickedPosition[1] = 0
- position_2 = position
- }
- position_3.value != null && position_3.value != "" ? position_3 = position_3.value : position_3 = 0;
- ev_object.object.position = [position_1, position_2, position_3]
- }
- add_dome(ev_object);
- }
- function delete_dome() {
- if (dome != undefined) {
- if (dome.length > 0) {
- dome[0].remove()
- }
- }
- }
- function equipment_ajax(object) {
- var myElement = document.getElementById(object.name);
- if (myElement) {
- for (let i = 0; i < uis_list.length; i++) {
- if (object.name === uis_list[i].name) {
- var box = document.getElementById(object.name);
- box.remove();
- var box1 = document.getElementById(object.name);
- box1.remove();
- uis_array.splice(i, 1)
- uis.splice(i, 1)
- uis_list.splice(i, 1)
- uis_name[object.userData.物体类型]++
- }
- }
- } else {
- $.ajax({
- type: "GET",
- url: '/uploads/wechat/163607/file/广西东盟项目/测试.json',
- dataType: "json",
- async: false,
- success: function (data) {
- for (let i = 0; i < data.length; i++) {
- if (data[i].deviceid === object.id && data[i].devicetype === object.userData.物体类型) {
- init(object, data[i]);
- }
- }
- }
- });
- }
- }
- function delete_ui() {
- for (let i = 0; i < uis_array.length;) {
- equipment_ajax(uis_array[i])
- }
- }
- function click_userData() {
- var userData = []
- var user_array = {}
- uis_name = {}
- dataObj.checkbox = {}
-
- app.query("#" + floorID)[0].query('["userData/物体类型"]').forEach(function (obj) {
- userData.push(obj.userData.物体类型)
- var array = app.query("#" + floorID)[0].query('["userData/物体类型"="' + obj.userData.物体类型 + '"]').length
- uis_name[obj.userData.物体类型] = array
- })
-
- for (var i = 0; i < userData.length; i++) {
- for (var j = i + 1; j < userData.length;) {
- userData[i] == userData[j] ? userData.splice(j, 1) : j++;
- }
- }
- userData.forEach(function (obj, index) {
- dataObj.checkbox[obj] = false;
- })
- }
- window.addEventListener("message", (event) => {
- var that = this;
-
- var name = event.data.name;
- var state = event.data.state;
- if (name === '17楼监控2' || name === '17楼监控1') {
-
-
-
-
-
-
-
-
-
-
-
-
-
- } else {
- stateArray.push(state)
- if (stateArray.length > 1) {
- for (let i = 0; i < stateArray.length; i++) {
- if (stateArray[i - 1] === stateArray[i]) {
- if (sidebar.deviceShow == true) {
- sidebar.deviceShow = false
- } else {
- sidebar.deviceShow = true
- }
- stateArray = [];
- }
- }
- } else {
- sidebar.deviceShow = true
- }
- var devList = []
- var deviceArray = app.query('["userData/物体类型"="' + name + '"]');
- devList.push(deviceArray)
- flash(devList, state);
- }
- }, false);
- function deviceIcon_click(id, name) {
- let funcName = "icon_click";
- var data = { id, name }
- var message = {
- 'funcName': funcName,
- 'param': data
- }
-
-
-
- window.parent.postMessage(message, '*');
- }
-
- function flash(objArray, state) {
- var color = ''
- var opacity;
- objArray.forEach(function (obj, index) {
- obj.on('update', function () {
- if (state === 'total') {
- color = sidebar.deviceShow == true ? '#008000' : '#F8F8FF'
- } else if (state === 'error') {
- color = sidebar.deviceShow == true ? '#FFF000' : '#F8F8FF'
- } else if (state === "none") {
- color = '#F8F8FF'
- }
- opacity = sidebar.deviceShow == true ? 0.5 + 0.5 * Math.sin(2 * app.elapsedTime / 500) : 1
- obj.style.alwaysOnTop = true
- obj.style.color = color
- obj.style.opacity = opacity
- }, '每帧改变透明度');
- })
- }
- function queryDeviceStatus(evt) {
-
- objArray = evt.data;
-
-
-
-
-
-
-
- obj = app.query("#" + objArray)[0];
- obj.on('update', function () {
- obj.style.color = '#FF0000'
- obj.style.opacity = 0.5 + 0.5 * Math.sin(2 * app.elapsedTime / 500);
- }, '每帧改变透明度');
- }
- function reset(objArray) {
- objArray.forEach(function (obj) {
- obj.style.opacity = 1.0;
- obj.style.color = null;
- obj.off('update', null, '每帧改变透明度');
- })
- }
- var timer = null;
- function createChart(option, type) {
- var bottomBackground = document.createElement('div');
- bottomBackground.setAttribute('id', 'bottomBackground');
- var bottomDom = document.createElement('div');
-
- if (type == "车位状态") {
- var backgroundStyle = 'position: absolute;top:3px;right:3px;height:300px;width:380px;background: rgba(22,24,63,0.3); border-radius:3px';
- var chartsStyle = 'position: absolute;top:10px;right:0px;width:360px;height:250px;margin:0 10px;';
- }
- bottomBackground.setAttribute('style', backgroundStyle);
- bottomDom.setAttribute('style', chartsStyle);
-
- var bottomCharts = window.echarts.init(bottomDom);
- bottomCharts.setOption(option);
-
- bottomCharts.on('click', function (params) {
- clearTimeout(timer);
-
- cancelOutline();
- reset();
- clearUIAnchorArr();
-
- if (params.name == "测试") {
- app.query("测试======").style.outlineColor = "#4a8cff"
- }
-
- timer = setTimeout(function () {
- cancelOutline();
- reset();
- clearUIAnchorArr();
- }, 5000)
- });
- bottomBackground.appendChild(bottomDom);
- app.domElement.appendChild(bottomBackground);
- }
- function getTabledata(d) {
- var ygArray = [];
- d.forEach(function (d) {
- var deviceInfo = {
- "设备编号": d.ownerCode,
- "设备名称": d.ownerName,
- "安装位置": d.unitinfo,
- };
- ygArray.push(deviceInfo)
- })
-
- var tableData = {
-
- props: ['设备编号', '设备名称', '安装位置'],
-
- items: ygArray
- };
- return tableData;
- }
- function createPerson(name, age, family) {
- var o = new Object();
- o.name = name;
- o.age = age;
- o.family = family;
- o.say = function () {
- alert(this.name);
- }
- return o;
- }
- function createmonitorlist() {
- mycreat();
- function mycreat() {
- let sign1 =
- `
- <div id="mymonitor" style='position: absolute;top:50px;left:3px;height:330px;width:400px;background: rgba(255,255,255,1); border-radius:0px; margin-top:0px'>
- <div style="">监控设备</div>
- <div id="deviceListTable1" lay-filter="test" ></div>
- </div>
- `;
- $('#div2d').append($(sign1));
- };
- }
- function destroyMonitor() {
- var mymonitor = document.getElementById('mymonitor')
- mymonitor.remove();
- }
- function destroyPanel() {
- var mydiv = document.getElementById('mydiv')
- mydiv.remove();
- }
- function createDeviceListTable(option, type) {
- mycreat();
- function mycreat() {
- let sign =
- `
- <div id="mydiv" style='position: absolute;top:50px;left:3px;height:330px;width:480px;background: rgba(255,255,255,1); border-radius:0px; margin-top:0px'>
- <div style="">烟感设备</div>
- <div id="deviceListTable" lay-filter="test" ></div>
- </div>
- `;
- $('#div2d').append($(sign));
- (function () {
- let loginUser = {
- "V_LOGINNAME": "admin",
- "V_PASSWORD": "e10adc3949ba59abbe56e057f20f883e",
- }
- var queryData = {}
- queryData.queryJson = JSON.stringify(loginUser);
- layui.use('table', function () {
- var table = layui.table;
- table.render({
- elem: '#deviceListTable',
- size: 'sm',
- height: 300,
- skin: 'nob ',
- where: queryData
- , method: 'post'
- , url: 'http://101.133.214.75:8080/Device_Manager/thingjs/queryYgList',
- cols: [
- [{
- field: 'ownerName',
- title: '设备名称',
- fixed: 'left',
- unresize: true,
- sort: true
- }, {
- field: 'ownerCode',
- title: '设备编号'
- }, {
- field: 'unitinfo',
- title: '详细地址',
- sort: true
- }, {
- field: 'ownerXh',
- title: '型号'
- }
- ]
- ]
- , page: true
- });
-
- table.on('row(test)', function (obj) {
- app.level.change(app.buildings[0]);
- var ownerCode = obj.data.ownerCode;
- deviceID = app.query("#" + ownerCode)[0];
-
- var domDiv = document.getElementById('bottomBackground');
- if (domDiv) {
- domDiv.remove();
- }
- app.camera.flyTo({
- object: deviceID,
- xAngle: 45,
- yAngle: -45,
- radiusFactor: 4,
- time: 2 * 1000,
- complete: function () {
- }
- });
-
-
-
-
-
- obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
- });
- });
- })();
- };
- }
- function updateData(obj) {
-
-
-
- if (!webSocket) {
-
-
- webSocket = new WebSocket('ws://101.133.214.75:8080/Device_Manager/socket');
-
- webSocket.onopen = function () {
- console.log("websoket服务器连接成功...");
- };
-
- webSocket.onmessage = function (evt) {
- queryDeviceStatus(evt);
- };
- webSocket.onclose = function (evt) {
- console.log("websoket关闭...");
- webSocket = null;
- }
- }
- }
- class MainPanel {
- constructor(app) {
- this.app = app;
- this.panels_znyg = [];
- this.panels_znjk = [];
- this.panels_znef = [];
- this.toolBar = null;
- this.toolImgs = {};
- this.isExpandBuilding = false;
- this.building = this.app.buildings[0];
- }
-
- createToolsPanel() {
- var that = this;
- var baseURL = "http://47.103.74.123/ThingjsIcon/";
-
- this.toolBar = THING.widget.Banner({ column: 'left', width: '20px', media: true, captionPos: 'hover', opacity: 0.5 });
- this.toolBar.data = sidebar
- this.toolBar.setPosition({ right: 0, top: 60 });
- this.toolImgs.img1 = this.toolBar.addImageBoolean(this.toolBar.data, 'znyg').name('智能烟感').imgUrl(iconUrl + '智能烟感.png');
- this.toolImgs.img2 = this.toolBar.addImageBoolean(this.toolBar.data, 'znjk').name('监控').imgUrl(iconUrl + '摄像头.png');
- this.toolImgs.img3 = this.toolBar.addImageBoolean(this.toolBar.data, 'enterBuilding').name('进入建筑').imgUrl(iconUrl + '建筑.png');
- this.toolImgs.img4 = this.toolBar.addImageBoolean(this.toolBar.data, 'expandBuilding').name('楼层展开').imgUrl(iconUrl + '多楼层.png');
- this.toolImgs.img5 = this.toolBar.addImageBoolean(this.toolBar.data, 'deviceShow').name('建筑透视').imgUrl(iconUrl + '透视.png');
- this.toolImgs.img1.on('change', function (boolValue) { that.onChangeImageButton('znyg', boolValue); });
- this.toolImgs.img2.on('change', function (boolValue) { that.onChangeImageButton('znjk', boolValue); });
- this.toolImgs.img3.on('change', function (boolValue) { that.onChangeImageButton('enterBuilding', boolValue); });
- this.toolImgs.img4.on('change', function (boolValue) { that.onChangeImageButton('expandBuilding', boolValue); });
- this.toolImgs.img5.on('change', function (boolValue) { that.onChangeImageButton('deviceShow', boolValue); });
- }
- addButton(name) {
- var that = this;
- if (this.toolImgs.img6) {
- this.toolImgs.img6.remove()
- }
- if (this.toolImgs.img7) {
- this.toolImgs.img7.remove()
- }
- this.toolImgs.img6 = this.toolBar.addImageBoolean(this.toolBar.data, 'equipment').name('设备选择器').imgUrl(iconUrl + '设备.png');
- this.toolImgs.img6.on('change', function (boolValue) { that.onChangeImageButton('equipment', boolValue); });
- this.toolImgs.img7 = this.toolBar.addImageBoolean(this.toolBar.data, 'device_add').name('模型创建').imgUrl(iconUrl + '设备.png');
- this.toolImgs.img7.on('change', function (boolValue) { that.onChangeImageButton('device_add', boolValue); });
- if (name != "Floor") {
- this.toolImgs.img6.remove();
- this.toolImgs.img7.remove();
- }
- }
-
- onChangeImageButton(key, boolValue) {
- var that = this;
- if (key == "enterBuilding") {
- this.goinBuild(boolValue, key);
- } else if (key == "deviceShow") {
- var devicList = [];
- var build = app.buildings[0]
- var opacity = build.style.opacity;
- build.style.opacity = (opacity > 0.8) ? 0.1 : 1.0;
- if (boolValue) {
- this.goinBuild(boolValue);
-
- }
- else {
- flash(devicList, "none");
- reset(devicList);
- }
- }
- else if (key == "expandBuilding") {
- this.app.level.change(app.buildings[0]);
- if ($(this).hasClass('active')) {
- horizontalExpand(building, 'close');
- verticalExpand(building, 'close');
- }
- if (boolValue) {
- coordinate = [24.7179997, 111.99999690000001, -3.2360001];
- coordinate_1 = [37.5919984, 111.99999690000001, -3.2140001000000002];
- coordinate_2 = [37.6669991, 111.99999690000001, -10.439000400000001];
- coordinate_3 = [24.8049996, 111.99999690000001, -10.434000300000001];
- this.personclick(coordinate, coordinate_1, coordinate_2, coordinate_3)
- this.building.expandFloors({
- 'time': 1000,
- 'length': 4,
- 'horzMode': false,
- 'hideRoof': true,
- 'complete': function () {
- that.isExpandBuilding = true;
- }
- })
- } else {
- coordinate = [24.7179997, 59.9999969, -3.2360001];
- coordinate_1 = [37.5919984, 59.9999969, -3.2140001000000002];
- coordinate_2 = [37.6669991, 59.9999969, -10.439000400000001];
- coordinate_3 = [24.8049996, 59.9999969, -10.434000300000001];
- this.personclick(coordinate, coordinate_1, coordinate_2, coordinate_3)
- this.building.unexpandFloors({
- 'time': 500,
- 'complete': function () { that.isExpandBuilding = false; }
- })
- }
- } else if (key == "znyg") {
- if (boolValue) {
- createDeviceListTable();
- } else {
- destroyPanel();
- }
- } else if (key == "equipment") {
- boolValue ? equipment("设备选择器") : panel_.destroy();
- } else if (key == "device_add") {
-
- if (boolValue) {
- equipment("模型创建")
- } else {
- panel_.destroy()
- }
- deviceIcon_click("iframe", "iframe");
- } else {
- if (key == "znjk") {
-
- if (boolValue) {
- createmonitorlist();
- } else {
- destroyMonitor();
- }
- }
- }
- }
- personclick(coordinate, coordinate_1, coordinate_2, coordinate_3) {
- var car = app.query(new_name)[0];
- if (car != null && car != "") {
- person.playAnimation({ name: new_animationNames, loopType: 'repeat' });
- var path = [coordinate, coordinate_1, coordinate_2, coordinate_3, coordinate];
- car.movePath({
- orientToPath: true,
- path: path,
- time: 50 * 1000,
- delayTime: 1000,
- lerpType: null,
-
-
-
- loopType: THING.LoopType.Repeat,
- })
- }
- }
-
- resetExpand() {
- var that = this;
- if (this.isExpandBuilding) {
- this.toolBar.data.expandBuilding = false;
- this.building.unexpandFloors({
- 'time': 500,
- 'complete': function () { that.isExpandBuilding = false; }
- })
- }
- }
- goinBuild(boolValue) {
- this.resetExpand();
- var name = boolValue ? '返回室外' : '进入建筑';
- this.toolImgs.img3.name(name);
- if (boolValue) {
- this.app.level.change(app.buildings[0]);
- var domDiv = document.getElementById('bottomBackground');
- if (domDiv) {
- domDiv.remove();
- }
- }
- else {
- this.app.level.change(app.root.campuses[0]);
-
- }
- }
- }
|