diff --git a/api/100J/HBY100-J.js b/api/100J/HBY100-J.js
index 7a3ca1d..2666c89 100644
--- a/api/100J/HBY100-J.js
+++ b/api/100J/HBY100-J.js
@@ -24,10 +24,68 @@ export function deviceDeleteAudioFile(params) {
})
}
+// 更新语音,使用语音
+export function deviceUpdateVoice(data) {
+ return request({
+ url: `/app/hby100j/device/updateVoice`,
+ method: 'post',
+ data:data
+ })
+}
// 100J信息
export function deviceDetail(id) {
return request({
- url: `/app/hby100/device/${id}`,
+ url: `/app/hby100j/device/${id}`,
method: 'get',
})
+}
+// 爆闪模式
+export function deviceStrobeMode(data) {
+ return request({
+ url: `/app/hby100j/device/strobeMode`,
+ method: 'post',
+ data:data
+ })
+}
+
+// 强制报警
+export function deviceForceAlarmActivation(data) {
+ return request({
+ url: `/app/hby100j/device/forceAlarmActivation`,
+ method: 'post',
+ data:data
+ })
+}
+// 爆闪频率
+export function deviceStrobeFrequency(data) {
+ return request({
+ url: `/app/hby100j/device/strobeFrequency`,
+ method: 'post',
+ data:data
+ })
+}
+// 灯光调节亮度
+export function deviceLightAdjustment(data) {
+ return request({
+ url: `/app/hby100j/device/lightAdjustment`,
+ method: 'post',
+ data:data
+ })
+}
+
+// 调节音量
+export function deviceUpdateVolume(data) {
+ return request({
+ url: `/app/hby100j/device/updateVolume`,
+ method: 'post',
+ data:data
+ })
+}
+// 语音播放
+export function deviceVoiceBroadcast(data) {
+ return request({
+ url: `/app/hby100j/device/voiceBroadcast`,
+ method: 'post',
+ data:data
+ })
}
\ No newline at end of file
diff --git a/config/index.js b/config/index.js
index d239f4a..31d9e3c 100644
--- a/config/index.js
+++ b/config/index.js
@@ -2,13 +2,13 @@
const config = {
// 开发环境
development: {
- BASE_URL: 'http://192.168.110.172:8000',//http://139.224.253.23:8000
+ BASE_URL: 'http://192.168.2.34:8000',//http://139.224.253.23:8000
API_PREFIX: '',
// MQTT 配置
- MQTT_HOST: 'www.cnxhyc.com',
- MQTT_PORT: 8083,
+ MQTT_HOST: '47.120.79.150',
+ MQTT_PORT: 9083,
MQTT_USERNAME: 'admin',
- MQTT_PASSWORD: '#YtvpSfCNG'
+ MQTT_PASSWORD: '#YtvpSfCNG'
},
// 生产环境
production: {
diff --git a/pages/100J/HBY100-J.vue b/pages/100J/HBY100-J.vue
index 8731117..76fef92 100644
--- a/pages/100J/HBY100-J.vue
+++ b/pages/100J/HBY100-J.vue
@@ -22,7 +22,7 @@
- {{ deviceInfo.batteryRemainingTime || '0' }}分钟
+ {{ Math.floor((Number(deviceInfo.batteryRemainingTime)||0)/60) }}小时 {{ (Number(deviceInfo.batteryRemainingTime)||0)%60 }}分钟
续航时间
@@ -40,29 +40,29 @@
设备状态
- {{ deviceInfo.onlineStatus === 0 ? '离线' : deviceInfo.onlineStatus === 2 ? '故障' : '在线' }}
+ {{ deviceInfo.onlineStatus === 0 ? '离线' : deviceInfo.onlineStatus
+ === 2 ? '故障' : '在线' }}
-
- 定位信息
+
+ 定位信息
+
-
- {{ deviceInfo && deviceInfo.longitude ? Number(deviceInfo.longitude).toFixed(4) : '' }}
- {{ deviceInfo && deviceInfo.latitude ? Number(deviceInfo.latitude).toFixed(4) : '' }}
-
-
-
- {{ deviceInfo.address }}
-
+ {{ deviceInfo && deviceInfo.longitude ? Number(deviceInfo.longitude).toFixed(4) : '' }}
+ {{ deviceInfo && deviceInfo.latitude ? Number(deviceInfo.latitude).toFixed(4) : '' }}
-
+
+
+ {{ deviceInfo.address }}
+
+
+
- {{ formData.sta_SOSType === 1 ? '报警中' : '强制报警' }}
+ {{ deviceInfo.voiceStrobeAlarm === 1 ? '报警中' : '强制报警' }}
解除
@@ -80,7 +80,7 @@
@@ -97,19 +97,18 @@
-
+
-
-
播放语音
-
@@ -149,39 +148,33 @@
-
-
-
-
-
-
+
-
-
-
产品信息
@@ -202,7 +195,6 @@
-
import gbk from '@/utils/gbk.js'
+ import MqttClient from '@/utils/mqtt.js';
import {
showLoading,
hideLoading,
@@ -228,7 +221,13 @@
baseURL
} from '@/utils/request.js';
import {
- deviceDetail
+ deviceDetail,
+ deviceStrobeMode,
+ deviceForceAlarmActivation,
+ deviceStrobeFrequency,
+ deviceLightAdjustment,
+ deviceUpdateVolume,
+ deviceVoiceBroadcast
} from '@/api/100J/HBY100-J.js'
var these = null;
import Common from '@/utils/Common.js'
@@ -236,6 +235,7 @@
export default {
data() {
return {
+ mqttClient: null,
Status: {
isRightIconVisible: false,
navTitle: '',
@@ -305,11 +305,11 @@
macAddress: '',
bleStatu: false,
sta_address: '',
- sta_VoiceType: '',
- sta_VoiceVolume: 1,
+ sta_VoiceType: '0',
+ volume: 10,
sta_LightType: '',
- sta_LightFreq: 0.5,
- sta_LightDimmer: 10,
+ strobeFrequency: 0.5,
+ lightBrightness: 10,
sta_system: '',
warnTime: 0,
sta_SOSType: 0
@@ -321,8 +321,8 @@
name: '消防',
show: true
},
- "2": {
- key: "2",
+ "0": {
+ key: "0",
name: '公安',
show: true
},
@@ -336,8 +336,8 @@
name: '市政',
show: true
},
- "5": {
- key: "5",
+ "2": {
+ key: "2",
name: '应急',
show: true
},
@@ -346,60 +346,60 @@
name: '医疗',
show: true
},
- "7": {
- key: "7",
+ "5": {
+ key: "5",
name: '铁道',
show: true
},
- "8": {
- key: "8",
+ "7": {
+ key: "7",
name: 'app语音',
show: false
},
- "0": {
- key: "0",
+ "-1": {
+ key: "-1",
name: '关闭',
show: false
}
},
sta_LightType: [{
- key: "1",
- name: '红蓝',
- show: true
- },
- {
- key: "2",
- name: '红闪',
- show: true
- },
- {
- key: "3",
- name: '黄闪',
- show: true
- },
- {
- key: "4",
- name: '蓝闪',
- show: true
- },
- {
- key: "5",
- name: '红流水',
- show: true
- },
- {
key: "6",
- name: '黄流水',
- show: true
- },
- {
- key: "7",
- name: '蓝流水',
+ name: '红蓝交替',
show: true
},
{
key: "0",
+ name: '红闪',
+ show: true
+ },
+ {
+ key: "2",
+ name: '黄闪',
+ show: true
+ },
+ {
+ key: "1",
+ name: '蓝闪',
+ show: true
+ },
+ {
+ key: "3",
+ name: '红色顺时针',
+ show: true
+ },
+ {
+ key: "4",
+ name: '黄色顺时针',
+ show: true
+ },
+ {
+ key: "5",
+ name: '红蓝顺时针',
+ show: true
+ },
+ {
+ key: "-1",
name: '关闭',
show: false
}
@@ -452,6 +452,7 @@
these.Status.navTitle = data.data.deviceName;
these.Status.apiType = data.apiType;
these.Status.isRightIconVisible = these.Status.apiType === 'listA';
+
if (data.apiType !== 'listA') {
Common.getdeviceShareId(data.data.id).then(res => {
if (res.code == 200) {
@@ -462,9 +463,24 @@
});
}
+ this.mqttClient = new MqttClient();
+ // this.mqttClient.connect(() => {
+ // // 订阅来自设备的状态更新
+ // const statusTopic = `status/894078/HBY100/${data.data.deviceImei}`;
+ // this.mqttClient.subscribe(statusTopic, (payload) => {
+ // try {
+ // // 解析MQTT返回的payload
+ // const payloadObj = typeof payload === 'string' ? JSON.parse(
+ // payload) : payload;
+ // } catch (e) {
+
+ // }
+ // })
+ // })
console.log(data, 'datatatatat');
these.fetchDeviceDetail(data.data.id)
});
+ this.createThrottledFunctions();
},
onHide: function() {
@@ -476,12 +492,36 @@
computed: {
},
+
methods: {
+ createThrottledFunctions() {
+ // 创建节流函数
+ this.throttledBrightnessChange = this.throttle(this.handleBrightnessChange, 500);
+ this.throttledFreqChange = this.throttle(this.handleFreqChange, 500);
+ this.throttledVolumeChange = this.throttle(this.handleVolumeChange, 500);
+ },
// 获取设备详情(普通详情)
fetchDeviceDetail(id) {
deviceDetail(id).then((res) => {
if (res.code == 200) {
- this.deviceInfo = res.data
+ const validData = Object.fromEntries(
+ Object.entries(res.data).filter(([key, value]) => {
+ // 过滤规则:值为 null/undefined/0 的字段都不参与合并
+ return value !== null && value !== undefined && value !== 0;
+ })
+ );
+ Object.assign(this.formData, validData);
+ this.deviceInfo = res.data;
+ // 0 红色爆闪,1 蓝色爆闪,2 黄色爆闪,3,红色顺时针旋转爆闪,4黄色顺时针旋转爆闪,5,红蓝顺时针旋转爆闪,6 红蓝交替爆闪
+ this.formData.sta_LightType = (res.data.strobeMode ?? 0) + ''
+ // 0爆闪关闭, 1爆闪开启
+ const strobeEnable = res.data.strobeEnable ?? 0;
+ this.formData.sta_LightType = strobeEnable === 1 ? 1 : -1;
+ if (res.data.alarmMode == 7) {
+ this.formData.sta_VoiceType = res.data.voiceStrobeAlarm ?? 0;
+ } else {
+ this.formData.sta_VoiceType = res.data.alarmMode + ''
+ }
}
})
},
@@ -502,9 +542,9 @@
},
success: (res) => {
let json = {
- persissonType: '670'
+ persissonType: '100J'
};
-
+ Object.assign(json, this.deviceInfo);
res.eventChannel.emit('share', {
data: json
});
@@ -513,21 +553,11 @@
},
// 语音管理
audioManager(item) {
+ this.formData.sta_VoiceType = -1
if (this.Status.apiType !== 'listA') {}
uni.navigateTo({
url: '/pages/100J/audioManager/AudioList',
- events: {
- audioApply: function(id) {
- //应用某个语音时,将数据发送给设备
- console.log("准备发送数据", id);
- showLoading(these, {
- text: '准备发送数据'
- });
- these.audioData.hexs = uni.getStorageSync(Common.pcmStorageKey + "_" + id);
- console.log("hexs.length=", these.audioData.hexs.length)
- these.HoldYouHand();
- }
- },
+ events: {},
success: (res) => {
// 页面跳转成功后的回调函数
res.eventChannel.emit('deviceData', {
@@ -538,18 +568,154 @@
},
//频率
onFreqChanging(e) {
- this.formData.sta_LightFreq = e.detail.value;
+ this.formData.strobeFrequency = e.detail.value;
+ this.throttledFreqChange(e.detail.value);
},
//音量
onVolumeChanging(e) {
- this.formData.sta_VoiceVolume = e.detail.value;
+ this.formData.volume = e.detail.value;
+ this.throttledVolumeChange(e.detail.value);
},
+
// 亮度调节
onBrightnessChanging(e) {
- this.formData.sta_LightDimmer = e.detail.value;
+ this.formData.lightBrightness = e.detail.value;
+ this.throttledBrightnessChange(e.detail.value);
},
+ // 亮度调节
+ handleBrightnessChange(brightnessValue) {
+ let data = {
+ deviceId: this.deviceInfo.deviceId,
+ brightness: brightnessValue
+ };
+ console.log('发送亮度调节请求:', data);
+ deviceLightAdjustment(data).then((res) => {
+ if (res.code === 200) {
+ console.log('亮度调节成功');
+ uni.showToast({
+ title: res.msg,
+ icon: 'none',
+ duration: 1000
+ });
+ } else {
+ uni.showToast({
+ title: res.msg || '调节失败',
+ icon: 'none',
+ duration: 1000
+ });
+ }
+ }).catch((err) => {
+
+ });
+ },
+ // 频率调节
+ handleFreqChange(freqValue) {
+ let data = {
+ deviceId: this.deviceInfo.deviceId,
+ frequency: freqValue
+ };
+
+ deviceStrobeFrequency(data).then((res) => {
+ if (res.code === 200) {
+ uni.showToast({
+ title: res.msg,
+ icon: 'none',
+ duration: 1000
+ });
+ } else {
+ uni.showToast({
+ title: res.msg || '调节失败',
+ icon: 'none',
+ duration: 1000
+ });
+ }
+ }).catch((err) => {});
+ },
+ // 音量调节处理函数
+ handleVolumeChange(volumeValue) {
+ let data = {
+ deviceId: this.deviceInfo.deviceId,
+ volume: volumeValue
+ };
+ deviceUpdateVolume(data).then((res) => {
+ if (res.code === 200) {
+ uni.showToast({
+ title: res.msg,
+ icon: 'none',
+ duration: 1000
+ });
+ } else {
+ uni.showToast({
+ title: res.msg,
+ icon: 'none',
+ duration: 1000
+ });
+ }
+ }).catch((err) => {});
+ },
+ // 节流函数
+ throttle(func, delay = 500) {
+ let timer = null;
+ let lastArgs = null;
+ let lastThis = null;
+ return function(...args) {
+ lastArgs = args;
+ lastThis = this;
+ if (!timer) {
+ timer = setTimeout(() => {
+ timer = null;
+ func.apply(lastThis, lastArgs);
+ }, delay);
+ }
+ };
+
+ },
+ // *******定位******
+ gpsPosition(item) {
+ // 添加调试日志
+ uni.navigateTo({
+ url: '/pages/common/map/index',
+ events: {
+ ack: function(data) {}
+ },
+ success: (res) => {
+ res.eventChannel.emit('Map', {
+ data: item
+ });
+ }
+ })
+ },
+ // 警示灯开关闭
lightTypeSet(item, index) {
- this.formData.sta_LightType = item.key;
+ let val = item.key;
+ // 切换选中/取消选中逻辑
+ if (this.formData.sta_LightType === val) {
+ val = '-1';
+ }
+ this.formData.sta_LightType = val;
+ let data = {
+ deviceId: this.deviceInfo.deviceId,
+ // 开启/关闭:选中模式时传1,关闭时传0
+ enable: val === '-1' ? 0 : 1,
+ // 0 红色爆闪,1 蓝色爆闪,2 黄色爆闪,3,红色顺时针旋转爆闪,4黄色顺时针旋转爆闪,5,红蓝顺时针旋转爆闪,6 红蓝交替爆闪
+ mode: item.key
+ };
+ deviceStrobeMode(data).then((res) => {
+ if (res.code == 200) {
+ const tipText = data.enable === 1 ? '开启成功' : '关闭成功';
+ uni.showToast({
+ title: tipText,
+ icon: 'none',
+ duration: 1000
+ });
+ } else {
+ uni.showToast({
+ title: res.msg,
+ icon: 'none',
+ duration: 1000
+ });
+ }
+ })
},
// 报警模式
setUsrToggle() {
@@ -557,22 +723,48 @@
},
// 播放语音
openVolume(item, index) {
- if (item) {
- console.log(item.key, 'keyyy');
- this.formData.sta_VoiceType = item.key;
- } else if (index === '8') { // 点击“播放语音”的场景
- this.formData.sta_VoiceType = '8';
-
+ if (!item) {
+ item = this.dic.sta_VoiceType[index];
}
+ let val = item.key;
+ if (this.formData.sta_VoiceType === val) {
+ val = '-1';
+ }
+ this.formData.sta_VoiceType = val;
+ console.log(this.formData.sta_VoiceType, 'this.formData.sta_VoiceType')
+ // 模式类型为7时才去判断
+ if (val === '7' || val === '-1') {
+ let data = {
+ deviceId: this.deviceInfo.deviceId,
+ voiceBroadcast: Number(this.formData.sta_VoiceType) === -1 ? 0 : 1
+ }
+ deviceVoiceBroadcast(data).then((res) => {
+ if (res.code == 200) {
+ uni.showToast({
+ title: res.msg,
+ icon: 'none'
+ });
+ } else {
+ uni.showToast({
+ title: res.msg,
+ icon: 'none'
+ });
+ }
+ })
+ }
+
},
// 报警模式
sosSetting(item) {
+ console.log(this.deviceInfo, '44444');
+ console.log(item, 'tent');
const isClose = item === 0;
if (!this.Status) this.Status = {};
if (!this.Status.Pop) this.Status.Pop = {
showPop: false
};
- //弹窗配置
+
+ // 弹窗配置
this.Status.Pop = {
...this.Status.Pop,
showPop: true,
@@ -583,10 +775,31 @@
showCancel: true,
buttonCancelText: '取消',
okCallback: () => {
- this.formData.sta_SOSType = item;
- uni.showToast({
- title: isClose ? '声光报警已解除' : '强制报警已开启',
- icon: 'none'
+ console.log(this.formData.sta_SOSType, 'this.formData.sta_SOSType');
+ this.formData.sta_SOSType = isClose ? 0 : 1;
+ const data = {
+ deviceIds: [this.deviceInfo.deviceId],
+ // 声光报警开关:关闭传0,开启传1
+ voiceStrobeAlarm: isClose ? 0 : 1,
+ mode: this.formData.sta_VoiceType
+ };
+ deviceForceAlarmActivation(data).then((res) => {
+ if (res.code === 200) {
+ uni.showToast({
+ title: isClose ? '声光报警已解除' : '强制报警已开启',
+ icon: 'none'
+ });
+ } else {
+ uni.showToast({
+ title: res.msg,
+ icon: 'none'
+ });
+ }
+ }).catch((err) => {
+ uni.showToast({
+ title: '请求失败,请重试',
+ icon: 'none'
+ });
});
}
};
@@ -597,7 +810,6 @@
bleStateBreak() {},
bleStateRecovry() {},
previewImg(img) {},
-
bleValueNotify: function(receive, device, path, recArr) { //订阅消息
if (receive.deviceId !== this.formData.deviceId) {
return;
@@ -792,14 +1004,14 @@
border-radius: 16rpx;
background: rgba(26, 26, 26, 1);
box-sizing: border-box;
- padding: 14rpx 0rpx;
+ padding: 15rpx 30rpx;
}
.eqinfo .item {
width: 100%;
height: 60rpx;
line-height: 60rpx;
- padding: 0rpx 28rpx;
+ /* padding: 0rpx 28rpx; */
box-sizing: border-box;
display: flex;
flex-direction: row;
@@ -824,11 +1036,18 @@
font-family: PingFang SC;
font-size: 28rpx;
font-weight: 400;
-
letter-spacing: 0.07px;
text-align: left;
}
+ .eqinfo .info-value {
+ /* margin-top: 30rpx; */
+ }
+
+ /* .eqinfo .status-running {
+ color: rgba(174, 214, 0, 1);
+ } */
+
.lamp {
margin-top: 24rpx;
}
@@ -1530,4 +1749,32 @@
width: 100%;
font-size: 32rpx;
}
+ .info-row {
+ display: flex;
+ justify-content: space-between;
+ }
+
+ .info-label {
+ font-size: 28rpx;
+ color: rgba(255, 255, 255, 0.87);
+ white-space: nowrap;
+ }
+
+ .info-value {
+ font-size: 28rpx;
+ color: rgba(255, 255, 255, 0.6);
+ }
+
+ .status-running {
+ /* color: rgba(255, 255, 255, 0.6); */
+ text-align: end;
+ }
+
+ .locationGPS {
+ width: 88%;
+ text-align: end;
+ float: right;
+ line-height: 45rpx;
+ font-size: 28rpx;
+ }
\ No newline at end of file
diff --git a/pages/100J/audioManager/AudioList.vue b/pages/100J/audioManager/AudioList.vue
index 5ebbf95..0ddca29 100644
--- a/pages/100J/audioManager/AudioList.vue
+++ b/pages/100J/audioManager/AudioList.vue
@@ -4,31 +4,33 @@
:down="downOption" :fixed="false" :style="{ height: mescrollHeight + 'px' }">
-
-
+
-
+
-
+
{{ item.fileNameExt }}
- {{item.createTime || Common.DateFormat(new Date(), "yyyy年MM月dd日")}}
- {{item.duration}}秒
- {{ item.createTime || Common.DateFormat(new Date(),
+ "yyyy年MM月dd日") }}
+ {{ item.duration }}秒
+
+ @click.stop="play(item, index)">
-
- {{item.isApply ?'使用中':'使用'}}
+
+ {{ item.useStatus == 1 ? '使用中' : '使用' }}
@@ -40,7 +42,7 @@