FloorClick.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. //创建楼层选择器
  2. function creatFloorChoose() {
  3. var floorsign =
  4. `
  5. <div id="floorChooseDiv" class="showFloorBtn">
  6. <div value='close' onclick="handleSide()" class ="closeIocn" id='rightSideSwitch'></div>
  7. </div>
  8. `;
  9. $('#div2d').append($(floorsign));
  10. var car = app.query(".Floor")
  11. var html = ``
  12. for(let i = 0 ; i < car.length; i++){
  13. html +=
  14. `
  15. <div onclick="floorclick('${car[i].id}')" class = "showFloorBtns" id='${car[i].id}'>${car[i].id}</div>
  16. `
  17. }
  18. $('#floorChooseDiv').append($(html));
  19. $('head').append($(`
  20. <style>
  21. .showFloorBtns{
  22. margin-bottom:6px;
  23. border:1px solid rgb(24,118,208);
  24. border-radius:4px;
  25. text-align:center;
  26. height:28px;
  27. line-height:28px;
  28. width:40px;
  29. color:rgba(255,255,255,0.5);
  30. background-color:rgba(24,144,255,0.3);
  31. // display:inline-block;
  32. }
  33. .showFloorBtn{
  34. position: absolute;
  35. // top:10px;
  36. top:calc(2%);
  37. right:-52px;
  38. // height:800px;
  39. width:50px;
  40. border-radius:0px;
  41. margin-top:0px;
  42. cursor:pointer;
  43. }
  44. .closeIocn{
  45. // margin-bottom:6px;
  46. // border:1px solid rgb(24,118,208);
  47. border-radius:4px;
  48. text-align:center;
  49. height:30px;
  50. line-height:28px;
  51. width:40px;
  52. color:rgba(255,255,255,0.5);
  53. background-image: url(https://s3.ax1x.com/2021/01/29/yCR8dP.png);
  54. background-repeat:no-repeat;
  55. background-position:center center;
  56. position: absolute;
  57. top: calc(50%);
  58. left: -35px;
  59. }
  60. .active{
  61. background-color:red;
  62. }
  63. </style>
  64. `));
  65. }
  66. //楼层切换
  67. function floorclick(id) {
  68. var _this = this;
  69. showAllPanels();
  70. reset();
  71. var floor = app.query("#" + id)[0];
  72. delete_ui();
  73. sidebar.equipment = false;
  74. floorID = id;//将当前楼层存放floorID
  75. click_userData();//调用获取当前楼层设备类型数据
  76. app.level.change(floor);
  77. app.query("#" + id)[0].query('.Thing').forEach(function (obj){
  78. // console.log(obj)
  79. var car = app.query("#"+obj.id)[0];
  80. // panelArr.push(uiAnchor(car));
  81. })
  82. $.ajax({
  83. type: "GET",
  84. url:'/uploads/wechat/163607/file/广西东盟项目/JSON/Goods.json',
  85. dataType: "json",
  86. async: false,
  87. success: function (data) {
  88. for(let i = 0 ; i < data.array.length; i++){
  89. var array = data.array[i]
  90. if(id === array.floorID){
  91. _this.createTruck(array);
  92. }
  93. }
  94. }
  95. });
  96. }
  97. // 销毁面板
  98. function showAllPanels() {
  99. panelArr.forEach(function (car) {
  100. car.destroy();
  101. });
  102. }
  103. function createTruck(data) {
  104. // 创建Thing
  105. truck = app.create({
  106. type: data.type,
  107. name: data.name,
  108. url: data.url,
  109. id: data.id,
  110. position: data.position,
  111. angle: 0,
  112. angles: data.angles,
  113. scale: data.scale
  114. });
  115. if(data.uiAnchor == true){
  116. panelArr.push(uiAnchor(truck));
  117. }
  118. }
  119. function reset() {
  120. app.query(/thing/).forEach(function (obj){
  121. // console.log(obj)
  122. obj.destroy();
  123. obj = null;
  124. })
  125. }
  126. // 点击右侧侧边栏开关
  127. function handleSide() {
  128. if ($('#rightSideSwitch').attr('value') == 'close') {
  129. $('.showFloorBtn').animate({ right: 0 }, 300);
  130. // $('#rightSideSwitch').attr('value', 'open');
  131. $('#rightSideSwitch').attr('value', 'open').css('background-image', 'url(https://s3.ax1x.com/2021/01/29/yCRGIf.png)');
  132. } else if ($('#rightSideSwitch').attr('value') == 'open') {
  133. $('.showFloorBtn').animate({ right: -52 }, 300);
  134. $('#rightSideSwitch').attr('value', 'close').css('background-image', 'url(https://s3.ax1x.com/2021/01/29/yCR8dP.png)');
  135. // $('#rightSideSwitch').attr('value', 'close');
  136. }
  137. }