Browse Source

解决鞍山顶楼问题

haojianlong 4 years ago
parent
commit
f454d07897
1 changed files with 33 additions and 27 deletions
  1. 33 27
      src/components/floorMap/index.vue

+ 33 - 27
src/components/floorMap/index.vue

@@ -102,40 +102,46 @@ export default {
                     this.scene.addItem(imgItem)
                     this.view.scene = this.scene
                     // this.view.fitSceneToView()
+                } else {
+                    // 屋顶图不为图片
+                    this.readBaseMap(floor);
                 }
             } else {
                 if (window.fengmapData.gnameToGid[floor]) {
-                    window.fengmapData.parseData(window.fengmapData.gnameToGid[floor], res => {
-                        if (res.err) {
-                            console.log('errr', res.err)
-                            return
-                        }
-                        this.fParser = new SFloorParser(null)
-                        this.fParser.parseData(res)
-                        this.fParser.spaceList.forEach(t => {
-                            this.scene.addItem(t)
-                            t.nameSize = 12
-                            t.nameColor = '#2a2a2a'
-                            if (t.data.Name && this.bunkObj[t.data.Name]) {
-                                t.name = this.bunkObj[t.data.Name].brandname
-                            } else {
-                                // t.name = t.data.Name
-                                t.name = ''
-                            }
-                        })
-                        this.fParser.wallList.forEach(t => this.scene.addItem(t))
-                        this.fParser.virtualWallList.forEach(t => this.scene.addItem(t))
-                        this.fParser.doorList.forEach(t => this.scene.addItem(t))
-                        this.fParser.columnList.forEach(t => this.scene.addItem(t))
-                        this.fParser.casementList.forEach(t => this.scene.addItem(t))
-                        this.view.scene = this.scene
-                        // this.view.fitSceneToView()
-                        this.readGraph()
-                    })
+                    this.readBaseMap(floor);
                 } else {
                     console.log('楼层不正确')
                 }
             }
+        },// 解析底图
+        readBaseMap(floor){
+            window.fengmapData.parseData(window.fengmapData.gnameToGid[floor], res => {
+                if (res.err) {
+                    console.log('errr', res.err)
+                    return
+                }
+                this.fParser = new SFloorParser(null)
+                this.fParser.parseData(res)
+                this.fParser.spaceList.forEach(t => {
+                    this.scene.addItem(t)
+                    t.nameSize = 12
+                    t.nameColor = '#2a2a2a'
+                    if (t.data.Name && this.bunkObj[t.data.Name]) {
+                        t.name = this.bunkObj[t.data.Name].brandname
+                    } else {
+                        // t.name = t.data.Name
+                        t.name = ''
+                    }
+                })
+                this.fParser.wallList.forEach(t => this.scene.addItem(t))
+                this.fParser.virtualWallList.forEach(t => this.scene.addItem(t))
+                this.fParser.doorList.forEach(t => this.scene.addItem(t))
+                this.fParser.columnList.forEach(t => this.scene.addItem(t))
+                this.fParser.casementList.forEach(t => this.scene.addItem(t))
+                this.view.scene = this.scene
+                // this.view.fitSceneToView()
+                this.readGraph()
+            })
         },
         readGraph() {
             this.readGroup(this.floorid)