Переглянути джерело

更新 接入大坝信息数据

wzh 4 роки тому
батько
коміт
aac2573638
2 змінених файлів з 17 додано та 8 видалено
  1. 3 5
      src/components/EnvironmentalModule.vue
  2. 14 3
      src/store/index.js

+ 3 - 5
src/components/EnvironmentalModule.vue

@@ -12,20 +12,18 @@
 </template>
 
 <script>
-import { ref, onMounted } from "vue";
+import { ref, onMounted, computed } from "vue";
 import { mapState } from "vuex";
+import store from "store/index";
 import exchangeUrl from "utils/exchangeUrl";
 
 export default {
   computed: mapState(["damInfo"]),
   setup() {
-    function init() {}
-
     onMounted(() => {
-      init();
+      store.dispatch("GetSanxiaInfo");
     });
     return {
-      init,
       exchangeUrl,
     };
   },

+ 14 - 3
src/store/index.js

@@ -1,4 +1,5 @@
 import { createStore } from "vuex";
+import api from "apis/fetch.js";
 
 const store = createStore({
   state: {
@@ -61,19 +62,19 @@ const store = createStore({
       data: [
         {
           title: "上游前往三峡数量",
-          text: "98700",
+          text: "0",
           unit: "艘",
           icon: "ship-fill",
         },
         {
           title: "三峡等闸船舶数量",
-          text: "88300",
+          text: "0",
           unit: "艘",
           icon: "dam",
         },
         {
           title: "预计等待时间",
-          text: "98700",
+          text: "0",
           unit: "分",
           icon: "clock",
         },
@@ -104,6 +105,11 @@ const store = createStore({
     setNumbers(state, numbers) {
       state.numbers = numbers;
     },
+    setDamInfo(state, nums) {
+      state.damInfo.data[0].text = nums.upstreamShipNum;
+      state.damInfo.data[1].text = nums.waitingShipNum;
+      state.damInfo.data[2].text = nums.estimatedWaitingTime;
+    },
   },
   actions: {
     Login({ commit }, userInfo) {
@@ -120,6 +126,11 @@ const store = createStore({
         resolve(0);
       });
     },
+    GetSanxiaInfo({ commit }) {
+      api.getSanxiaInfo().then((e) => {
+        commit("setDamInfo", e.data.result);
+      });
+    },
     GetNumbers({ commit, state }, type) {
       return new Promise((resolve, reject) => {
         let arr1 = [