Sfoglia il codice sorgente

增加proxy代理+运行大楼代码

ming 2 anni fa
parent
commit
7935d59247
2 ha cambiato i file con 89 aggiunte e 35 eliminazioni
  1. 77 35
      src/views/index.vue
  2. 12 0
      vue.config.js

+ 77 - 35
src/views/index.vue

@@ -25,8 +25,8 @@
           <div class="card_center">
             <el-card class="box-card card_center1" style="padding:0 !important">
               <div class="map" style="height:45vh">
-                <!-- <iframe style="width:100%;height:100%;border:none;" src='https://www.thingjs.com/s/ef7ee6a73896c01bda77e679?params=105b0f77fd24654d4eebc434e9'></iframe> -->
-                <!-- <iframe style="width:100%;height:100%;border:none;" src='https://www.thingjs.com/s/b11227d4fd5505106989737c?params=105b0f77fd24654d4eebc434e9'></iframe> -->
+                <!-- <iframe id="myIframe" style="width:100%;height:100%;border:none;" src='https://www.thingjs.com/s/ef7ee6a73896c01bda77e679?params=105b0f77fd24654d4eebc434e9'></iframe> -->
+                <iframe  id="myIframe" style="width:100%;height:100%;border:none;" src='https://www.thingjs.com/s/b11227d4fd5505106989737c?params=105b0f77fd24654d4eebc434e9'></iframe>
 
               </div>
             </el-card>
@@ -278,6 +278,7 @@ import index2 from "./components/index/index2";
 import index3 from "./components/index/index3";
 import index5 from "./components/index/index5";
 import axios from 'axios'
+axios.defaults.baseURL = "/api";
 import $ from 'jquery'
 
 // import index6 from "./components/index/index6";
@@ -291,7 +292,7 @@ export default {
 
 
       title: "楼层展示",
-      open: true,
+      open: false,
       form: {},
       tableData: [{
             type: '火灾监控',
@@ -330,6 +331,8 @@ export default {
             undetail: '38', 
             rate:'50%'
           }],
+          buildingStore:[],
+          top_level:'',
 
 
       index1Data: [],//设备工况=>饼图
@@ -367,6 +370,9 @@ export default {
     this.yhTable()
     this.initWebSocket()
     this.getBuild()
+    
+    
+
   },
   mounted() {
 
@@ -377,44 +383,80 @@ export default {
     cancel() {
       this.open = false;
     },
+    draw_buinding(){
+      alert('运行大楼')
+      var _this=this;
+        setTimeout(function(){
+              _this.callFuncInThingJS('userListener', _this.buildingStore, _this.top_level, '10316') ;
+        },1000)
 
-    getBuild() {
-
-      // alert(1)
-      const aa = { "V_LOGINNAME": "gxdmxxg", "V_PASSWORD": "gxdmxxg123", "COMPANY_CODE": "10316", "COMMSTATUS": "NO" }
-      $.ajax({
-        type: 'POST',
-        url: 'http://47.103.74.123:8080/YtIoT/iot/frontpage/getCurrentObjectListByCompanyId',
-        data: { queryJson: JSON.stringify(aa) },
-        success: function (result) {
-
-          console.log(result)
-        }
-      });
-
-      // const aa={"V_LOGINNAME":"gxdmxxg","V_PASSWORD":"gxdmxxg123","COMPANY_CODE":"10316","COMMSTATUS":"NO"}
-      // alert(1)
-      // axios({
-      //     method: "post",
-      //     url: `http://47.103.74.123:8080/YtIoT/iot/frontpage/getCurrentObjectListByCompanyId`,
-      //     params: {
-      //        queryJson: JSON.stringify(aa) 
-      //     },
-      //     headers: {
+    },
 
-      //     },
-      // }).then((res) => {
-      //       console.log(res)
-      //     })
+    getBuild() {
+      // const params = { "V_LOGINNAME": "gxdmxxg", "V_PASSWORD": "gxdmxxg123", "COMPANY_CODE": "10316", "COMMSTATUS": "NO" }
+      // $.ajax({
+      //   type: 'POST',
+      //   url: 'http://47.103.74.123:8080/YtIoT/iot/frontpage/getCurrentObjectListByCompanyId',
+      //   data: { queryJson: JSON.stringify(params) },
+      //   success: function (result) {
+
+      //     console.log(result)
+      //   }
+      // });
+
+      const params={"V_LOGINNAME":"gxdmxxg","V_PASSWORD":"gxdmxxg123","COMPANY_CODE":"10316","COMMSTATUS":"NO"}
+      axios({
+          method: "post",
+          url: `/frontpage/getCurrentObjectListByCompanyId`,
+          params: {
+             queryJson: JSON.stringify(params) 
+          },
+          headers: {
+
+          },
+      }).then((res) => {
+        console.log('res')
+        console.log(res)
+        this.top_level = res.data.top_level;
+        this.buildingStore = res.data.LIST;
+        console.log( this.top_level)
+        console.log( this.buildingStore)
+        
+
+        this.draw_buinding();
+    
+        // var json = eval('(' + res + ')');
+        //     if (json.action == 'getCurrentObjectListByCompanyId') {
+        //         if (json.check == true) {
+        //             if (json.LIST != undefined) {
+                       
+        //                 this.top_level = json.top_level;
+                    
+        //                 this.buildingStore = json.LIST;
+        //             }
+        //             draw_buinding();
+        //         } else {
+        //           alert('错误信息')
+                   
+        //         }
+        //     }
+      })
 
-      // axios.get("https://fire.usky.cn:8443/YtIoT/iot/frontpage/getCurrentObjectListByCompanyId?",{
-      //                   params:{queryJson: JSON.stringify(aa) },
-      //                   headers:{'Content-Type': 'application/x-www-form-urlencoded'}
-      //               }).then((res)=>{
-      //                   console.log(res)})
 
 
     },
+   callFuncInThingJS(funcName, data, top_level, company_code) {
+      var iframe =document.getElementById("myIframe");  
+      var msg = {data, top_level, company_code}
+      var message = {
+          'funcName': funcName,
+          'param': msg
+      }
+      console.log('message')
+      console.log(message)
+      iframe.contentWindow.postMessage(message, '*');
+  },
+
 
     getList() {
 

+ 12 - 0
vue.config.js

@@ -41,7 +41,19 @@ module.exports = {
                 pathRewrite: {
                     ['^' + process.env.VUE_APP_BASE_API]: ''
                 }
+            },
+            '/api': {
+                target: 'http://47.103.74.123:8080/YtIoT/iot', //这里填入你要请求的接口的前缀
+                ws: true, //代理websocked
+                changeOrigin: true, //虚拟的站点需要更换origin
+                secure: true, //是否https接口,我用的http但是我变成false他打包后会报错,所以先true
+                pathRewrite: {
+                    '^/api': ''     //重写路径
+                }
+
             }
+
+           
         },
         disableHostCheck: true
     },