guoxiaohuan 4 years ago
parent
commit
8d6d8d70ee
3 changed files with 240 additions and 235 deletions
  1. 209 227
      src/App.vue
  2. 29 6
      src/router/index.js
  3. 2 2
      src/store/index.js

+ 209 - 227
src/App.vue

@@ -1,143 +1,137 @@
 <template>
-  <div id="app">
-    <div :id="`fengMap${id}`" class="fengMap"></div>
-    <router-view />
-  </div>
+    <div id='app'>
+        <div :id='`fengMap${id}`' class='fengMap'></div>
+        <router-view />
+    </div>
 </template>
 <script>
-import { mapGetters, mapActions, mapMutations } from "vuex";
-import { SFengParser } from "@saga-web/feng-map";
-import { setFloor } from "@/api/public.js";
-window.fengmapData = null;
+import { mapGetters, mapActions, mapMutations } from 'vuex'
+import { SFengParser } from '@saga-web/feng-map'
+import { setFloor } from '@/api/public.js'
+window.fengmapData = null
 export default {
-  data() {
-    return {
-      view: "",
-      scene: "",
-      id: "2",
-      canvasID: "",
-      key: "23f30a832a862c58637a4aadbf50a566",
-      appName: "万达可视化系统",
-      mapServerURL: `http://map.wanda.cn/editor`,
-      mapthemeUrl: `http://map.wanda.cn/editor/webtheme`,
-      isMounted: false,
-      plazaIds: ""
-    };
-  },
-  /**
-   * 刷新保存vuex信息
-   */
-  created() {
-    this.$store.replaceState(
-      Object.assign(
-        this.$store.state,
-        JSON.parse(localStorage.getItem("beforeunload"))
-      )
-    );
-    //    刷新时,将haveFengMap 置为false,解决设备设施页面,刷新时不出新楼层图的问题
-    this.SETHAVEFENGMAP(-1);
-    localStorage.removeItem("beforeunload");
-    window.addEventListener("beforeunload", () => {
-      let state = JSON.stringify(this.$store.state);
-      localStorage.setItem("beforeunload", state);
-    });
-  },
-  mounted() {
-    this.isMounted = true;
-    this.plazaIds = localStorage.getItem("PLAZAID");
-  },
-  computed: {
-    ...mapGetters(["plazaId", "fmapID", "haveFengMap", "accessLevel"])
-  },
-  methods: {
-    ...mapActions(["getfmapID"]),
-    ...mapMutations(["SETHAVEFENGMAP"]),
-    getFengMap() {
-      this.getfmapID().then(() => {
-        this.getMap();
-      });
+    data() {
+        return {
+            view: '',
+            scene: '',
+            id: '2',
+            canvasID: '',
+            key: '23f30a832a862c58637a4aadbf50a566',
+            appName: '万达可视化系统',
+            mapServerURL: `http://map.wanda.cn/editor`,
+            mapthemeUrl: `http://map.wanda.cn/editor/webtheme`,
+            isMounted: false,
+            plazaIds: ''
+        }
+    },
+    /**
+     * 刷新保存vuex信息
+     */
+    created() {
+        let beforeunload = JSON.parse(localStorage.getItem('beforeunload'))
+        // 删除 store中的ssoToken
+        beforeunload && delete beforeunload.ssoToken
+        this.$store.replaceState(Object.assign(this.$store.state, beforeunload))
+        //    刷新时,将haveFengMap 置为false,解决设备设施页面,刷新时不出新楼层图的问题
+        this.SETHAVEFENGMAP(false)
+        localStorage.removeItem('beforeunload')
+        window.addEventListener('beforeunload', () => {
+            let state = JSON.stringify(this.$store.state)
+            localStorage.setItem('beforeunload', state)
+        })
+    },
+    mounted() {
+        this.isMounted = true
+        this.plazaIds = localStorage.getItem('PLAZAID')
     },
-    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
-      //   }
+    computed: {
+        ...mapGetters(['plazaId', 'fmapID', 'haveFengMap', 'accessLevel'])
+    },
+    methods: {
+        ...mapActions(['getfmapID']),
+        ...mapMutations(['SETHAVEFENGMAP']),
+        getFengMap() {
+            this.getfmapID().then(() => {
+                this.getMap()
+            })
+        },
+        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
+            //   }
 
-      window.fengmapData = new SFengParser(
-        `fengMap${this.id}`,
-        `${this.mapServerURL}/fmap/${this.fmapID}`,
-        this.key,
-        this.appName,
-        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;
-        });
-        // 获取主题数据
-        window.fengmapData
-          .loadTheme(
-            `${this.mapServerURL}/webtheme/${this.fmapID}/${this.fmapID}.theme`
-          )
-          .then(res => {
-            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"];
-          //   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);
+            window.fengmapData = new SFengParser(
+                `fengMap${this.id}`,
+                `${this.mapServerURL}/fmap/${this.fmapID}`,
+                this.key,
+                this.appName,
+                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
+                })
+                // 获取主题数据
+                window.fengmapData.loadTheme(`${this.mapServerURL}/webtheme/${this.fmapID}/${this.fmapID}.theme`).then(res => {
+                    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"];
+                    //   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)
+                        })
+                        .catch(error => {
+                            console.log('缓存楼层', error)
+                        })
+                }
             })
-            .catch(error => {
-              console.log("缓存楼层", error);
-            });
         }
-      });
-    }
-  },
-  watch: {
-    plazaIds(plazaId) {
-      console.log("获取到id", plazaId);
-      window.fengmapData = null;
-      // 当获取到到项目id,请求底图
-      if (plazaId) {
-        // 请求该项目下的楼层数据
-        this.getFengMap();
-      } else {
-        window.fengmapData = null;
-      }
     },
-    isMounted(isMounted) {
-      if (isMounted && this.plazaIds) {
-        this.getFengMap();
-      }
+    watch: {
+        plazaIds(plazaId) {
+            console.log('获取到id', plazaId)
+            window.fengmapData = null
+            // 当获取到到项目id,请求底图
+            if (plazaId) {
+                // 请求该项目下的楼层数据
+                this.getFengMap()
+            } else {
+                window.fengmapData = null
+            }
+        },
+        isMounted(isMounted) {
+            if (isMounted && this.plazaIds) {
+                this.getFengMap()
+            }
+        }
     }
-  }
-};
+}
 </script>
 <style lang="less">
 body,
@@ -165,8 +159,8 @@ input,
 textarea,
 th,
 td {
-  margin: 0;
-  padding: 0;
+    margin: 0;
+    padding: 0;
 }
 
 body,
@@ -174,7 +168,7 @@ button,
 input,
 select,
 textarea {
-  font: 12px/1.5 Arial, "Microsoft YaHei", "\65b0\5b8b\4f53";
+    font: 12px/1.5 Arial, 'Microsoft YaHei', '\65b0\5b8b\4f53';
 }
 
 h1,
@@ -183,7 +177,7 @@ h3,
 h4,
 h5,
 h6 {
-  font-size: 100%;
+    font-size: 100%;
 }
 
 address,
@@ -193,170 +187,158 @@ var,
 em,
 i,
 u {
-  font-style: normal;
+    font-style: normal;
 }
 
 ol,
 ul {
-  list-style: none;
+    list-style: none;
 }
 
 a {
-  text-decoration: none;
+    text-decoration: none;
 }
 
 a:hover {
-  text-decoration: underline;
+    text-decoration: underline;
 }
 
 img {
-  border: none;
-  vertical-align: middle;
+    border: none;
+    vertical-align: middle;
 }
 
 :focus {
-  outline: 0;
+    outline: 0;
 }
 
 button,
 input,
 select,
 textarea {
-  font-size: 100%;
+    font-size: 100%;
 }
 
 table {
-  border-collapse: collapse;
-  border-spacing: 0;
+    border-collapse: collapse;
+    border-spacing: 0;
 }
 
 /* 滚动条样式 */
 
 body ::-webkit-scrollbar {
-  width: 5px;
-  height: 8px;
+    width: 5px;
+    height: 8px;
 }
 
 body ::-webkit-scrollbar-track {
-  background-color: rgba(0, 0, 0, 0);
-  border-radius: 3px;
+    background-color: rgba(0, 0, 0, 0);
+    border-radius: 3px;
 }
 
 body ::-webkit-scrollbar-thumb {
-  border-radius: 3px;
-  background: #e6e6e6;
-  border: 1px solid #e6e6e6;
+    border-radius: 3px;
+    background: #e6e6e6;
+    border: 1px solid #e6e6e6;
 }
 
 body ::-webkit-scrollbar-thumb:vertical:hover {
-  background: #e6e6e6;
-  border: 1px solid #e6e6e6;
+    background: #e6e6e6;
+    border: 1px solid #e6e6e6;
 }
 
 #app {
-  //meri-design组件select的字体颜色
-  /deep/ .p-select-fakePlaceholder {
-    span {
-      span {
-        color: #606266 !important;
-        font-size: 13px;
-        font-weight: normal;
-      }
+    //meri-design组件select的字体颜色
+    /deep/ .p-select-fakePlaceholder {
+        span {
+            span {
+                color: #606266 !important;
+                font-size: 13px;
+                font-weight: normal;
+            }
+        }
+    }
+    //element 分页组件背景色
+    /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active {
+        background: linear-gradient(180deg, rgba(54, 156, 247, 1) 0%, rgba(2, 91, 170, 1) 100%);
+    }
+    //element button
+    /deep/ .el-button--primary,
+    .p-button-primary {
+        background: linear-gradient(180deg, rgba(54, 156, 247, 1) 0%, rgba(2, 91, 170, 1) 100%);
     }
-  }
-  //element 分页组件背景色
-  /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active {
-    background: linear-gradient(
-      180deg,
-      rgba(54, 156, 247, 1) 0%,
-      rgba(2, 91, 170, 1) 100%
-    );
-  }
-  //element button
-  /deep/ .el-button--primary,
-  .p-button-primary {
-    background: linear-gradient(
-      180deg,
-      rgba(54, 156, 247, 1) 0%,
-      rgba(2, 91, 170, 1) 100%
-    );
-  }
 }
 .clearfix::after {
-  content: ".";
-  display: block;
-  height: 0;
-  clear: both;
-  visibility: hidden;
+    content: '.';
+    display: block;
+    height: 0;
+    clear: both;
+    visibility: hidden;
 }
 .clearfix {
-  zoom: 1;
+    zoom: 1;
 }
 
 .left {
-  float: left;
+    float: left;
 }
 
 .right {
-  float: right;
+    float: right;
 }
 html,
 body {
-  width: 100%;
-  height: 100%;
-  // min-width: 1920px;
-  //   background: url('./assets/images/back.jpg') no-repeat;
+    width: 100%;
+    height: 100%;
+    // min-width: 1920px;
+    //   background: url('./assets/images/back.jpg') no-repeat;
 }
 #app {
-  height: 100%;
-  width: 100%;
-  position: relative;
-  .fengMap {
-    position: fixed;
-    width: 100px;
-    height: 100px;
-    z-index: -1;
-    opacity: 0;
-  }
+    height: 100%;
+    width: 100%;
+    position: relative;
+    .fengMap {
+        position: fixed;
+        width: 100px;
+        height: 100px;
+        z-index: -1;
+        opacity: 0;
+    }
 }
 // element表头背景颜色修改
 .core-device-report,
 .specification-update-record {
-  .el-table thead th {
-    background-color: #f8f9fa;
-  }
-  .el-pagination.is-background .el-pager li:not(.disabled).active {
-    background: linear-gradient(
-      180deg,
-      rgba(54, 156, 247, 1) 0%,
-      rgba(2, 91, 170, 1) 100%
-    );
-  }
+    .el-table thead th {
+        background-color: #f8f9fa;
+    }
+    .el-pagination.is-background .el-pager li:not(.disabled).active {
+        background: linear-gradient(180deg, rgba(54, 156, 247, 1) 0%, rgba(2, 91, 170, 1) 100%);
+    }
 }
 // 说明书更新记录 element 时间控件样式重写
 .specification-update-record,
 .core-device-report {
-  .el-input__inner {
-    height: 32px;
-    line-height: 32px;
-  }
-  .el-date-editor .el-range__icon,
-  .el-date-editor .el-range-separator {
-    line-height: 26px;
-    width: 8%;
-  }
+    .el-input__inner {
+        height: 32px;
+        line-height: 32px;
+    }
+    .el-date-editor .el-range__icon,
+    .el-date-editor .el-range-separator {
+        line-height: 26px;
+        width: 8%;
+    }
 }
 .el-dialog__header {
-  border-bottom: 1px solid rgba(239, 240, 241, 1);
+    border-bottom: 1px solid rgba(239, 240, 241, 1);
 }
 .gantt-chart .el-dialog__title {
-  font-weight: 500;
+    font-weight: 500;
 }
 .img-detail-container {
-  .el-dialog__body {
-    padding-top: 0;
-    padding-bottom: 0;
-    padding-right: 0;
-  }
+    .el-dialog__body {
+        padding-top: 0;
+        padding-bottom: 0;
+        padding-right: 0;
+    }
 }
 </style>

+ 29 - 6
src/router/index.js

@@ -91,14 +91,36 @@ router.beforeEach(async (to, from, next) => {
     beforeunload && (__token = JSON.parse(beforeunload).ssoToken)
     if (!ignore.includes(to.path)) {
         //都是需要token检验的页面 首先优先获取路由上带的token
-        let token = to.query.token ? to.query.token : store.getters['ssoToken'] ? store.getters['ssoToken'] : __token
-        // 开发环境模式token有模式值
-        if (process.env.NODE_ENV == 'aly' || process.env.NODE_ENV == 'serve') {
-            token = 'admin:chuyushu'
+        let token = null
+        if (to.query.token) {
+            store.commit('SETSSOTOKEN', to.query.token) //存vuex
+            sessionStorage.setItem('SSOTOKEN', to.query.token)
+            token = to.query.token
+        } else {
+            // to.query.token ? to.query.token : store.getters['ssoToken'] ? store.getters['ssoToken'] : __token
+            if (store.getters['ssoToken']) {
+                token = store.getters['ssoToken']
+            } else if (sessionStorage.getItem('SSOTOKEN')) {
+                token = sessionStorage.getItem('SSOTOKEN')
+                store.commit('SETSSOTOKEN', sessionStorage.getItem('SSOTOKEN')) //存vuex
+            } else {
+                let lastRoute = {
+                    path: to.path,
+                    params: to.params,
+                    query: to.query,
+                }
+                store.commit('SETLASTROUTER', lastRoute)
+                let ssoServer = 'http://oauth.wanda-dev.cn'
+                if (process.env.NODE_ENV == 'wanda_build') {
+                    ssoServer = 'http://oauth.wanda.cn'
+                }
+                let systemcode = 'CAD156',
+                    signal = new Date().getTime(),
+                    version = '1.0.0'
+                window.location.href = `${ssoServer}/login?systemcode=${systemcode}&signal=${signal}&version=${version}`
+            }
         }
-        // console.log('token====', token)
         if (token) {
-            store.commit('SETSSOTOKEN', token)
             if (to.path == '/') {
                 next('/group')
             }
@@ -109,6 +131,7 @@ router.beforeEach(async (to, from, next) => {
                     // await store.dispatch('getFact')
                 }
             }
+            console.log('token', token)
             await store.dispatch('getFloors')
             await store.dispatch('getBrand')
             // await store.dispatch('getFact')

+ 2 - 2
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: '',