Explorar el Código

Merge branch 'master' of http://182.92.126.35:3000/msx/Vent-App

lxh hace 2 días
padre
commit
14b3757663
Se han modificado 3 ficheros con 72 adiciones y 67 borrados
  1. 1 4
      api/api.js
  2. 21 40
      pages/history/history.vue
  3. 50 23
      pages/home/detail/autodoor/autodoor.vue

+ 1 - 4
api/api.js

@@ -111,10 +111,7 @@ const apiService = {
   },
   //如果上面这个接口返回code码  则使用这个接口获取url
   getCameraByCode(params) {
-    // const urlParams = new URLSearchParams(params);
-    // const url =
-    //   "/ventanaly-device/camera/queryByCameraCode?" + urlParams.toString();
-    const url = buildURL("/ventanaly-device/camera/queryByCameraCode", params);
+    const url = buildURL("/monitor/camera/queryByCameraCode", params);
     return http.get(url);
   },
 

+ 21 - 40
pages/history/history.vue

@@ -365,11 +365,8 @@ export default {
       this.devices = [];
       data.forEach((element) => {
         const deviceObj = {
-          id: element.deviceId
-            ? element.deviceId
-            : element.deviceID
-            ? element.deviceID
-            : "",
+          // id: element.deviceID,
+          ID: element.deviceID,
           strinstallpos: element.strinstallpos,
           type: element.deviceType,
           stationtype: element.stationtype,
@@ -380,7 +377,8 @@ export default {
     },
     //选择设备  点击确定按钮  保存id
     selectDevice(e) {
-      this.deviceID = e.value[0].id;
+      // this.deviceId = e.value[0].id;
+      this.deviceID = e.value[0].ID;
       this.stationType = e.value[0].stationtype;
       this.strType = e.value[0].strtype;
       this.deviceType1 = e.value[0].type;
@@ -415,11 +413,13 @@ export default {
     },
     //查询历史数据 getDeviceHistory
     checkHistory() {
+      this.historyData = []; // 清空历史数据
       if (this.stationType !== "redis") {
         this.getHistoryData();
       } else {
         this.getHistoryData2();
       }
+      // this.getHistoryData2();
     },
     // 查询历史数据
     getHistoryData() {
@@ -432,7 +432,6 @@ export default {
         pageSize: 10,
         strtype: this.TabCur,
       };
-      console.log(params, "params");
       new Promise((resolve, reject) => {
         api
           .getDeviceHistory(params)
@@ -465,40 +464,22 @@ export default {
         pageSize: 10,
         strtype: this.TabCur + "*",
       };
-      new Promise((resolve, reject) => {
-        api
-          .getDeviceHistory2(params)
-          .then((response) => {
-            if (response.data.code == 200) {
-              this.historyData =
-                (response.data &&
-                  response.data.result &&
-                  response.data.result.records) ||
-                [];
-              // this.pageNo = response.data.result.datalist.current;
-              uni.showModal({
-                title: "数据提示",
-                content: this.historyData.length
-                  ? `共${
-                      this.historyData.length
-                    }条数据:\n${this.historyData.join("\n\n")}`
-                  : "暂无历史数据",
-                showCancel: false,
-                confirmText: "知道了",
-              });
-            } else {
-              resolve(response);
-              uni.showToast({
-                title: "请求失败",
-                icon: "none",
-                duration: 2000,
-              });
+      api
+        .getDeviceHistory2(params)
+        .then((response) => {
+          if (response.data.code === 200) {
+            const result1 = response.data.result;
+            if (result1.records.length != 0) {
+              this.historyData = result1.records;
             }
-          })
-          .catch((error) => {
-            reject(error);
-          });
-      });
+            // this.pageNo = response1.data.result.datalist.current;
+          } else {
+            reject(new Error(`请求失败,错误码:${response.data.code}`));
+          }
+        })
+        .catch((error) => {
+          reject(error);
+        });
     },
     async loadMoreData() {
       if (this.loading || !this.hasMoreData) return;

+ 50 - 23
pages/home/detail/autodoor/autodoor.vue

@@ -75,7 +75,6 @@
             :gatestate1="frontGateStatus"
             :gatestate2="midGateStatus"
             :gatestate3="rearGateStatus"
-            :cameralist="cameralist"
             :height="height"
             :doorcount="ndoorcount"
           >
@@ -114,20 +113,7 @@
             :nowfengji="qidongfengji"
           ></fanmainAnimate>
         </div>
-        <div
-          class="flcard"
-          v-if="this.TabCur == 'window' && this.nwindownum == 1"
-        >
-          <windowAnimate
-            :windowAngle="windowAngle"
-            :height="height"
-            :windowcount="nwindownum"
-          ></windowAnimate>
-        </div>
-        <div
-          class="flcard"
-          v-if="this.TabCur == 'window' && this.nwindownum == 2"
-        >
+        <div class="flcard" style="" v-if="this.TabCur == 'window'">
           <windowAnimate
             :windowAngle="windowAngle"
             :windowAngle1="windowAngle1"
@@ -135,6 +121,21 @@
             :windowcount="nwindownum"
           ></windowAnimate>
         </div>
+        <div v-if="this.cameraList.length > 0">
+          <div class="flcard" v-for="(item, index) in cameraList" :key="index">
+            <video
+              style="margin-left: 20px"
+              id="myVideo"
+              controls
+              show-loading
+              autoplay
+              class="r-video"
+              :vslide-gesture="true"
+              :vslide-gesture-in-fullscreen="true"
+              :src="item.addr"
+            ></video>
+          </div>
+        </div>
         <div class="flcard">
           <div
             class="flex-container"
@@ -671,7 +672,8 @@ export default {
       fan1State: "",
       fan2State: "",
       deviceid: "", //ID
-      cameralist: [], //摄像数据
+      cameras: [], //摄像头数据
+      cameraList: [], //摄像数据
       showColum: {},
       deviceShowList: [],
     };
@@ -693,7 +695,6 @@ export default {
   created() {
     this.getShowColum();
     this.getDeviceInfo(this.itemId);
-    this.getVideoUrlById(this.itemId);
   },
   mounted() {
     this.startTimer();
@@ -789,6 +790,9 @@ export default {
               var result = response.data.result.msgTxt[0].datalist[0];
               let newData = { ...result, ...result.readData };
               this.tableData = newData;
+              this.cameras = result.cameras;
+              this.getVideoUrlById(this.cameras);
+
               if (this.tableData["frontGateClose"] == "1") {
                 this.tableData.frontGateOpen = "关闭";
               } else if (this.tableData["frontGateClose"] == "0") {
@@ -845,16 +849,39 @@ export default {
       });
     },
     //获取监控URL 通过ID获取
-    getVideoUrlById(ID) {
-      let IDString = String(ID); // 将 ID 转换为字符串
+    getVideoUrlById(data) {
+      this.cameraList = []; // 清空摄像头列表
+      data.forEach((item) => {
+        const isHttp =
+          item.addr?.startsWith("http://") || item.addr?.startsWith("https://");
+        if (isHttp) {
+          this.cameraList.push(item);
+        } else {
+          this.getVideoUrlByCode(item.addr);
+        }
+      });
+    },
+    getVideoUrlByCode(ID) {
       new Promise((resolve, reject) => {
         api
-          .getCameraById({ deviceid: IDString })
+          .getCameraByCode({ cameraCode: ID, videoType: "" })
           .then((response) => {
             if (response.data.code == 200) {
-              if (response.data.result.records.length > 0) {
-                this.cameralist = response.data.result.records[0];
-              }
+              const addr = response.data.result.url;
+              this.cameraList.push({
+                addr: addr,
+                cameraCode: ID,
+              });
+              uni.showModal({
+                title: "数据提示",
+                content: this.cameraList.addr
+                  ? `共${
+                      this.cameraList.cameraCode
+                    }条数据:\n${this.cameraList.join("\n\n")}`
+                  : "无数据",
+                showCancel: false,
+                confirmText: "知道了",
+              });
             } else {
               resolve(response);
             }