xiaoxin 2 vuotta sitten
vanhempi
commit
7afe593d40
2 muutettua tiedostoa jossa 58 lisäystä ja 34 poistoa
  1. 37 0
      src/api/video/index.ts
  2. 21 34
      src/views/safe/center/watchDetailDialog.vue

+ 37 - 0
src/api/video/index.ts

@@ -1,5 +1,6 @@
 import axios from "axios";
 import axios from "axios";
 
 
+// 获取监控视频地址
 export const getVedio = async (rtspaddr: string) => {
 export const getVedio = async (rtspaddr: string) => {
   const res = await axios({
   const res = await axios({
     method: "post",
     method: "post",
@@ -17,3 +18,39 @@ export const getVedio = async (rtspaddr: string) => {
     return ws_url;
     return ws_url;
   }
   }
 };
 };
+
+import request from "@/utils/request";
+
+enum API {
+  // 登录获取监控权限
+  VIDEOLOGIN_URL = "/av_ja/videoAdmin/login",
+
+  // 获取监控列表数组
+  VIDEOLIST_URL = "/av_ja/camera/queryCamera",
+
+  // 监控拉流
+  VIDEOPULL_URL = "/av_ja/stream/addStreamSource",
+}
+
+//登录获取监控权限
+export const reqVideoLogin = (data: any) =>
+  request.post(API.VIDEOLOGIN_URL, data, { headers: { type: "local" } });
+
+//获取监控列表数组
+export const reqVideoList = (params: any) =>
+  request.get(API.VIDEOLIST_URL, {
+    params,
+    headers: {
+      type: "local",
+      admin_token: localStorage.getItem("admin_token"),
+    },
+  });
+
+//监控拉流
+export const reqVideoPull = (data: any) =>
+  request.post(API.VIDEOPULL_URL, data, {
+    headers: {
+      type: "local",
+      admin_token: localStorage.getItem("admin_token"),
+    },
+  });

+ 21 - 34
src/views/safe/center/watchDetailDialog.vue

@@ -18,7 +18,7 @@
             :key="index"
             :key="index"
             @click="handleChange(index, item)"
             @click="handleChange(index, item)"
           >
           >
-            {{ item.d
+            {{ item.d || "未知"
             }}{{ item.installationSite ? "-" + item.installationSite : "" }}
             }}{{ item.installationSite ? "-" + item.installationSite : "" }}
           </div>
           </div>
         </div>
         </div>
@@ -44,10 +44,14 @@ import { ref, onMounted, onUnmounted } from "vue";
 // 引入监控数据
 // 引入监控数据
 import { watchData } from "@/components/map/watchData";
 import { watchData } from "@/components/map/watchData";
 // 引入监控相关的数据接口
 // 引入监控相关的数据接口
-import { getVedio } from "@/api/video/index";
+import {
+  getVedio,
+  reqVideoLogin,
+  reqVideoList,
+  reqVideoPull,
+} from "@/api/video/index";
 // @ts-ignore
 // @ts-ignore
 import WasmPlayer from "@easydarwin/easywasmplayer";
 import WasmPlayer from "@easydarwin/easywasmplayer";
-import axios from "axios";
 
 
 const props = defineProps(["currentWatch"]);
 const props = defineProps(["currentWatch"]);
 const $emit = defineEmits(["closeDialog"]);
 const $emit = defineEmits(["closeDialog"]);
@@ -104,17 +108,13 @@ onUnmounted(() => {
 
 
 // 登录获取监控权限
 // 登录获取监控权限
 const handleLogin = async () => {
 const handleLogin = async () => {
-  const res = await axios({
-    url: "http://6.205.66.13:8083/av_ja/videoAdmin/login",
-    method: "post",
-    data: {
-      username: "admin",
-      password: "admin.123456",
-    },
+  const res = await reqVideoLogin({
+    username: "admin",
+    password: "admin.123456",
   });
   });
-  console.log(res);
+  // console.log(res);
   if ((res as any).code === 200) {
   if ((res as any).code === 200) {
-    localStorage.setItem("admin_token", res.data.code);
+    localStorage.setItem("admin_token", res.data.token);
 
 
     // 获取监控列表数据
     // 获取监控列表数据
     getVideoList();
     getVideoList();
@@ -123,18 +123,12 @@ const handleLogin = async () => {
 
 
 // 获取监控列表数据
 // 获取监控列表数据
 const getVideoList = async () => {
 const getVideoList = async () => {
-  const res = await axios({
-    url: "http://6.205.66.13:8083/av_ja/videoAdmin/login",
-    params: {
-      pageNum: 1,
-      pageSize: 100,
-      spot: props.currentWatch,
-    },
-    headers: {
-      admin_token: localStorage.getItem("admin_token"),
-    },
+  const res = await reqVideoList({
+    pageNum: 1,
+    pageSize: 100,
+    spot: props.currentWatch,
   });
   });
-  console.log(res);
+  // console.log(res);
   if ((res as any).code === 200) {
   if ((res as any).code === 200) {
     videoList.value = res.data.list;
     videoList.value = res.data.list;
     currentD.value = videoList.value[0].d;
     currentD.value = videoList.value[0].d;
@@ -145,18 +139,11 @@ const getVideoList = async () => {
 
 
 // 拉流请求
 // 拉流请求
 const addStreamSource = async () => {
 const addStreamSource = async () => {
-  const res = await axios({
-    url: "http://6.205.66.13:8083/av_ja/stream/addStreamSource",
-    method: "post",
-    data: {
-      d: currentD.value,
-      nowLine: "1",
-    },
-    headers: {
-      admin_token: localStorage.getItem("admin_token"),
-    },
+  const res = await reqVideoPull({
+    d: currentD.value,
+    nowLine: "1",
   });
   });
-  console.log(res);
+  // console.log(res);
   if ((res as any).code === 200) {
   if ((res as any).code === 200) {
     getVideosData(res.data.flv_ws);
     getVideosData(res.data.flv_ws);
   }
   }