//创建楼层选择器
function creatFloorChoose() {
var floorsign =
`
`;
$('#div2d').append($(floorsign));
var car = app.query(".Floor")
var html = ``
for(let i = 0 ; i < car.length; i++){
html +=
`
${car[i].id}
`
}
$('#floorChooseDiv').append($(html));
$('head').append($(`
`));
}
//楼层切换
function floorclick(id) {
var _this = this;
showAllPanels();
reset();
var floor = app.query("#" + id)[0];
delete_ui();
sidebar.equipment = false;
floorID = id;//将当前楼层存放floorID
click_userData();//调用获取当前楼层设备类型数据
app.level.change(floor);
app.query("#" + id)[0].query('.Thing').forEach(function (obj){
// console.log(obj)
var car = app.query("#"+obj.id)[0];
// panelArr.push(uiAnchor(car));
})
$.ajax({
type: "GET",
url:'/uploads/wechat/163607/file/广西东盟项目/JSON/Goods.json',
dataType: "json",
async: false,
success: function (data) {
for(let i = 0 ; i < data.array.length; i++){
var array = data.array[i]
if(id === array.floorID){
_this.createTruck(array);
}
}
}
});
}
// 销毁面板
function showAllPanels() {
panelArr.forEach(function (car) {
car.destroy();
});
}
function createTruck(data) {
// 创建Thing
truck = app.create({
type: data.type,
name: data.name,
url: data.url,
id: data.id,
position: data.position,
angle: 0,
angles: data.angles,
scale: data.scale
});
if(data.uiAnchor == true){
panelArr.push(uiAnchor(truck));
}
}
function reset() {
app.query(/thing/).forEach(function (obj){
// console.log(obj)
obj.destroy();
obj = null;
})
}
// 点击右侧侧边栏开关
function handleSide() {
if ($('#rightSideSwitch').attr('value') == 'close') {
$('.showFloorBtn').animate({ right: 0 }, 300);
// $('#rightSideSwitch').attr('value', 'open');
$('#rightSideSwitch').attr('value', 'open').css('background-image', 'url(https://s3.ax1x.com/2021/01/29/yCRGIf.png)');
} else if ($('#rightSideSwitch').attr('value') == 'open') {
$('.showFloorBtn').animate({ right: -52 }, 300);
$('#rightSideSwitch').attr('value', 'close').css('background-image', 'url(https://s3.ax1x.com/2021/01/29/yCR8dP.png)');
// $('#rightSideSwitch').attr('value', 'close');
}
}