From 44dd9c4eb8a2489c63a5eb53fd4254bbb3510e95 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Thu, 18 Jun 2026 09:14:57 +0800
Subject: [PATCH] Merge branch 'feature/v9.0/9.0.4'

---
 src/subPackages/droneConsole/index.vue |  131 +++++++++++++------------------------------
 1 files changed, 39 insertions(+), 92 deletions(-)

diff --git a/src/subPackages/droneConsole/index.vue b/src/subPackages/droneConsole/index.vue
index a39ab4e..b296006 100644
--- a/src/subPackages/droneConsole/index.vue
+++ b/src/subPackages/droneConsole/index.vue
@@ -5,74 +5,42 @@
 <script setup>
 import {onHide, onLoad, onShow} from "@dcloudio/uni-app";
 import WebViewPlus from "@/components/WebViewPlus.vue";
-import {getWebViewUrl} from "@/utils/index.js";
-import Recorder from "js-audio-recorder";
-import dayjs from "dayjs";
+import {getEnvObj, getWebViewUrl} from "@/utils/index.js";
 import {useUserStore} from "@/store/index.js";
 
-const wayLineJodInfoId = ref(null)
-const startState = ref('0')
-let recorder
-const soundVideoName = ref('') // 喊话名称
-soundVideoName.value = `${dayjs().format('YYYYMMDDHHmmss')}实时喊话`
-const droneHornState = ref('0')
-const uNotifyRef = ref(null)
-
-const viewUrl = computed(() => {
-  return getWebViewUrl('/DroneConsole', {
-    wayLineJodInfoId: wayLineJodInfoId.value,
-    startState: startState.value,
-    droneHornState: droneHornState.value
-  })
-})
-
 function onPostMessage(data) {
-  if (data.type === 'record') {
-    startState.value = '1'
-    recorder = new Recorder({
-      sampleBits: 16, // 采样位数,支持8或16,默认16
-      sampleRate: 16000, // 采样率,支持11025、16000、22050、24000、44100、48000
-      numChannels: 1, // 声道,支持1或2,默认1
-    })
-    nextTick(() => {
-      recorder.start().then(() => {
-        recorder.onprocess = duration => {
-        }
-      })
-    })
-  } else if (data.type === 'stopRecord') {
-    startState.value = '2'
-    recorder.stop()
-  } else if (data.type === 'trialListening') {
-    recorder.play()
-  } else if (data.type === 'resetRecording') {
-    startState.value = '0'
-    recorder?.destroy().then(() => {
-      recorder = null // 释放资源
-    })
-  } else if (data.type === 'pushToDrone') {
-    pushToDrone(data)
-  } else if (data.type === 'saveSound') {
-    saveSound(data)
+  if (data.type === 'back'){
+    // #ifdef H5
+    window.history.back()
+    // #endif
+
+    // #ifdef APP-PLUS
+    uni.navigateBack({
+      delta: 1 // 返回的页面数,默认1(返回上一页)
+    });
+    // #endif
   }
 }
 
+
+// 文件上传demo
+const {VITE_API_BASE_URL} = getEnvObj()
 function uploadUtil(options) {
   const {formData, file, url} = options
   return new Promise((resolve, reject) => {
     let accessToken = useUserStore()?.$state?.userInfo?.access_token;
     const file = new File([recorder.getWAVBlob()], '.wav')
     uni.uploadFile({
-      url: `https://wrj.shuixiongit.com/api${url}`,
+      url: `${VITE_API_BASE_URL}${url}`,
       name: 'file',
       header: {'Blade-Auth': 'bearer ' + accessToken},
       file,
       formData,
       success: (res) => {
         const resData = JSON.parse(res.data)
-        if (resData.code === 200){
+        if (resData.code === 200 || resData.code === 0) {
           resolve(res)
-        }else{
+        } else {
           showToast(resData.message)
           reject(res)
         }
@@ -88,25 +56,19 @@
   uNotifyRef.value.show({
     type: 'default',
     message,
-    // top: 10,
-    // color: '#fff',
-    // bgColor: '#000',
-    // message,
-    // duration: 1000 * 3,
-    // fontSize: 20,
-    // safeAreaInsetTop: true
   });
 }
 
 
 // 保存喊话至广播列表内
 function saveSound(data) {
-  const file = new File([recorder.getWAVBlob()], '.wav')
+  const recorder = 'xxx'
+  const file = new File([recorder?.getWAVBlob()], '.wav')
   uploadUtil({
     file,
     formData: {
-      fileName: data.soundName,
-      sn: data.dockSn
+      fileName: 'xxx',
+      sn: 'xxx',
     },
     url: '/drone-device-core/speak/api/v1/uploadSpeak'
   }).then(res => {
@@ -114,43 +76,28 @@
   })
 }
 
-// 无人机开始喊话
-function pushToDrone(data) {
-  const wavBlob = recorder.getWAVBlob()
-  const file = new File([wavBlob], new Date().getTime() + '.wav')
-  uploadUtil({
-    file,
-    formData: {
-      name: data.soundName,
-      sn: data.dockSn,
-      psdk_index: 2,
-      volumn: 100,
-    },
-    url: '/drone-device-core/speak/api/v1/startVoice'
-  }).then(res => {
-    droneHornState.value = '1'
-    showToast('播放成功')
-  }).catch(() => {
-    droneHornState.value = '0'
-  })
-}
-
+const viewUrl = ref("");
 onLoad((options) => {
-  wayLineJodInfoId.value = options.wayLineJodInfoId
+  viewUrl.value = getWebViewUrl("/DroneConsole", {
+    wayLineJobInfoId: options.wayLineJobInfoId,
+    dockSn: options.dockSn,
+  });
 })
 
 
-// onShow(() => {
-//   // #ifdef APP-PLUS
-//   plus.screen.lockOrientation("landscape-primary");
-//   // #endif
-// });
-//
-// onHide(() => {
-//   // #ifdef APP-PLUS
-//   plus.screen.lockOrientation("portrait-primary");
-//   // #endif
-// });
+onShow(() => {
+  // #ifdef APP-PLUS
+  plus.navigator.setFullscreen(true); // 加入全屏
+  plus.screen.lockOrientation("landscape-primary");//横屏
+  // #endif
+});
+
+onHide(() => {
+  // #ifdef APP-PLUS
+  plus.navigator.setFullscreen(false);
+  plus.screen.lockOrientation("portrait-primary");
+  // #endif
+});
 </script>
 <style scoped lang="scss">
 

--
Gitblit v1.9.3