console
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>加载模型</title>
<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="http://bos3d-alpha.bimwinner.com/static/UI/latest/BOS3DUI.min.css"/>
<script src="http://bos3d-alpha.bimwinner.com/static/latest/BOS3D.min.js"></script>
<script src="http://bos3d.bimwinner.com/static/UI/latest/BOS3DUI.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<style>
.viewport {
width: 100%;
height: 100%;
}
body {
margin: 0;
overflow: hidden;
position: fixed;
}
.message {
position: absolute;
z-index: 2;
height: 350px;
width: 600px;
top: 20px;
left: 20px;
box-shadow: 1px 1px 5px #888888;
display: none;
}
.login {
position: absolute;
z-index: 2;
box-shadow: 1px 1px 5px #888888;
bottom: 30px;
left: 20px;
width: 300px;
}
.footer {
overflow-y: scroll;
height: 295px;
}
.close {
cursor: pointer;
padding-top: 7px;
}
.close span {
font-size: 30px;
margin-right: 10px;
}
td {
border: 1px solid #ddd;
}
</style>
<body>
<div class="panel panel-default message">
<div style="display: flex;justify-content: space-between;">
<div class="panel-body">属性信息</div>
<div class="close"><span>×</span></div>
</div>
<div class="panel-footer footer">
<table class="table table-hover">
<thead>
<tr class="designation">
</tr>
</thead>
<tbody class="associatedData">
</tbody>
</table>
</div>
</div>
<div class="panel panel-default login">
<div class="panel-heading">登录面板</div>
<div class="panel-body">
<form>
<div class="form-group">
<label>账号:</label>
<input type="text" class="form-control" placeholder="请输入账号" id="username">
</div>
<div class="form-group">
<label>密码:</label>
<input type="password" class="form-control" placeholder="请输入密码" id="password">
</div>
<div class="form-group">
<label>建筑ID:</label>
<input type="text" class="form-control" placeholder="请输入建筑ID" id="appKey">
</div>
<div class="form-group">
<label>模型Key:</label>
<input type="text" class="form-control" placeholder="请输入模型Key" id="modelKey">
</div>
<div class="form-group">
<label>模型DB:</label>
<input type="text" class="form-control" placeholder="请输入模型DB" id="modelDb">
</div>
<div style="display: flex;justify-content: center;">
<button type="button" class="btn btn-default register">登录</button>
</div>
</form>
</div>
</div>
<div id="viewport" class="viewport"></div>
</body>
<script rel="script">
$("#username").val(localStorage.getItem("username"))
$("#password").val(localStorage.getItem("password"))
$("#appKey").val(localStorage.getItem("appKey"))
$("#modelKey").val(localStorage.getItem("modelKey"))
$("#modelDb").val(localStorage.getItem("modelDb"))
const option = {host: "http://building-bos3d.rickricks.com", viewport: "viewport"};
const viewer3D = new BOS3D.Viewer(option);
const bos3dui = new BOS3DUI({
viewer3D: viewer3D,
BOS3D: BOS3D
});
let tagKey;
let keys;
let appkey = $("#appKey").val();
let modelKey = $("#modelKey").val();
viewer3D.registerModelEventListener(window.BOS3D.EVENTS.ON_CLICK_PICK, async function (event) {
modelKey = event.intersectInfo.selectedObjectId;
$(".information").html("暂无数据...");
await getmodelKey(modelKey)
await gettagKey();
await getAssociated();
$(".panel").show();
});
function getmodelKey() {
return new Promise((resovle, reject) => {
$.ajax({
method: 'get',
url: `http://building-bos.rickricks.com/buildingservice/${appkey}/tagModelRel/?componentKey=${modelKey}`,
dataType: 'json',
headers: {
"content-Type": "application/json",
"Authorization": localStorage.getItem("token")
},
success: (res) => {
console.log(res)
tagKey = res.data[0].tagKey;
resovle("a");
},
error: () => {
$(".message").hide();
alert("请先登录自己的账号");
}
})
});
}
function gettagKey() {
return new Promise((resovle, reject) => {
let obj = {
"condition": [
{
"bosclass": "tags",
"alias": "tags",
"subCondition": [
{
"field": "_key",
"operator": "==",
"value": tagKey,
"number": "false"
}
]
},
{
"bosclass": "uoCustomDatas",
"alias": "ucd",
"subCondition": []
},
{
"bosclass": "uirCustomDataTag",
"alias": "ubscd",
"type": "relationship",
"from": "ucd",
"to": "tags",
"subCondition": []
},
{
"bosclass": "uoCustomDataStructures",
"alias": "ucds",
"subCondition": []
},
{
"bosclass": "uirCustomStructureData",
"alias": "ucsd",
"type": "relationship",
"from": "ucds",
"to": "ucd",
"subCondition": []
}
],
"select": {
"name": "ucds.longName",
"key": "ucds._key"
}
}
$.ajax({
method: 'post',
url: `http://building-bos.rickricks.com/bosfoundationservice/${appkey}/prototype/linked/query`,
dataType: 'json',
headers: {
"content-Type": "application/json",
"Authorization": localStorage.getItem("token")
},
data: JSON.stringify(obj),
success: (res) => {
console.log(res.data.data[0].key)
keys = res.data.data[0].key;
resovle("a");
},
error: () => {
alert("请先登录自己的账号");
}
})
});
}
function getAssociated() {
return new Promise((resovle, reject) => {
let obj = {
"condition": [
{
"bosclass": "tags",
"alias": "tags",
"subCondition": [
{
"field": "_key",
"operator": "==",
"value": tagKey,
"number": "false"
}
]
},
{
"bosclass": "uoCustomDatas",
"alias": "ucd",
"subCondition": []
},
{
"bosclass": "uirCustomDataTag",
"alias": "ubscd",
"type": "relationship",
"from": "ucd",
"to": "tags",
"subCondition": []
},
{
"bosclass": "uoCustomDataStructures",
"alias": "ucds",
"subCondition": [
{
"field": "_key",
"operator": "==",
"value": keys,
"number": "false"
}
]
},
{
"bosclass": "uirCustomStructureData",
"alias": "ucsd",
"type": "relationship",
"from": "ucds",
"to": "ucd",
"subCondition": []
}
],
"select": {
"name": "ucd.name",
"key": "ucd._key",
"attribute": "ucd.attribute",
"code": "ucd.code",
"type": "ubscd.type"
}
}
$.ajax({
method: 'post',
url: `http://building-bos.rickricks.com/bosfoundationservice/${appkey}/prototype/linked/query?page=1&per_page=10`,
dataType: 'json',
headers: {
"content-Type": "application/json",
"Authorization": localStorage.getItem("token")
},
data: JSON.stringify(obj),
success: (res) => {
let attribute = res.data.data
$(".designation").html('')
for (item in attribute[0].attribute) {
$(".designation").append(`<th>${item}</th>`)
}
$(".associatedData").html('')
let string = ``;
for (items in attribute) {
string = `<tr>`
for (item in attribute[items].attribute) {
string += `<td>${attribute[items].attribute[item]}</td>`
}
string += `</tr>`
$(".associatedData").append(string)
}
resovle("a");
},
error: () => {
alert("请先登录自己的账号");
}
})
});
}
$(".close").on("click", () => {
$(".message").hide();
})
$(".register").on('click', () => {
let username = $("#username").val();
let password = $("#password").val();
localStorage.setItem("username", $("#username").val());
localStorage.setItem("password", $("#password").val());
localStorage.setItem("appKey", $("#appKey").val());
localStorage.setItem("modelKey", $("#modelKey").val());
localStorage.setItem("modelDb", $("#modelDb").val());
appkey = $("#appKey").val();
modelKey = $("#modelKey").val();
let obj = {
name: username,
password: password
}
$.ajax({
method: 'post',
url: `http://building-bos.rickricks.com/boscenterservice/account/login`,
dataType: 'json',
data: obj,
cache: false,
success: (res) => {
if (res.code === "LOGIN_ERROR") {
alert("密码输入失败")
} else if (res.code === "USER_LOCK") {
alert("账号已锁定")
} else {
let token = res.data.access_token;
localStorage.setItem("token", token)
alert("登录成功")
}
},
error: () => {
alert(false);
}
})
viewer3D.addView($("#modelKey").val(), $("#modelDb").val());
})
</script>
</html>