123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- window.grendCAD = (function grendCAD() {
- let initFloor
- // let initDOM
- let point, dire
- window.cad = {
- setSign: function(p, d) {
- point = p
- dire = d
- }
- }
- function loadDOM($parent,id) {
- // if (initDOM) return initDOM;
- let $layer = document.createElement('div')
- let $cad = document.createElement('div')
- $layer.className = id
- $cad.id = id
- $layer.appendChild($cad)
- let style = document.createElement('style')
- style.innerHTML = `
- .${id} {
- position: fixed;
- right: -260px;
- top: 90px;
- width: 260px;
- height: 200px;
- z-index: 99;
- transition: all 0.3s ease;
- }
- .${id} > div {
- width: 100%;
- height: 100%;
- }
- @media only screen and (max-width: 600px) {
- .${id} {
- position: absolute;
- left: 16px;
- top: 65px;
- width: 100px;
- height: 100px;
- background: rgba(0, 0, 0, .3);
- border-radius: 5px;
- }
- }
- `
- $parent.appendChild(style)
- $parent.appendChild($layer)
-
- return $layer
- }
- function setStyle(signColor, borderColor, borderWidth) {
- cad.setDefaultPointStyle({
- fillColor: "rgba(0,0,0,0)",
- storkeColor: "rgba(0,0,0,0)"
- });
- console.log(borderWidth)
- cad.setDefaultLineStyle({
- width: borderWidth,
- color: borderColor
- });
- console.log('执行===============');
- cad.setDefaultSignStyle({
- color: signColor,
- r: 6,
- })
- }
- return function(floor, $parent, signColor, borderColor, borderWidth, id) {
- // if (initFloor) {
- // console.log('cache')
- // return setStyle(signColor, borderColor, borderWidth)
- // }
- console.log('load')
- initFloor = floor
- let $layer = loadDOM($parent,id)
- $layer.style.visibility = 'hidden'
- window.cad = structureCAD({
- data: {
- block: [],
- column: [],
- door: [],
- hole: [],
- segment: [],
- "vertex-xy": [],
- "vertex-z": [],
- },
- layer: $layer.querySelector('#'+id),
- edit: false
- });
-
- setStyle(signColor, borderColor, borderWidth)
- cad.hideDire()
- cad.hideGauge()
-
- console.log('loadData')
- cad.loadData(initFloor);
- if (point && dire) {
- window.cad.setSign(point, dire)
- }
- $layer.style.visibility = 'visible'
- }
- })();
- if (window.number == '1149_2') {
- $.ajax({
- url: 'static/data/first_floor.json',
- method: 'GET',
- success(res) {
- grendCAD(res, document.documentElement, '#4f7d71', '#fcf5d3', '1px','cad1')
- $.ajax({
- url: 'static/data/second_floor.json',
- method: 'GET',
- success(res) {
- grendCAD(res, document.documentElement, '#4f7d71', '#fcf5d3', '1px','cad')
- }
- })
- }
- })
- }
- if (window.number == '1152_1') {
- $.ajax({
- url: 'static/data/floor_1152.json',
- method: 'GET',
- success(res) {
- grendCAD(res, document.documentElement, '#4f7d71', '#fcf5d3', '1px','cad')
- }
- })
- }
- // $.ajax({
- // url: g_Prefix + "data/" + window.number + "/someData.json" + "?" + Date.now(),
- // method: 'GET',
- // success(data) {
- // if (!data.showCad) return
-
-
- // }
- // })
|