diff --git a/src/utils/initLogin.js b/src/utils/initLogin.js
index cf57a84..7b0a98d 100644
--- a/src/utils/initLogin.js
+++ b/src/utils/initLogin.js
@@ -39,3 +39,11 @@ export const stopDeviceCameraZoomApi = (data) => {
export const stopDeviceCameraApi = (data) => {
return service.post('/ptz/stop/turn', data)
}
+// 开启喊话
+export const openDeviceMKApi = (data) => {
+ return service.post('/icvs/audio/startCall?token=' + data.token, data)
+}
+// 关闭喊话
+export const stopDeviceMKApi = (data) => {
+ return service.post('/icvs/audio/stopTalk?token=' + data.token, data)
+}
diff --git a/src/views/home/components/control-deck-new.vue b/src/views/home/components/control-deck-new.vue
index 9343408..26000b7 100644
--- a/src/views/home/components/control-deck-new.vue
+++ b/src/views/home/components/control-deck-new.vue
@@ -185,36 +185,36 @@
- 关
+ 关闭
- 闪烁
+ 开启
- 运动时闪烁
+ 自动
@@ -320,7 +320,18 @@
-

+
+

+
+
+
结束喊话
@@ -386,6 +397,7 @@ import {
BatteryFullSharp,
BatteryChargingSharp,
} from '@vicons/ionicons5'
+import { openDeviceMKApi, stopDeviceMKApi } from '@/utils/initLogin'
import { useMessage, useDialog, NRadio, NRadioGroup, NInputNumber, NSpace } from 'naive-ui'
import { debounce } from 'lodash'
@@ -404,7 +416,7 @@ const isDragging = ref(false)
const currentTop = ref(0)
const startY = ref(0)
const startTop = ref(0)
-const checkedValue = ref('')
+const checkedValue = ref('关闭')
const selectValue = ref('')
const deviceToken = ref('')
const deviceInfo = ref({})
@@ -603,16 +615,41 @@ onMounted(() => {
})
const handleChange1 = (e) => {
- console.log(e)
checkedValue.value = e.target.value
+ handleChangeLight(checkedValue.value)
}
const handleChange2 = (e) => {
- console.log(e)
checkedValue.value = e.target.value
+ handleChangeLight(checkedValue.value)
}
const handleChange3 = (e) => {
checkedValue.value = e.target.value
+ handleChangeLight(checkedValue.value)
}
+
+// 警灯闪烁
+
+const handleChangeLight = async (value) => {
+ const lightMap = {
+ 关闭: 'OFF',
+ 开启: 'ON',
+ 自动: 'AUTO',
+ }
+
+ const { data: res } = await handleRobotActionApi({
+ puId: robotData.robotInfo?.puId,
+ type: '19',
+ value: lightMap[value],
+ })
+
+ if (res.code == 200) {
+ message.success('操作成功')
+ } else {
+ message.error('操作失败')
+ checkedValue.value = '关闭'
+ }
+}
+
const handleChange4 = (e) => {
checkedValue.value = e.target.value
}
@@ -775,6 +812,55 @@ const handleChangeVolume = debounce(async (value) => {
}
}, 1000)
+const isOpenMK = ref(false)
+const onHandleOpenOrCloseMK = async (type) => {
+ if (type === 1) {
+ // 先判断当前设备有没有开启MK
+ try {
+ // 请求麦克风权限并检查状态
+ const stream = await navigator.mediaDevices.getUserMedia({ audio: true })
+
+ // 检查麦克风是否真的在接收声音(可选)
+ const audioTracks = stream.getAudioTracks()
+ if (audioTracks.length > 0) {
+ audioTracks.forEach((track) => track.stop())
+
+ // 调用麦克风开启接口
+ const { data: res } = await openDeviceMKApi({
+ token: deviceToken.value,
+ puId: robotData.robotInfo?.puId,
+ idx: 0,
+ })
+
+ if (res.code == 200) {
+ message.success('麦克风开启成功')
+ isOpenMK.value = true
+ } else {
+ message.error('麦克风开启失败')
+ }
+ } else {
+ message.error('未检测到音频输入设备')
+ }
+ } catch (error) {
+ message.error('麦克风访问被拒绝或不可用,请检查麦克风权限')
+ }
+ } else {
+ // 调用麦克风开启接口
+ const { data: res } = await stopDeviceMKApi({
+ token: deviceToken.value,
+ puid: deviceInfo.value?.puId,
+ idx: 0,
+ })
+
+ if (res.code == 200) {
+ message.success('麦克风已关闭')
+ isOpenMK.value = false
+ } else {
+ message.error('麦克风关闭失败')
+ }
+ }
+}
+
onMounted(async () => {
const token = await getRobotTokenFn() // 获取设备token
const device = await getRobotDeviceListFn() // 获取设备信息
diff --git a/src/views/home/components/control-deck.vue b/src/views/home/components/control-deck.vue
index 7a631b0..d3ac64b 100644
--- a/src/views/home/components/control-deck.vue
+++ b/src/views/home/components/control-deck.vue
@@ -185,36 +185,36 @@
- 关
+ 关闭
- 闪烁
+ 开启
- 运动时闪烁
+ 自动
@@ -320,7 +320,15 @@
-

+

+
+ 结束喊话
+
@@ -386,6 +394,7 @@ import {
BatteryFullSharp,
BatteryChargingSharp,
} from '@vicons/ionicons5'
+import { openDeviceMKApi, stopDeviceMKApi } from '@/utils/initLogin'
import { useMessage, useDialog, NRadio, NRadioGroup, NInputNumber, NSpace } from 'naive-ui'
import { debounce } from 'lodash'
@@ -404,7 +413,7 @@ const isDragging = ref(false)
const currentTop = ref(0)
const startY = ref(0)
const startTop = ref(0)
-const checkedValue = ref('')
+const checkedValue = ref('关闭')
const selectValue = ref('')
const deviceToken = ref('')
const deviceInfo = ref({})
@@ -627,15 +636,39 @@ onMounted(() => {
})
const handleChange1 = (e) => {
- console.log(e)
checkedValue.value = e.target.value
+ handleChangeLight(checkedValue.value)
}
const handleChange2 = (e) => {
- console.log(e)
checkedValue.value = e.target.value
+ handleChangeLight(checkedValue.value)
}
const handleChange3 = (e) => {
checkedValue.value = e.target.value
+ handleChangeLight(checkedValue.value)
+}
+
+// 警灯闪烁
+
+const handleChangeLight = async (value) => {
+ const lightMap = {
+ 关闭: 'OFF',
+ 开启: 'ON',
+ 自动: 'AUTO',
+ }
+
+ const { data: res } = await handleRobotActionApi({
+ puId: robotData.robotInfo?.puId,
+ type: '19',
+ value: lightMap[value],
+ })
+
+ if (res.code == 200) {
+ message.success('操作成功')
+ } else {
+ message.error('操作失败')
+ checkedValue.value = '关闭'
+ }
}
const handleChange4 = (e) => {
checkedValue.value = e.target.value
@@ -711,6 +744,55 @@ const handleChangeZoomCamera = async (motion) => {
}
}
+const isOpenMK = ref(false)
+const onHandleOpenOrCloseMK = async (type) => {
+ if (type === 1) {
+ // 先判断当前设备有没有开启MK
+ try {
+ // 请求麦克风权限并检查状态
+ const stream = await navigator.mediaDevices.getUserMedia({ audio: true })
+
+ // 检查麦克风是否真的在接收声音(可选)
+ const audioTracks = stream.getAudioTracks()
+ if (audioTracks.length > 0) {
+ audioTracks.forEach((track) => track.stop())
+
+ // 调用麦克风开启接口
+ const { data: res } = await openDeviceMKApi({
+ token: deviceToken.value,
+ puId: robotData.robotInfo?.puId,
+ idx: 0,
+ })
+
+ if (res.code == 200) {
+ message.success('麦克风开启成功')
+ isOpenMK.value = true
+ } else {
+ message.error('麦克风开启失败')
+ }
+ } else {
+ message.error('未检测到音频输入设备')
+ }
+ } catch (error) {
+ message.error('麦克风访问被拒绝或不可用,请检查麦克风权限')
+ }
+ } else {
+ // 调用麦克风开启接口
+ const { data: res } = await stopDeviceMKApi({
+ token: deviceToken.value,
+ puid: deviceInfo.value?.puId,
+ idx: 0,
+ })
+
+ if (res.code == 200) {
+ message.success('麦克风已关闭')
+ isOpenMK.value = false
+ } else {
+ message.error('麦克风关闭失败')
+ }
+ }
+}
+
// 操控机器人
const handleChangeRobot = debounce(async (type) => {
const isInspection = await handleInspection()