From a689af1348938afd3b4506aad9b6d5057193e25d Mon Sep 17 00:00:00 2001
From: ZZJ <10913410+zzj2100@user.noreply.gitee.com>
Date: 星期五, 27 五月 2022 09:59:00 +0800
Subject: [PATCH] bug修复

---
 src/components/canvas/index.vue |   60 ++++++++++++++++++++++++++++++++----------------------------
 1 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/src/components/canvas/index.vue b/src/components/canvas/index.vue
index b7266ef..016dc18 100644
--- a/src/components/canvas/index.vue
+++ b/src/components/canvas/index.vue
@@ -79,9 +79,8 @@
       },
       type: Object,
     },
-    currentCameraId: {
-      type: String,
-      default: "",
+    currentCamera: {
+      type: Object,
     },
     snapshot_url: {
       type: String,
@@ -116,9 +115,14 @@
           return this.snapshot_url.replace("/opt/vasystem", "");
         }
 
+        if (this.snapshot_url.indexOf("data:image/png;base64,") != -1) {
+          return `${this.snapshot_url}`;
+        }
+
         if (this.sourceType == 2) {
           return `${this.snapshot_url}`;
         } else {
+          console.log(this.snapshot_url);
           return `/httpImage/${this.snapshot_url}`;
         }
       } else {
@@ -148,7 +152,6 @@
   watch: {
     loading: {
       handler(newVal, oldVal) {
-        // console.log(newVal,'loading')
         if (newVal) {
           this.baseImg = "";
           this.refresh();
@@ -182,30 +185,30 @@
     async getCanvasPic() {
       // this.$emit('changeBaseImg',this.currentCameraId)
       this.$emit("changeLoading", true);
-      if (this.currentCameraId) {
+      if (this.currentCamera.cameraId) {
         let _this = this;
-        await updateSnapshot(this.currentCameraId)
-          .then((res) => {
-            if (res.data.cameraId === _this.currentCameraId) {
-              this.baseImg = res.data.snapshotUrl;
-              this.$emit(
-                "refresh",
-                res.data.snapshotUrl,
-                _this.currentCameraId
-              );
-              this.$forceUpdate();
-              this.$notify({
-                type: "success",
-                message: "搴曞浘宸插埛鏂�",
-              });
-            }
-          })
-          .catch((err) => {
-            this.$notify({
-              type: "error",
-              message: "搴曞浘鍒锋柊澶辫触",
+
+        await updateSnapshot({
+          id: _this.currentCamera.cameraId,
+          name: _this.currentCamera.cameraName,
+          type: _this.currentCamera.type,
+          rtsp: _this.currentCamera.rtsp,
+        }).then((res) => {
+          if (res.data.cameraId === _this.currentCamera.cameraId) {
+            _this.baseImg = "data:image/png;base64," + res.data.base64;
+            _this.$emit(
+              "refresh",
+              _this.baseImg,
+              _this.currentCamera.cameraName
+            );
+            _this.$forceUpdate();
+            _this.$notify({
+              type: "success",
+              message: "搴曞浘宸插埛鏂�",
             });
-          });
+          }
+        });
+
         this.$emit("changeLoading", false);
       }
     },
@@ -523,8 +526,9 @@
       ctx.restore();
     },
     async refresh() {
-      // console.log(this.loading,'鍒锋柊搴曞浘',this.snapshot_url)
-      if (!this.currentCameraId) {
+      console.log("鍒锋柊搴曞浘");
+      if (!this.currentCamera.cameraId) {
+        console.log("娌″埛鏂�");
         return false;
       }
       // await this.$emit('changeLoading', true)

--
Gitblit v1.8.0