Browse Source

feat:底图与读取绘制图分离

YaolongHan 4 years ago
parent
commit
b0318bc462
3 changed files with 42 additions and 41 deletions
  1. 29 26
      src/App.vue
  2. 9 11
      src/components/floorMap/index.vue
  3. 4 4
      src/store/index.js

+ 29 - 26
src/App.vue

@@ -35,7 +35,7 @@ export default {
       )
     );
     //    刷新时,将haveFengMap 置为false,解决设备设施页面,刷新时不出新楼层图的问题
-    this.SETHAVEFENGMAP(false);
+    this.SETHAVEFENGMAP(-1);
     localStorage.removeItem("beforeunload");
     window.addEventListener("beforeunload", () => {
       let state = JSON.stringify(this.$store.state);
@@ -58,18 +58,19 @@ export default {
       });
     },
     getMap() {
-             //如果项目为 南昌八一路 长春重庆路 青岛台东路 则不走楼层缓存接口
-        // if(this.plazaIds == "1001064" || this.plazaIds == "1001065" || this.plazaIds == "1001066"){
-        //     let arr = ["b2","b1","f1","f2","f3","f4","f5","f6","g80"];
-        //     setFloor({ plazaId: this.plazaIds }, arr)
-        //     .then(res => {
-        //       console.log("缓存楼层", res);
-        //     })
-        //     .catch(error => {
-        //       console.log("缓存楼层", error);
-        //     });
-        //     return
-        //   }
+      //如果项目为 南昌八一路 长春重庆路 青岛台东路 则不走楼层缓存接口
+      // if(this.plazaIds == "1001064" || this.plazaIds == "1001065" || this.plazaIds == "1001066"){
+      //     let arr = ["b2","b1","f1","f2","f3","f4","f5","f6","g80"];
+      //     setFloor({ plazaId: this.plazaIds }, arr)
+      //     .then(res => {
+      //       console.log("缓存楼层", res);
+      //     })
+      //     .catch(error => {
+      //       console.log("缓存楼层", error);
+      //     });
+      //     return
+      //   }
+
       window.fengmapData = new SFengParser(
         `fengMap${this.id}`,
         `${this.mapServerURL}/fmap/${this.fmapID}`,
@@ -78,6 +79,9 @@ export default {
         null,
         this.mapthemeUrl
       );
+     if (this.fmapID.includes("null")) {
+        this.SETHAVEFENGMAP(0);
+      }
       window.fengmapData.loadMap(this.fmapID, (a, b) => {
         const dataArr = b.map(item => {
           return item.gname;
@@ -88,23 +92,22 @@ export default {
             `${this.mapServerURL}/webtheme/${this.fmapID}/${this.fmapID}.theme`
           )
           .then(res => {
-            this.SETHAVEFENGMAP();
+            this.SETHAVEFENGMAP(1);
           });
         // 缓存楼层数据
         if (dataArr.length) {
           //如果项目为 南昌八一路 长春重庆路 青岛台东路 则不走楼层缓存接口
-          if(this.plazaIds == "1001064" || this.plazaIds == "1001065" || this.plazaIds == "1001066"){
-            let arr = ["b2","b1","f1","f2","f3","f4","f5","f6","g80"];
-            alert('12313')
-            setFloor({ plazaId: this.plazaIds }, arr)
-            .then(res => {
-              console.log("缓存楼层", res);
-            })
-            .catch(error => {
-              console.log("缓存楼层", error);
-            });
-            return
-          }
+          // if(this.plazaIds == "1001064" || this.plazaIds == "1001065" || this.plazaIds == "1001066"){
+          //   let arr = ["b2","b1","f1","f2","f3","f4","f5","f6","g80"];
+          //   setFloor({ plazaId: this.plazaIds }, arr)
+          //   .then(res => {
+          //     console.log("缓存楼层", res);
+          //   })
+          //   .catch(error => {
+          //     console.log("缓存楼层", error);
+          //   });
+          //   return
+          // }
           setFloor({ plazaId: this.plazaIds }, dataArr)
             .then(res => {
               console.log("缓存楼层", res);

+ 9 - 11
src/components/floorMap/index.vue

@@ -72,18 +72,18 @@ export default {
             this.floorid = floorid
             this.mapSize()
             this.$refs.canvasFun.isShow = false;
-            console.log('haveFengMap',this.haveFengMap)
             setTimeout(() => {
-                if (this.haveFengMap) {
-                    this.clearGraphy()
-                    this.scene = new FloorScene()
+                this.clearGraphy()
+                this.scene = new FloorScene()
+                if (this.haveFengMap == 1) {
                     this.scene.selectContainer.connect('listChange', this, this.listChange)
                     if (this.canvasID != `canvas${this.id}`) {
                         this.canvasID = `canvas${this.id}`
                     }
                     this.parserData(floorid)
-                }else{
-                   this.loading = false
+                }else if(this.haveFengMap == 0){
+                   this.view.scene = this.scene;
+                   this.readGraph()
                 }
             }, 100)
         },
@@ -136,7 +136,6 @@ export default {
         },
         readGraph(){
             this.readGroup(this.floorid).then(data => {
-                this.loading = false
                 if (data.Result == 'failure') {
                     this.$store.commit('SETISMESSAGE', false)
                     this.view.fitSceneToView()
@@ -229,6 +228,7 @@ export default {
                 if (this.$refs.canvasFun) {
                     this.$refs.canvasFun.everyScale = this.view.scale
                 }
+                this.loading = false;
             }).catch(()=>{
                 this.loading = false
             })
@@ -419,10 +419,8 @@ export default {
                 }
             }
         },
-        haveFengMap(val) {
-            if (val) {
-                this.init(this.floorid)
-            }
+        haveFengMap() {
+            this.init(this.floorid)
         }
     },
     mounted() {

+ 4 - 4
src/store/index.js

@@ -8,9 +8,9 @@ import router from '../router'
 Vue.use(Vuex)
 export default new Vuex.Store({
     state: {
-        // ssoToken: 'admin:chuyushu',
+        ssoToken: 'admin:chuyushu',
         // ssoToken: '',
-        ssoToken: null,
+        // ssoToken: null,
         plazaName: '',
         isPreview: false,
         lastRoute: '',
@@ -27,7 +27,7 @@ export default new Vuex.Store({
         floorsArr: [], //楼层数组
         floorSelect: [], //楼层下拉框
         fmapID: '',
-        haveFengMap: false, //是否有蜂鸟地图的数据
+        haveFengMap: -1, //是否有蜂鸟地图的数据 -1为等待 0 为失败 1 为成功
         isMessage: true, //是否有发布的图
         scpzTable: [], //土建装饰图例展示
         legendTable: [], //除土建装饰图例展示
@@ -111,7 +111,7 @@ export default new Vuex.Store({
         SETMAPID(state, data) {
             state.fmapID = data
         },
-        SETHAVEFENGMAP(state, data = true) {
+        SETHAVEFENGMAP(state, data) {
             state.haveFengMap = data
         },
         // 土建的图例