ccj 3 年之前
父節點
當前提交
c1ca520f50
共有 2 個文件被更改,包括 62 次插入51 次删除
  1. 2 1
      .env.production
  2. 60 50
      src/views/home/index.vue

+ 2 - 1
.env.production

@@ -4,7 +4,8 @@
 
 NODE_ENV = 'production'
 # base api
-VUE_APP_BASE_API = 'http://api.eliangeyun.com'
+#VUE_APP_BASE_API = 'http://api2.eliangeyun.com'
+VUE_APP_BASE_API = 'http://apitest.eliangeyun.com'
 
 # 微服务相关接口配置
 ## 任务消息

+ 60 - 50
src/views/home/index.vue

@@ -7,10 +7,14 @@
         <!-- 任务、消息、提醒、超期 -->
         <Panel :data-list="panelList"
                @click="gotoNewRw"></Panel>
-        <button @click="openPort">测试</button>
-        <button @click="closePort">关闭</button>
-        <div>{{text}}</div>
-               <!-- <img style='width:100%;margin-top:10px;' src="../../../public/img/tmt.gif" alt=""> -->
+        <div v-show="true">
+          <el-button @click="test">test</el-button>
+          <el-button @click="test1">test1</el-button>
+          <el-button @click="openPort">openPort</el-button>
+          <el-button @click="closePort">closePort</el-button>
+          <div>{{text}}</div>
+        </div>
+       <!-- <img style='width:100%;margin-top:10px;' src="../../../public/img/tmt.gif" alt=""> -->
       </div>
     </div>
     <div id="mapXY"></div>
@@ -115,7 +119,8 @@ export default {
       },
       vesselBankFlag: sessionStorage.getItem('ws-pf_vesselBankFlag'),
       shezhiVal: '',
-      text:"数据"
+      text:"数据",
+      reader:null
     }
   },
   computed: {
@@ -179,11 +184,11 @@ export default {
   async created () {
     //获取快捷路口列表
     this.getRouteList()
-    this.checkUserInfoDialog()
+    // this.checkUserInfoDialog()
   },
   async mounted () {
     //获取新闻列表
-    this.getNewList()
+    // this.getNewList()
     noticeNumber().toPromise().then(res => {
       const { task = 0, remind = 0, overdue = 0, news = 0 } = res
       this.number.task = task
@@ -191,16 +196,16 @@ export default {
       this.number.overdue = overdue
       this.number.news = news
     })
-    if (this.vesselBankFlag !== 'V') {
-      EventBus.$emit('addShipScript', () => {
-        this.initShipMap()
-      })
-    }
-    setTimeout(() => {
-      this.showEchart = true
-    }, 900)
+    // if (this.vesselBankFlag !== 'V') {
+    //   EventBus.$emit('addShipScript', () => {
+    //     this.initShipMap()
+    //   })
+    // }
+    // setTimeout(() => {
+    //   this.showEchart = true
+    // }, 900)
 
-    this.showBlockList = []
+    // this.showBlockList = []
     // if (this.vesselBankFlag === 'V') {
     //   this.$refs.noticeList.style.width = 'calc(50% - 7px)'
     //   this.$refs.newsList.style.width = 'calc(50% - 7px)'
@@ -216,9 +221,9 @@ export default {
     // }
   },
   watch: {
-    getLanguage: function () {
-      this.getShipList()
-    }
+    // getLanguage: function () {
+    //   this.getShipList()
+    // }
   },
   methods: {
     ...mapActions('user', ['toSetShow', 'changeVesslBank']),
@@ -531,42 +536,47 @@ export default {
         this.$router.push({ name: 'workNotification', query: { types: data } })
       }
     },
+    test(){
+      console.log('testtesttesttest');
+    },
+    async test1(){
+      console.log('testtesttesttest111111');
+    },
     async openPort(){
-      if ("serial" in navigator) {
-      // The Web Serial API is supported.
-      console.log("the Web Serial API is supported.");
-      const port = await navigator.serial.requestPort();
-      await port.open({ baudRate: 9600 }); // set baud rate
-      const reader = port.readable.getReader();
-      // 监听来自串行设备的数据
-      while (true) {
-        const { value, done } = await reader.read();
-        console.log(value,done);
-        if (done) {
-          // 允许稍后关闭串口。
-          reader.releaseLock();
-          break;
-        }
-        var result="";
-        if(value.length < 5){
-          debugger
-        }
-        for(var i=0;i<value.length;i++){
-          result += String.fromCharCode(value[i])
+      console.log('openPort');
+      if ('serial' in navigator) {
+        // The Web Serial API is supported.
+        console.log('the Web Serial API is supported.');
+        const port = await navigator.serial.requestPort();
+        await port.open({ baudRate: 9600 }); // set baud rate
+        this.reader = port.readable.getReader();
+        // 监听来自串行设备的数据
+        while (true) {
+          const { value, done } = await this.reader.read();
+          console.log(value,done);
+          if (done) {
+            // 允许稍后关闭串口。
+            this.reader.releaseLock();
+            break;
+          }
+          var result="";
+          if(value.length < 5){
+          }
+          for(var i=0;i<value.length;i++){
+            result += String.fromCharCode(value[i])
+          }
+          this.text = result
+          // value 是一个 Uint8Array
         }
-        this.text = result
-        // value 是一个 Uint8Array
+         await port.close();
+      }
+      else{
+        console.log('the Web Serial API is not supported.',navigator);
       }
-     
-    }
     },
     async closePort(){
-      
-      const port = await navigator.serial.requestPort();
-      await port.open({ baudRate: 9600 }); // set baud rate
-      const reader = port.readable.getReader();
-      reader.cancel()
-      port.close();
+      console.log('closePort');
+      this.reader.cancel()
     }
   }
 }