Compare commits
29 Commits
main
...
eceaa90010
| Author | SHA1 | Date | |
|---|---|---|---|
| eceaa90010 | |||
| c64b140754 | |||
| fe49ff631d | |||
| d5269b02d0 | |||
| 56e85e5dba | |||
| d134c67a16 | |||
| 37f5047a46 | |||
| 6839e9fd40 | |||
| b6ce2dbe25 | |||
| 35d6574754 | |||
| dbc0ab7d0f | |||
| e0cef19da1 | |||
| ab19f14f05 | |||
| 4c6704ba8a | |||
| 553e24886f | |||
| b99ac04c88 | |||
| e7b40dbed6 | |||
| a18b2b81e8 | |||
| 6715384b0a | |||
| 4e518e7340 | |||
| 1598065457 | |||
| 4eb118b42c | |||
| 5613f0fb8a | |||
| bdc9ad8fcd | |||
| 89817525ab | |||
| 7cfbfdfce3 | |||
| a7e1809fc8 | |||
| 7158293d8d | |||
| ded31de046 |
@ -7,7 +7,7 @@
|
||||
},
|
||||
{
|
||||
"customPlaygroundType" : "local",
|
||||
"playground" : "standard",
|
||||
"playground" : "custom",
|
||||
"type" : "uni-app:app-android"
|
||||
},
|
||||
{
|
||||
|
||||
5
App.vue
5
App.vue
@ -3,7 +3,7 @@
|
||||
import upgrade from '@/utils/update.js';
|
||||
|
||||
// 延迟断开蓝牙:选择文件/录音等会触发 onHide,8 秒内返回则不断开
|
||||
const BLE_DISCONNECT_DELAY = 8000;
|
||||
const BLE_DISCONNECT_DELAY = 30000;
|
||||
let _bleDisconnectTimer = null;
|
||||
|
||||
export default {
|
||||
@ -74,6 +74,9 @@
|
||||
initOS();
|
||||
}
|
||||
|
||||
|
||||
let system=uni.getSystemInfoSync();
|
||||
console.log("system=",system);
|
||||
// #endif
|
||||
},
|
||||
onShow: function() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -124,9 +124,10 @@
|
||||
*/
|
||||
async drawAndGetPixels() {
|
||||
// 第一次调用时先预热画布(解决APP重新打开后第一次获取数据不完整的问题)
|
||||
await this.warmupCanvas();
|
||||
// await this.warmupCanvas();
|
||||
|
||||
let convertCharToMatrix=function(imageData) {
|
||||
debugger;
|
||||
// console.log("imgData=",imageData)
|
||||
let matrix = [];
|
||||
|
||||
@ -166,6 +167,7 @@
|
||||
}
|
||||
|
||||
let drawTxt=async (textLine)=> {
|
||||
debugger;
|
||||
let result = {};
|
||||
let ctx = this.ctx;
|
||||
|
||||
@ -226,7 +228,7 @@
|
||||
let arr = [];
|
||||
// 循环处理每行文本
|
||||
for (let i = 0; i < this.validTxts.length; i++) {
|
||||
|
||||
debugger;
|
||||
let linePixls = [];
|
||||
let item = this.validTxts[i];
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
const config = {
|
||||
// 开发环境
|
||||
development: {
|
||||
BASE_URL: 'http://192.168.110.57: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: '47.120.79.150',
|
||||
|
||||
@ -7,14 +7,14 @@
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.sta_PowerPercent}}%</view>
|
||||
<view class="smallTxt">电量</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.sta_charge?dic.sta_charge[formData.sta_charge+'']:"未充电" }}
|
||||
</view>
|
||||
|
||||
@ -28,14 +28,14 @@
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.sta_battery}}%</view>
|
||||
<view class="smallTxt">电量</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.sta_system?dic.sta_system[formData.sta_system]:"" }}</view>
|
||||
<view class="smallTxt">设备状态</view>
|
||||
@ -475,9 +475,9 @@
|
||||
|
||||
sta_system: {
|
||||
"0": '关机',
|
||||
"1": '仅充电',
|
||||
"2": '开机未充电',
|
||||
"3": '开机且充电',
|
||||
"1": '充电中',//仅充电
|
||||
"2": '未充电',//开机未充电
|
||||
"3": '充电中',//开机且充电
|
||||
"": ""
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt" :style="{ color: deviceInfo.batteryPercentage < 20 ? '#FF0000' : '' }">
|
||||
{{ deviceInfo.batteryPercentage }}%
|
||||
@ -20,7 +20,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">
|
||||
{{ Math.floor((Number(deviceInfo.batteryRemainingTime) || 0) / 60) }}小时
|
||||
@ -48,7 +48,7 @@
|
||||
<text class="lbl">蓝牙名称</text>
|
||||
<text class="value valueFont">{{device.bluetoothName}}</text>
|
||||
</view>
|
||||
<view class="item" @click.top="bleStatuToggle">
|
||||
<view class="item" @click.stop="bleStatuToggle">
|
||||
<text class="lbl">蓝牙状态</text>
|
||||
<text class="value"
|
||||
:class="(!formData.bleStatu || formData.bleStatu==='err')?'red':'green'">{{getbleStatu}}</text>
|
||||
@ -64,7 +64,7 @@
|
||||
<view class="info-value status-running">
|
||||
{{ deviceInfo && deviceInfo.longitude ? Number(deviceInfo.longitude).toFixed(4) : '' }}
|
||||
{{ deviceInfo && deviceInfo.latitude ? Number(deviceInfo.latitude).toFixed(4) : '' }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="info-value status-running locationGPS">
|
||||
<uni-icons type="location" size="17" color="rgba(255, 255, 255, 0.8)"
|
||||
style="vertical-align: bottom;" />
|
||||
@ -173,10 +173,10 @@
|
||||
<view class="line"></view>
|
||||
<view class="header paddingTop0">
|
||||
<text class="sliderTxt">频率</text>
|
||||
<text class="sliderVal">{{ formData.strobeFrequency }}HZ</text>
|
||||
<text class="sliderVal">{{ strobeFrequencySlider }}HZ</text>
|
||||
</view>
|
||||
<view class="slider-container">
|
||||
<slider min="1" max="10" step="1" :disabled="false" :value="formData.strobeFrequency"
|
||||
<slider min="1" max="10" step="1" :disabled="false" :value="strobeFrequencySlider"
|
||||
activeColor="#bbe600" backgroundColor="#686767" block-size="20" block-color="#ffffffde"
|
||||
@change="onFreqChanging" @changing="onFreqChanging" class="custom-slider" />
|
||||
</view>
|
||||
@ -251,7 +251,6 @@
|
||||
} from '@/api/100J/HBY100-J.js'
|
||||
import BleHelper from '@/utils/BleHelper.js';
|
||||
var bleTool = BleHelper.getBleTool();
|
||||
var these = null;
|
||||
import Common from '@/utils/Common.js'
|
||||
const pagePath = "/pages/100/HBY100";
|
||||
export default {
|
||||
@ -332,7 +331,7 @@
|
||||
sta_VoiceType: '0',
|
||||
volume: 10,
|
||||
sta_LightType: '',
|
||||
strobeFrequency: 0.5,
|
||||
strobeFrequency: 1,
|
||||
lightBrightness: 10,
|
||||
sta_system: '',
|
||||
warnTime: 0,
|
||||
@ -466,20 +465,45 @@
|
||||
deviceInfo: {},
|
||||
}
|
||||
},
|
||||
onUnload() {},
|
||||
onLoad: function() {
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
var these = this;
|
||||
|
||||
this.$watch("deviceInfo.batteryPercentage", (newVal, oldVal) => {
|
||||
if (newVal <= 20) {
|
||||
// 低电量:语音上传/蓝牙分包时电量字段易抖动,防抖 + 上传中不弹,避免「发送中频繁低电量」误报
|
||||
this._lastBatteryLowToastPct = null;
|
||||
this._batteryLowDebounceTimer = null;
|
||||
this.$watch("deviceInfo.batteryPercentage", () => {
|
||||
if (bleTool.isVoiceUploading && bleTool.isVoiceUploading()) {
|
||||
if (this._batteryLowDebounceTimer) {
|
||||
clearTimeout(this._batteryLowDebounceTimer);
|
||||
this._batteryLowDebounceTimer = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
const n = Math.round(Number(this.deviceInfo.batteryPercentage));
|
||||
if (!Number.isFinite(n)) return;
|
||||
if (n > 20) {
|
||||
this._lastBatteryLowToastPct = null;
|
||||
if (this._batteryLowDebounceTimer) {
|
||||
clearTimeout(this._batteryLowDebounceTimer);
|
||||
this._batteryLowDebounceTimer = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (this._batteryLowDebounceTimer) clearTimeout(this._batteryLowDebounceTimer);
|
||||
this._batteryLowDebounceTimer = setTimeout(() => {
|
||||
this._batteryLowDebounceTimer = null;
|
||||
if (bleTool.isVoiceUploading && bleTool.isVoiceUploading()) return;
|
||||
const cur = Math.round(Number(this.deviceInfo.batteryPercentage));
|
||||
if (!Number.isFinite(cur) || cur > 20) return;
|
||||
if (this._lastBatteryLowToastPct === cur) return;
|
||||
this._lastBatteryLowToastPct = cur;
|
||||
uni.showToast({
|
||||
title: '设备电量低',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
|
||||
}, 800);
|
||||
});
|
||||
eventChannel.on('detailData', function(data) {
|
||||
var device = data.data;
|
||||
@ -488,17 +512,17 @@
|
||||
these.Status.apiType = data.apiType;
|
||||
these.Status.isRightIconVisible = these.Status.apiType === 'listA';
|
||||
|
||||
this.mqttClient = new MqttClient();
|
||||
these.mqttClient = new MqttClient();
|
||||
|
||||
this.mqttClient.connect(() => {
|
||||
these.mqttClient.connect(() => {
|
||||
// 订阅来自设备的状态更新
|
||||
const statusTopic = `status/894078/HBY100/${data.data.deviceImei}`;
|
||||
this.mqttClient.subscribe(statusTopic, (payload) => {
|
||||
these.mqttClient.subscribe(statusTopic, (payload) => {
|
||||
try {
|
||||
// 解析MQTT返回的payload
|
||||
const payloadObj = typeof payload === 'string' ? JSON.parse(
|
||||
payload) : payload;
|
||||
console.log(payloadObj, '这是我的数据类型么');
|
||||
// console.log(payloadObj, '这是我的数据类型么');
|
||||
const data = payloadObj.data ?? {};
|
||||
const funcType = payloadObj.funcType ?? ''; // 从顶层获取funcType
|
||||
const {
|
||||
@ -528,8 +552,9 @@
|
||||
// 设备按键, app同步
|
||||
} else if (funcType == '14') {
|
||||
// 调节亮度,音量,频率相关字段
|
||||
these.formData.strobeFrequency = led_strobe.frequency ||
|
||||
0.5; //频率
|
||||
these.formData.strobeFrequency = these.normalizeStrobeFreq(
|
||||
led_strobe.frequency != null ? led_strobe.frequency : 1
|
||||
);
|
||||
these.formData.volume = volume || 10; //音量
|
||||
these.formData.lightBrightness = brightness.red ||
|
||||
10; //亮度值
|
||||
@ -546,13 +571,12 @@
|
||||
// 报警模式,选中,首次上报值,或者切换设备按键上报值
|
||||
const enable = siren_alarm.enable ?? 0; // 报警开关:1=开,0=关
|
||||
const mode = siren_alarm.mode ?? 0; // 模式:0/1/2/3/4/5/6
|
||||
if (these.formData.sta_VoiceType != 7) {
|
||||
if (String(these.formData.sta_VoiceType) !== '7') {
|
||||
if (enable === 1) {
|
||||
// 开启状态
|
||||
these.formData.sta_VoiceType = mode + '';
|
||||
} else {
|
||||
// 关闭状态:赋值-1,表示关闭
|
||||
these.formData.sta_VoiceType = mode + '';
|
||||
const m = Number(mode);
|
||||
these.formData.sta_VoiceType = m === 7 ? '-1' : m + '';
|
||||
}
|
||||
} else {
|
||||
// 播放语音,上报消息
|
||||
@ -576,18 +600,15 @@
|
||||
}
|
||||
// 强制报警按键解除报警状态,app同步
|
||||
} else if (funcType === '12') {
|
||||
const enable_alarm = data.voice_strobe_alarm ??
|
||||
0; // 报警开关:1=开,0=关
|
||||
const mode_alarm = data.mode ?? 0; // 模式:0/1/2/3/4/5/6
|
||||
const enable_alarm = data.voice_strobe_alarm ?? 0;
|
||||
const mode_alarm = data.mode ?? 0;
|
||||
if (enable_alarm === 1) {
|
||||
// 开启状
|
||||
these.deviceInfo.voiceStrobeAlarm = 1;
|
||||
these.formData.sta_VoiceType = mode_alarm + ''
|
||||
these.formData.sta_VoiceType = mode_alarm + '';
|
||||
} else {
|
||||
// 关闭状态:赋值-1,表示关闭
|
||||
these.deviceInfo.voiceStrobeAlarm = -1;
|
||||
// 模式还是选中的,模式,解除也是
|
||||
these.formData.sta_VoiceType = mode_alarm + ''
|
||||
const m = Number(mode_alarm);
|
||||
these.formData.sta_VoiceType = m === 7 ? '-1' : m + '';
|
||||
}
|
||||
}
|
||||
// 警示灯模式选中切换
|
||||
@ -603,7 +624,7 @@
|
||||
}
|
||||
}
|
||||
// 报警模式相关字段
|
||||
console.log('formData赋值完成:', these.formData);
|
||||
// console.log('formData赋值完成:', these.formData);
|
||||
} catch (e) {
|
||||
// 捕获异常并打印,方便排查问题(不要空catch)
|
||||
console.log('解析MQTT payload失败:', e);
|
||||
@ -615,8 +636,8 @@
|
||||
if (these.Status.apiType === 'listA') {
|
||||
these.fetchDeviceDetail(data.data.id)
|
||||
} else {
|
||||
this.activePermissions = data.data.permission ? data.data.permission.split(',') : [];
|
||||
console.log(this.activePermissions, 'this.activePermissions');
|
||||
these.activePermissions = data.data.permission ? data.data.permission.split(',') : [];
|
||||
console.log(these.activePermissions, 'activePermissions');
|
||||
these.fetchDeviceDetail(data.data.deviceId)
|
||||
}
|
||||
// 尝试连接蓝牙:需先扫描获取 BLE deviceId,不能直接用 MAC;延迟 500ms 确保蓝牙适配器就绪
|
||||
@ -628,12 +649,20 @@
|
||||
});
|
||||
this.createThrottledFunctions();
|
||||
|
||||
// 注册蓝牙相关事件
|
||||
// 系统蓝牙开关:与 BleHelper 状态对齐(测试项「关蓝牙后状态空白」)
|
||||
this._hby100jBleAdapterHandler = () => {
|
||||
this.$nextTick(() => this.sync100JBleUiFromHelper && this.sync100JBleUiFromHelper());
|
||||
};
|
||||
if (typeof uni.onBluetoothAdapterStateChange === 'function') {
|
||||
uni.onBluetoothAdapterStateChange(this._hby100jBleAdapterHandler);
|
||||
}
|
||||
|
||||
// 注册蓝牙相关事件(必须 bind(this),否则 BleHelper 直接调用回调时 this 丢失,蓝牙状态不更新)
|
||||
bleTool.addReceiveCallback(this.bleValueNotify.bind(this), "HBY100J");
|
||||
bleTool.addDisposeCallback(this.bleStateBreak, "HBY100J");
|
||||
bleTool.addRecoveryCallback(this.bleStateRecovry, "HBY100J");
|
||||
bleTool.addStateBreakCallback(this.bleStateBreak, "HBY100J");
|
||||
bleTool.addStateRecoveryCallback(this.bleStateRecovry, "HBY100J");
|
||||
bleTool.addDisposeCallback(this.bleStateBreak.bind(this), "HBY100J");
|
||||
bleTool.addRecoveryCallback(this.bleStateRecovry.bind(this), "HBY100J");
|
||||
bleTool.addStateBreakCallback(this.bleStateBreak.bind(this), "HBY100J");
|
||||
bleTool.addStateRecoveryCallback(this.bleStateRecovry.bind(this), "HBY100J");
|
||||
|
||||
|
||||
|
||||
@ -642,6 +671,14 @@
|
||||
this.Status.pageHide = true;
|
||||
},
|
||||
onUnload() {
|
||||
if (this._batteryLowDebounceTimer) {
|
||||
clearTimeout(this._batteryLowDebounceTimer);
|
||||
this._batteryLowDebounceTimer = null;
|
||||
}
|
||||
if (this._hby100jBleAdapterHandler && typeof uni.offBluetoothAdapterStateChange === 'function') {
|
||||
uni.offBluetoothAdapterStateChange(this._hby100jBleAdapterHandler);
|
||||
this._hby100jBleAdapterHandler = null;
|
||||
}
|
||||
// 移除蓝牙事件监听
|
||||
bleTool.removeReceiveCallback("HBY100J");
|
||||
bleTool.removeDisposeCallback("HBY100J");
|
||||
@ -653,8 +690,14 @@
|
||||
},
|
||||
onShow() {
|
||||
this.Status.pageHide = false;
|
||||
// 从系统蓝牙开关/后台返回时,与 BleHelper.LinkedList 对齐,避免「蓝牙状态空白/不刷新」
|
||||
this.$nextTick(() => this.sync100JBleUiFromHelper());
|
||||
},
|
||||
computed: {
|
||||
/** 与 slider min/max(1~10) 对齐;离线未拉到详情时避免 0.5 等非法值导致滑块渲染飞出 */
|
||||
strobeFrequencySlider() {
|
||||
return this.normalizeStrobeFreq(this.formData.strobeFrequency);
|
||||
},
|
||||
getbleStatu() {
|
||||
if (this.formData.bleStatu === true) {
|
||||
return '已连接';
|
||||
@ -673,29 +716,76 @@
|
||||
},
|
||||
|
||||
methods: {
|
||||
/** 警示灯频率 UI:slider 为 1~10,与协议 0~12 取交集 */
|
||||
normalizeStrobeFreq(v) {
|
||||
const n = Number(v);
|
||||
if (!Number.isFinite(n)) return 1;
|
||||
const r = Math.round(n);
|
||||
if (r < 1) return 1;
|
||||
if (r > 10) return 10;
|
||||
return r;
|
||||
},
|
||||
/** 与 BleHelper 实际连接状态对齐(系统关蓝牙再开、从后台回前台等) */
|
||||
sync100JBleUiFromHelper() {
|
||||
const mac = (this.device && this.device.deviceMac) || (this.deviceInfo && this.deviceInfo.deviceMac);
|
||||
if (!mac || !this.deviceInfo.deviceId) return;
|
||||
const macNorm = (m) => (m || '').replace(/:/g, '').toUpperCase();
|
||||
const targetMacNorm = macNorm(mac);
|
||||
const last6 = targetMacNorm.slice(-6);
|
||||
const item = bleTool.data.LinkedList.find((v) => {
|
||||
const m = macNorm(v.macAddress || '');
|
||||
return m === targetMacNorm || (m.length >= 6 && m.slice(-6) === last6);
|
||||
});
|
||||
if (!bleTool.data.available) {
|
||||
this.formData.bleStatu = false;
|
||||
updateBleStatus(false, '', this.deviceInfo.deviceId);
|
||||
return;
|
||||
}
|
||||
if (item && item.Linked) {
|
||||
this.formData.bleStatu = true;
|
||||
updateBleStatus(true, item.deviceId, this.deviceInfo.deviceId);
|
||||
return;
|
||||
}
|
||||
if (this.formData.bleStatu === true || this.formData.bleStatu === 'connecting') {
|
||||
this.formData.bleStatu = false;
|
||||
updateBleStatus(false, '', this.deviceInfo.deviceId);
|
||||
}
|
||||
},
|
||||
bleStatuToggle() {
|
||||
const mac = (this.device && this.device.deviceMac) || (this.deviceInfo && this.deviceInfo.deviceMac);
|
||||
if (!mac) return;
|
||||
const macNorm = (m) => (m || '').replace(/:/g, '').toUpperCase();
|
||||
const targetMacNorm = macNorm(mac);
|
||||
const last6 = targetMacNorm.slice(-6);
|
||||
let f = bleTool.data.LinkedList.find((v) => {
|
||||
return v.macAddress == this.device.deviceMac;
|
||||
const m = macNorm(v.macAddress || '');
|
||||
return m === targetMacNorm || (m.length >= 6 && m.slice(-6) === last6);
|
||||
});
|
||||
|
||||
if (!f) {
|
||||
this.tryConnect100JBle(this.device.deviceMac);
|
||||
this.tryConnect100JBle(mac);
|
||||
return;
|
||||
}
|
||||
if (this.formData.bleStatu === true) {
|
||||
this.formData.bleStatu = 'dicconnect';
|
||||
bleTool.disconnectDevice(f.deviceId).finally(r => {
|
||||
bleTool.disconnectDevice(f.deviceId).finally(() => {
|
||||
this.formData.bleStatu = false;
|
||||
if (this.deviceInfo && this.deviceInfo.deviceId) {
|
||||
updateBleStatus(false, '', this.deviceInfo.deviceId);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.formData.bleStatu === false || this.formData.bleStatu === 'err') {
|
||||
this.formData.bleStatu = 'connecting';
|
||||
bleTool.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
|
||||
these.formData.bleStatu = true;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
bleTool.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(() => {
|
||||
this.formData.bleStatu = true;
|
||||
this.bleStateRecovry({
|
||||
deviceId: f.deviceId
|
||||
});
|
||||
}).catch(() => {
|
||||
this.formData.bleStatu = 'err';
|
||||
});
|
||||
return;
|
||||
}
|
||||
@ -720,7 +810,9 @@
|
||||
})
|
||||
);
|
||||
Object.assign(this.formData, validData);
|
||||
that.formData.strobeFrequency = that.normalizeStrobeFreq(that.formData.strobeFrequency);
|
||||
that.deviceInfo = res.data;
|
||||
that.$nextTick(() => that.sync100JBleUiFromHelper && that.sync100JBleUiFromHelper());
|
||||
const strobeEnable = res.data.strobeEnable ?? 0; // 0=关闭,1=开启
|
||||
const strobeMode = res.data.strobeMode ?? 0; // 0=红闪、1=蓝闪、3=红色顺时针...
|
||||
if (strobeEnable === 1) {
|
||||
@ -730,10 +822,12 @@
|
||||
// 关闭状态
|
||||
that.formData.sta_LightType = '-1';
|
||||
}
|
||||
if (this.formData_VoiceType == 7) {
|
||||
this.formData.sta_VoiceType = res.data.voiceStrobeAlarm ?? 0;
|
||||
const alarmOnDetail = res.data.voiceStrobeAlarm === 1;
|
||||
const amDetail = res.data.alarmMode != null ? Number(res.data.alarmMode) : 0;
|
||||
if (alarmOnDetail) {
|
||||
this.formData.sta_VoiceType = amDetail + '';
|
||||
} else {
|
||||
this.formData.sta_VoiceType = res.data.alarmMode + ''
|
||||
this.formData.sta_VoiceType = amDetail === 7 ? '-1' : amDetail + '';
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -949,18 +1043,18 @@
|
||||
item = this.dic.sta_VoiceType[index];
|
||||
}
|
||||
let val = item.key;
|
||||
const prevVoiceType = this.formData.sta_VoiceType;
|
||||
if (this.formData.sta_VoiceType === val) {
|
||||
val = '-1';
|
||||
}
|
||||
this.formData.sta_VoiceType = val;
|
||||
// 模式类型为7时才去判断
|
||||
console.log(val, 'valllll');
|
||||
const isVoiceOperate = val === '7' || val === '-1'; // 标记是否是语音开启/关闭操作
|
||||
if (this.deviceInfo.voiceStrobeAlarm == 1) {
|
||||
// 如果强制报警已经开启了,那么切换下面的模式需要时,需要触发报警指令
|
||||
// 仅「播放语音」7 的开关走播报接口;-1 只有从 7 取消时才视为关播报,避免取消内置音色选中误调播报接口
|
||||
const isVoiceOperate = val === '7' || (val === '-1' && prevVoiceType === '7');
|
||||
if (this.deviceInfo.voiceStrobeAlarm === 1) {
|
||||
// 强制报警已开启:切换下方模式需带报警下发
|
||||
const data = {
|
||||
deviceIds: [this.deviceInfo.deviceId],
|
||||
// 声光报警开关开启传1
|
||||
voiceStrobeAlarm: 1,
|
||||
mode: this.formData.sta_VoiceType
|
||||
};
|
||||
@ -976,13 +1070,14 @@
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
} else if (isVoiceOperate) {
|
||||
console.log('我是谁');
|
||||
let data = {
|
||||
const data = {
|
||||
deviceId: this.deviceInfo.deviceId,
|
||||
voiceBroadcast: Number(this.formData.sta_VoiceType) === -1 ? 0 : 1
|
||||
}
|
||||
voiceBroadcast: Number(this.formData.sta_VoiceType) === -1 ? 0 : 1,
|
||||
mode: this.formData.sta_VoiceType,
|
||||
voiceStrobeAlarm: this.deviceInfo.voiceStrobeAlarm
|
||||
};
|
||||
deviceVoiceBroadcast(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
uni.showToast({
|
||||
@ -995,14 +1090,55 @@
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
uni.showToast({
|
||||
title: '下发失败,请检查蓝牙或网络',
|
||||
icon: 'none'
|
||||
});
|
||||
});
|
||||
} else if (prevVoiceType === '7' && val !== '7' && val !== '-1') {
|
||||
// 从「播放语音」切到其它内置音色:先关播报;报警未开启时不走 forceAlarm,仅 UI 预选音色
|
||||
const data = {
|
||||
deviceId: this.deviceInfo.deviceId,
|
||||
voiceBroadcast: 0,
|
||||
mode: val,
|
||||
voiceStrobeAlarm: this.deviceInfo.voiceStrobeAlarm
|
||||
};
|
||||
deviceVoiceBroadcast(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
uni.showToast({
|
||||
title: res.msg || '已切换',
|
||||
icon: 'none'
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg || '操作失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
}).catch(() => {
|
||||
uni.showToast({
|
||||
title: '下发失败,请检查蓝牙或网络',
|
||||
icon: 'none'
|
||||
});
|
||||
});
|
||||
}
|
||||
// 未开启强制报警时,在 0–6 内置音色间切换或取消选中:只改按钮选中,不下发
|
||||
},
|
||||
// 报警模式
|
||||
sosSetting(item) {
|
||||
console.log(this.deviceInfo, '44444');
|
||||
console.log(item, 'tent');
|
||||
const isClose = item === 0;
|
||||
// 与「已解除不再重复关报警」对称:已在报警中不再弹窗重复下发「开启」,未报警时不再重复「解除」
|
||||
if (!isClose && this.deviceInfo.voiceStrobeAlarm === 1) {
|
||||
uni.showToast({ title: '当前已在报警中', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (isClose && this.deviceInfo.voiceStrobeAlarm !== 1) {
|
||||
uni.showToast({ title: '当前未在报警中', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (!this.Status) this.Status = {};
|
||||
if (!this.Status.Pop) this.Status.Pop = {
|
||||
showPop: false
|
||||
@ -1019,20 +1155,21 @@
|
||||
showCancel: true,
|
||||
buttonCancelText: '取消',
|
||||
okCallback: () => {
|
||||
this.deviceInfo.voiceStrobeAlarm = isClose ? 0 : 1; //强制报警,报警中 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) {
|
||||
// 与 MQTT / bleValueNotify 一致:报警中=1,解除=-1(勿在请求前乐观改 UI,失败会导致按钮文案错乱)
|
||||
this.$set(this.deviceInfo, 'voiceStrobeAlarm', isClose ? -1 : 1);
|
||||
uni.showToast({
|
||||
title: isClose ? '声光报警已解除' : '强制报警已开启',
|
||||
icon: 'none'
|
||||
});
|
||||
if (isClose && this.formData.sta_VoiceType === '7') {
|
||||
// 解除后「播放语音」行与 mode7 绑定,需退出高亮(兼容 sta_VoiceType 为数字 7)
|
||||
if (isClose && String(this.formData.sta_VoiceType) === '7') {
|
||||
this.formData.sta_VoiceType = '-1';
|
||||
}
|
||||
} else {
|
||||
@ -1041,7 +1178,12 @@
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
}).catch((err) => {});
|
||||
}).catch(() => {
|
||||
uni.showToast({
|
||||
title: '网络或蓝牙异常,请重试',
|
||||
icon: 'none'
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
},
|
||||
@ -1123,6 +1265,9 @@
|
||||
bleTool.StopSearch();
|
||||
bleTool.removeDeviceFound('HBY100J_SCAN');
|
||||
console.log('100J 蓝牙扫描超时,将使用4G');
|
||||
that.formData.bleStatu = false;
|
||||
const devId = that.deviceInfo && that.deviceInfo.deviceId;
|
||||
if (devId) updateBleStatus(false, '', devId);
|
||||
}, timeout);
|
||||
|
||||
bleTool.addDeviceFound((res) => {
|
||||
@ -1160,10 +1305,29 @@
|
||||
clearTimeout(timer);
|
||||
bleTool.removeDeviceFound('HBY100J_SCAN');
|
||||
console.log('100J 蓝牙扫描启动失败,将使用4G', err);
|
||||
that.formData.bleStatu = 'err';
|
||||
const devId = that.deviceInfo && that.deviceInfo.deviceId;
|
||||
if (devId) updateBleStatus(false, '', devId);
|
||||
}
|
||||
});
|
||||
},
|
||||
bleStateBreak() {
|
||||
_match100JBleItemByRes(res) {
|
||||
if (!res || !res.deviceId) return true;
|
||||
const mac = (this.device && this.device.deviceMac) || (this.deviceInfo && this.deviceInfo.deviceMac);
|
||||
if (!mac) return true;
|
||||
const macNorm = (m) => (m || '').replace(/:/g, '').toUpperCase();
|
||||
const target = macNorm(mac);
|
||||
const last6 = target.slice(-6);
|
||||
const item = bleTool.data.LinkedList.find((v) => {
|
||||
const m = macNorm(v.macAddress || '');
|
||||
return v.deviceId === res.deviceId && (m === target || (m.length >= 6 && m.slice(-6) ===
|
||||
last6));
|
||||
});
|
||||
return !!item;
|
||||
},
|
||||
bleStateBreak(res) {
|
||||
// 仅处理本页 100J 的断开,避免其它型号设备断连误改本页状态
|
||||
if (res && res.deviceId && !this._match100JBleItemByRes(res)) return;
|
||||
this.formData.bleStatu = false;
|
||||
updateBleStatus(false, '', this.deviceInfo.deviceId);
|
||||
},
|
||||
@ -1177,6 +1341,7 @@
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!this._match100JBleItemByRes(res)) return;
|
||||
let bleDeviceId = res.deviceId;
|
||||
updateBleStatus(true, bleDeviceId, this.deviceInfo.deviceId);
|
||||
// 蓝牙连接成功后主动拉取电源状态、定位(优先蓝牙,设备也会每1分钟主动上报)
|
||||
@ -1218,6 +1383,9 @@
|
||||
if (parsedData.batteryRemainingTime !== undefined) {
|
||||
this.$set(this.deviceInfo, 'batteryRemainingTime', parsedData.batteryRemainingTime);
|
||||
}
|
||||
if (parsedData.chargingStatus !== undefined) {
|
||||
this.$set(this.deviceInfo, 'chargingStatus', parsedData.chargingStatus);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1230,7 +1398,9 @@
|
||||
this.formData.sta_VoiceType = (parsedData.alarmMode ?? 0) + '';
|
||||
} else {
|
||||
this.$set(this.deviceInfo, 'voiceStrobeAlarm', -1);
|
||||
this.formData.sta_VoiceType = (parsedData.alarmMode ?? 0) + '';
|
||||
const am = Number(parsedData.alarmMode ?? 0);
|
||||
// 报警已关:设备仍可能带 mode7,避免「播放语音」仍显示为开启
|
||||
this.formData.sta_VoiceType = am === 7 ? '-1' : am + '';
|
||||
}
|
||||
}
|
||||
// 0x0A 爆闪模式:警示灯开关/模式
|
||||
@ -1256,7 +1426,8 @@
|
||||
this.formData.sta_VoiceType = (parsedData.alarmMode ?? 0) + '';
|
||||
} else {
|
||||
this.$set(this.deviceInfo, 'voiceStrobeAlarm', -1);
|
||||
this.formData.sta_VoiceType = (parsedData.alarmMode ?? 0) + '';
|
||||
const am = Number(parsedData.alarmMode ?? 0);
|
||||
this.formData.sta_VoiceType = am === 7 ? '-1' : am + '';
|
||||
}
|
||||
}
|
||||
if (parsedData.voiceBroadcast !== undefined) {
|
||||
@ -1264,15 +1435,17 @@
|
||||
else if (this.formData.sta_VoiceType === '7') this.formData.sta_VoiceType = '-1';
|
||||
}
|
||||
if (parsedData.volume !== undefined) this.formData.volume = parsedData.volume;
|
||||
if (parsedData.strobeFrequency !== undefined) this.formData.strobeFrequency = parsedData
|
||||
.strobeFrequency;
|
||||
if (parsedData.strobeFrequency !== undefined) {
|
||||
this.formData.strobeFrequency = this.normalizeStrobeFreq(parsedData.strobeFrequency);
|
||||
}
|
||||
if (parsedData.redBrightness !== undefined) this.formData.lightBrightness = parsedData
|
||||
.redBrightness;
|
||||
}
|
||||
// 0x09 音量、0x0D 亮度:单独响应时同步
|
||||
if (fc === 0x09 && parsedData.volume !== undefined) this.formData.volume = parsedData.volume;
|
||||
if (fc === 0x0B && parsedData.strobeFrequency !== undefined) this.formData.strobeFrequency = parsedData
|
||||
.strobeFrequency;
|
||||
if (fc === 0x0B && parsedData.strobeFrequency !== undefined) {
|
||||
this.formData.strobeFrequency = this.normalizeStrobeFreq(parsedData.strobeFrequency);
|
||||
}
|
||||
if (fc === 0x0D && parsedData.redBrightness !== undefined) this.formData.lightBrightness = parsedData
|
||||
.redBrightness;
|
||||
},
|
||||
@ -1779,6 +1952,9 @@
|
||||
|
||||
.slider-container {
|
||||
padding: 0px;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.addIco {
|
||||
|
||||
@ -29,8 +29,8 @@
|
||||
</view>
|
||||
<view class="itemRight ">
|
||||
<view class="btn" @click.stop="Apply(item, index)"
|
||||
:class="{ 'active': item.useStatus, 'btn-default': !item.useStatus }">
|
||||
{{ item.useStatus == 1 ? '使用中' : '使用' }}
|
||||
:class="{ 'active': isVoiceInUse(item), 'btn-default': !isVoiceInUse(item) }">
|
||||
{{ isVoiceInUse(item) ? '使用中' : '使用' }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="clear"></view>
|
||||
@ -105,7 +105,9 @@
|
||||
videRenameAudioFile,
|
||||
deviceDeleteAudioFile,
|
||||
deviceUpdateVoice,
|
||||
updateBleStatus
|
||||
updateBleStatus,
|
||||
sync100JBleProtocolFromHelper,
|
||||
remove100JVoiceBleCache
|
||||
} from '@/api/100J/HBY100-J.js'
|
||||
import { baseURL } from '@/utils/request.js'
|
||||
import {
|
||||
@ -231,12 +233,37 @@
|
||||
console.log("页面返回")
|
||||
},
|
||||
onUnload() {
|
||||
// 页面卸载时断开MQTT连接
|
||||
this.clearVoiceApplyTimers();
|
||||
if (this.mqttClient) {
|
||||
this.mqttClient.disconnect();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/** 清除「使用」语音相关的全部定时器,避免返回上一页后仍触发 toast / 二次 navigateBack */
|
||||
clearVoiceApplyTimers() {
|
||||
if (this._applyOverallTimer) {
|
||||
clearTimeout(this._applyOverallTimer);
|
||||
this._applyOverallTimer = null;
|
||||
}
|
||||
if (this.upgradeTimer) {
|
||||
clearTimeout(this.upgradeTimer);
|
||||
this.upgradeTimer = null;
|
||||
}
|
||||
if (this._applyNavigateTimer) {
|
||||
clearTimeout(this._applyNavigateTimer);
|
||||
this._applyNavigateTimer = null;
|
||||
}
|
||||
},
|
||||
scheduleNavigateBackAfterVoice(delayMs = 1500) {
|
||||
if (this._applyNavigateTimer) {
|
||||
clearTimeout(this._applyNavigateTimer);
|
||||
this._applyNavigateTimer = null;
|
||||
}
|
||||
this._applyNavigateTimer = setTimeout(() => {
|
||||
this._applyNavigateTimer = null;
|
||||
uni.navigateBack();
|
||||
}, delayMs);
|
||||
},
|
||||
//语音管理列表(合并云端 + 本地无网络保存的语音)
|
||||
getinitData(val, isLoadMore = false) {
|
||||
const deviceId = this.device.deviceId;
|
||||
@ -266,7 +293,8 @@
|
||||
this.total = res.total;
|
||||
const list = (res.data || []).map(item => ({
|
||||
...item,
|
||||
createTime: item.createTime || Common.DateFormat(new Date(), "yyyy年MM月dd日")
|
||||
createTime: item.createTime || Common.DateFormat(new Date(), "yyyy年MM月dd日"),
|
||||
useStatus: Number(item.useStatus) === 1 ? 1 : 0
|
||||
}));
|
||||
this.dataListA = mergeLocal(list);
|
||||
if (this.mescroll) this.mescroll.endBySize(this.dataListA.length, this.total + (this.dataListA.length - list.length));
|
||||
@ -430,7 +458,10 @@
|
||||
let task = () => {
|
||||
if (item._isLocal) {
|
||||
// 本地项:从本地存储移除
|
||||
const key = `100J_local_audio_${this.device.deviceId}`;
|
||||
const devId = this.device.deviceId;
|
||||
const vid = (item.id != null && item.id !== '') ? item.id : item.fileId;
|
||||
remove100JVoiceBleCache(devId, vid);
|
||||
const key = `100J_local_audio_${devId}`;
|
||||
let list = uni.getStorageSync(key) || [];
|
||||
list = list.filter(l => l.id !== item.id && l.Id !== item.Id);
|
||||
uni.setStorageSync(key, list);
|
||||
@ -496,9 +527,31 @@
|
||||
this.checkList.push(item.Id);
|
||||
}
|
||||
},
|
||||
/** 与后端约定:仅 1 为使用中(避免字符串 "0" 在 class 里仍为 truthy) */
|
||||
isVoiceInUse(item) {
|
||||
return Number(item && item.useStatus) === 1;
|
||||
},
|
||||
/** 切换「使用」后同步整表:仅当前项为 1,其余为 0(避免第一项永远显示使用中) */
|
||||
syncVoiceListUseStatus(activeItem) {
|
||||
const pickId = (o) => {
|
||||
if (!o) return '';
|
||||
const v = o.id ?? o.fileId ?? o.Id;
|
||||
return v != null && v !== '' ? String(v) : '';
|
||||
};
|
||||
const aid = pickId(activeItem);
|
||||
if (!aid) return;
|
||||
this.dataListA.forEach((row, i) => {
|
||||
const rid = pickId(row);
|
||||
const use = rid === aid ? 1 : 0;
|
||||
if (Number(row.useStatus) !== use) {
|
||||
this.$set(this.dataListA, i, { ...row, useStatus: use });
|
||||
}
|
||||
});
|
||||
},
|
||||
Apply(item, index) {
|
||||
this.updateProgress = 0;
|
||||
this.isUpdating = true;
|
||||
this.clearVoiceApplyTimers();
|
||||
// 本地项在无网时禁止下发,仅弹窗(isUpdating 在确认可执行后再置 true)
|
||||
// 本地项优先用 localPath;云端项用 fileUrl(兼容多种字段名),相对路径补全 baseURL
|
||||
let fileUrl = '';
|
||||
let localPath = (item.localPath && typeof item.localPath === 'string') ? item.localPath : '';
|
||||
@ -506,73 +559,144 @@
|
||||
const raw = item.fileUrl || item.url || item.filePath || item.audioUrl || item.ossUrl || '';
|
||||
fileUrl = (typeof raw === 'string' && raw) ? (raw.startsWith('/') ? (baseURL + raw) : raw) : '';
|
||||
} else {
|
||||
// 本地项:localPath 优先,无则用 fileUrl(mergeLocal 中可能只有 fileUrl 存路径)
|
||||
if (!localPath && item.fileUrl) localPath = item.fileUrl;
|
||||
// 本地项:localPath 优先;mergeLocal 可能把路径放在 fileUrl,但勿把 http 当成本地路径
|
||||
if (!localPath && item.fileUrl) {
|
||||
const cand = String(item.fileUrl).trim();
|
||||
if (cand && !/^https?:\/\//i.test(cand)) localPath = cand;
|
||||
}
|
||||
}
|
||||
const data = {
|
||||
id: item.id,
|
||||
fileUrl,
|
||||
id: (item.id != null && item.id !== '') ? item.id : item.fileId,
|
||||
// 本地合并项 mergeLocal 会把路径写在 fileUrl,需带给接口层做 effectiveLocal 兜底
|
||||
fileUrl: item._isLocal ? (typeof item.fileUrl === 'string' ? item.fileUrl : '') : fileUrl,
|
||||
localPath,
|
||||
onProgress: (p) => { this.updateProgress = p; },
|
||||
onWaiting: () => { uni.showToast({ title: '等待蓝牙连接中...', icon: 'none', duration: 2000 }); }
|
||||
onProgress: (p) => {
|
||||
const n = Math.min(100, Math.max(0, Math.round(Number(p) || 0)));
|
||||
const cur = Number(this.updateProgress) || 0;
|
||||
this.updateProgress = Math.max(cur, n);
|
||||
},
|
||||
// 不传「蓝牙连接中」类提示:关蓝牙走 4G 时易误导;进度条 + 必要时全局请稍候即可
|
||||
onWaiting: () => {}
|
||||
};
|
||||
// 整体超时 60 秒(仅影响蓝牙上传,4G HTTP 很快返回)
|
||||
const overallTimer = setTimeout(() => {
|
||||
if (this.isUpdating) {
|
||||
uni.showToast({ title: '操作超时', icon: 'none', duration: 2000 });
|
||||
const runDeviceUpdate = () => {
|
||||
// 大文件蓝牙分片耗时可远超 2 分钟,整体超时放宽到 10 分钟(挂到实例上,便于 onUnload / 成功时清除)
|
||||
const OVERALL_MS = 600000;
|
||||
if (this._applyOverallTimer) {
|
||||
clearTimeout(this._applyOverallTimer);
|
||||
this._applyOverallTimer = null;
|
||||
}
|
||||
this._applyOverallTimer = setTimeout(() => {
|
||||
this._applyOverallTimer = null;
|
||||
if (this.isUpdating) {
|
||||
uni.showToast({ title: '操作时间过长已中断,请重试或检查蓝牙连接', icon: 'none', duration: 2500 });
|
||||
this.isUpdating = false;
|
||||
this.updateProgress = 0;
|
||||
}
|
||||
}, OVERALL_MS);
|
||||
// 进入列表时的蓝牙快照可能过期;与 HBY100 详情页一致,从 BleHelper 按 MAC 再对齐一次
|
||||
sync100JBleProtocolFromHelper(this.device).then(() => deviceUpdateVoice(data)).then((RES) => {
|
||||
if (this._applyOverallTimer) {
|
||||
clearTimeout(this._applyOverallTimer);
|
||||
this._applyOverallTimer = null;
|
||||
}
|
||||
if (RES.code == 200) {
|
||||
// 蓝牙上传:进度已由 onProgress 更新,直接完成
|
||||
if (RES._channel === 'ble') {
|
||||
if (this.upgradeTimer) {
|
||||
clearTimeout(this.upgradeTimer);
|
||||
this.upgradeTimer = null;
|
||||
}
|
||||
const title = RES._updateVoiceAfterBleFailed
|
||||
? '蓝牙已下发,云端同步失败可稍后重试'
|
||||
: '音频上传成功';
|
||||
this.syncVoiceListUseStatus(item);
|
||||
uni.showToast({ title, icon: RES._updateVoiceAfterBleFailed ? 'none' : 'success', duration: 2000 });
|
||||
this.isUpdating = false;
|
||||
this.scheduleNavigateBackAfterVoice(1500);
|
||||
return;
|
||||
}
|
||||
// 4G:MQTT 进度可能数十秒才上报,用「自上次进度起」滑动超时,避免误报
|
||||
const MQTT_IDLE_MS = 120000;
|
||||
const armMqttIdle = () => {
|
||||
if (this.upgradeTimer) clearTimeout(this.upgradeTimer);
|
||||
this.upgradeTimer = setTimeout(() => {
|
||||
if (!this.isUpdating) return;
|
||||
uni.showToast({
|
||||
title: '长时间未收到设备进度,若语音已生效可返回查看',
|
||||
icon: 'none',
|
||||
duration: 3500
|
||||
});
|
||||
this.isUpdating = false;
|
||||
this.updateProgress = 0;
|
||||
}, MQTT_IDLE_MS);
|
||||
};
|
||||
armMqttIdle();
|
||||
this.mqttClient = this.mqttClient || new MqttClient();
|
||||
this.mqttClient.connect(() => {
|
||||
const statusTopic = `status/894078/HBY100/${this.device.deviceImei}`;
|
||||
this.mqttClient.subscribe(statusTopic, (payload) => {
|
||||
try {
|
||||
const payloadObj = typeof payload === 'string' ? JSON.parse(payload) : payload;
|
||||
const progress = payloadObj.data != null && payloadObj.data.progress !== undefined
|
||||
? payloadObj.data.progress
|
||||
: payloadObj.progress;
|
||||
if (progress !== undefined && !isNaN(progress) && progress >= 0 && progress <= 100) {
|
||||
armMqttIdle();
|
||||
const cur = Number(this.updateProgress) || 0;
|
||||
this.updateProgress = Math.max(cur, Math.round(progress));
|
||||
if (Number(progress) === 100) {
|
||||
if (this.upgradeTimer) clearTimeout(this.upgradeTimer);
|
||||
this.upgradeTimer = null;
|
||||
this.syncVoiceListUseStatus(item);
|
||||
uni.showToast({ title: '音频上传成功', icon: 'success', duration: 2000 });
|
||||
this.isUpdating = false;
|
||||
this.scheduleNavigateBackAfterVoice(1500);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('解析MQTT payload失败:', e);
|
||||
armMqttIdle();
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.isUpdating = false;
|
||||
uni.showToast({ title: RES.msg || '操作失败', icon: 'none', duration: 1000 });
|
||||
}
|
||||
}).catch((err) => {
|
||||
if (this._applyOverallTimer) {
|
||||
clearTimeout(this._applyOverallTimer);
|
||||
this._applyOverallTimer = null;
|
||||
}
|
||||
this.isUpdating = false;
|
||||
this.updateProgress = 0;
|
||||
}
|
||||
}, 60000);
|
||||
deviceUpdateVoice(data).then((RES) => {
|
||||
clearTimeout(overallTimer);
|
||||
if (RES.code == 200) {
|
||||
// 蓝牙上传:进度已由 onProgress 更新,直接完成
|
||||
if (RES._channel === 'ble') {
|
||||
uni.showToast({ title: '音频上传成功', icon: 'success', duration: 2000 });
|
||||
this.isUpdating = false;
|
||||
setTimeout(() => { uni.navigateBack(); }, 1500);
|
||||
return;
|
||||
}
|
||||
// 4G:订阅 MQTT 获取设备端进度,6 秒超时
|
||||
this.upgradeTimer = setTimeout(() => {
|
||||
if (this.isUpdating) {
|
||||
uni.showToast({ title: '音频进度同步超时', icon: 'none', duration: 2000 });
|
||||
this.isUpdating = false;
|
||||
this.updateProgress = 0;
|
||||
uni.showToast({ title: err.message || '操作失败', icon: 'none', duration: 2500 });
|
||||
});
|
||||
};
|
||||
if (item._isLocal) {
|
||||
uni.getNetworkType({
|
||||
success: (net) => {
|
||||
if (net.networkType === 'none') {
|
||||
uni.showModal({
|
||||
title: '无法使用',
|
||||
content: '无网保存的本地语音无法通过蓝牙下发。请先连接 WiFi 或移动网络后,重新录制并保存(上传云端),再点「使用」。',
|
||||
showCancel: false,
|
||||
confirmText: '知道了'
|
||||
});
|
||||
return;
|
||||
}
|
||||
}, 6000);
|
||||
this.mqttClient = this.mqttClient || new MqttClient();
|
||||
this.mqttClient.connect(() => {
|
||||
const statusTopic = `status/894078/HBY100/${this.device.deviceImei}`;
|
||||
this.mqttClient.subscribe(statusTopic, (payload) => {
|
||||
try {
|
||||
const payloadObj = typeof payload === 'string' ? JSON.parse(payload) : payload;
|
||||
const progress = payloadObj.data?.progress;
|
||||
if (progress !== undefined && !isNaN(progress) && progress >= 0 && progress <= 100) {
|
||||
this.updateProgress = progress;
|
||||
if (progress === 100) {
|
||||
clearTimeout(this.upgradeTimer);
|
||||
uni.showToast({ title: '音频上传成功', icon: 'success', duration: 2000 });
|
||||
this.isUpdating = false;
|
||||
setTimeout(() => { uni.navigateBack(); }, 1500);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
clearTimeout(this.upgradeTimer);
|
||||
console.error('解析MQTT payload失败:', e);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.isUpdating = false;
|
||||
uni.showToast({ title: RES.msg || '操作失败', icon: 'none', duration: 1000 });
|
||||
}
|
||||
}).catch((err) => {
|
||||
clearTimeout(overallTimer);
|
||||
this.isUpdating = false;
|
||||
uni.showToast({ title: err.message || '操作失败', icon: 'none', duration: 2000 });
|
||||
});
|
||||
this.isUpdating = true;
|
||||
runDeviceUpdate();
|
||||
},
|
||||
fail: () => {
|
||||
this.isUpdating = true;
|
||||
runDeviceUpdate();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.isUpdating = true;
|
||||
runDeviceUpdate();
|
||||
},
|
||||
closePop: function() {
|
||||
this.Status.Pop.showPop = false;
|
||||
|
||||
@ -137,8 +137,9 @@
|
||||
updateLoading
|
||||
} from '@/utils/loading.js';
|
||||
import Common from '@/utils/Common.js';
|
||||
|
||||
|
||||
import {
|
||||
cache100JVoiceFileForBle
|
||||
} from '@/api/100J/HBY100-J.js';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@ -421,44 +422,6 @@
|
||||
hideLoading(these);
|
||||
}, 1200);
|
||||
},
|
||||
// 无网络时保存到本地,供蓝牙直接发送(不依赖 OSS)
|
||||
// 将临时文件复制到持久化目录 _doc/100J_audio/,避免被系统清理
|
||||
saveLocalForBle(filePath) {
|
||||
const deviceId = these.Status.ID;
|
||||
if (!deviceId) return;
|
||||
const doSave = (persistentPath) => {
|
||||
const item = {
|
||||
...these.cEdit,
|
||||
localPath: persistentPath,
|
||||
fileUrl: '',
|
||||
deviceId,
|
||||
id: 'local_' + these.cEdit.Id,
|
||||
_createTime: these.cEdit.createTime || Common.DateFormat(new Date(), "yyyy年MM月dd日"),
|
||||
_isLocal: true
|
||||
};
|
||||
const key = `100J_local_audio_${deviceId}`;
|
||||
let list = uni.getStorageSync(key) || [];
|
||||
list.unshift(item);
|
||||
uni.setStorageSync(key, list);
|
||||
these.AudioData.tempFilePath = "";
|
||||
these.Status.isRecord = false;
|
||||
uni.navigateBack();
|
||||
};
|
||||
if (typeof plus !== 'undefined' && plus.io) {
|
||||
const fileName = 'audio_' + (these.cEdit.Id || Date.now()) + '.mp3';
|
||||
plus.io.resolveLocalFileSystemURL(filePath, (entry) => {
|
||||
plus.io.resolveLocalFileSystemURL('_doc/', (docEntry) => {
|
||||
docEntry.getDirectory('100J_audio', { create: true }, (dirEntry) => {
|
||||
entry.copyTo(dirEntry, fileName, (newEntry) => {
|
||||
doSave(newEntry.fullPath);
|
||||
}, () => { doSave(filePath); });
|
||||
}, () => { doSave(filePath); });
|
||||
}, () => { doSave(filePath); });
|
||||
}, () => { doSave(filePath); });
|
||||
} else {
|
||||
doSave(filePath);
|
||||
}
|
||||
},
|
||||
// 保存录音并上传(已修复文件格式问题)
|
||||
uploadLuYin() {
|
||||
// 文件类型验证
|
||||
@ -478,37 +441,73 @@
|
||||
console.log("自动添加.mp3扩展名,新路径:", uploadFilePath);
|
||||
}
|
||||
|
||||
console.log("上传文件路径:", uploadFilePath);
|
||||
plus.io.resolveLocalFileSystemURL(uploadFilePath, (entry) => {
|
||||
entry.getMetadata((metadata) => {
|
||||
console.log("文件大小:", metadata.size, "字节");
|
||||
console.log("文件类型验证通过");
|
||||
const startOssUpload = () => {
|
||||
console.log("上传文件路径:", uploadFilePath);
|
||||
// _downloads/_doc 相对路径上 resolve 部分机型会长期无回调,直接走 doUpload(内会 convert 供 uni.uploadFile)
|
||||
const fp = String(uploadFilePath || '');
|
||||
if (fp.indexOf('_downloads/') === 0 || fp.indexOf('_doc/') === 0) {
|
||||
this.doUpload(uploadFilePath);
|
||||
return;
|
||||
}
|
||||
plus.io.resolveLocalFileSystemURL(uploadFilePath, (entry) => {
|
||||
entry.getMetadata((metadata) => {
|
||||
console.log("文件大小:", metadata.size, "字节");
|
||||
console.log("文件类型验证通过");
|
||||
this.doUpload(uploadFilePath);
|
||||
}, (err) => {
|
||||
console.error("获取文件元数据失败:", err);
|
||||
this.doUpload(this.AudioData.tempFilePath);
|
||||
});
|
||||
}, (err) => {
|
||||
console.error("获取文件元数据失败:", err);
|
||||
console.error("文件不存在或路径错误:", err);
|
||||
this.doUpload(this.AudioData.tempFilePath);
|
||||
});
|
||||
}, (err) => {
|
||||
console.error("文件不存在或路径错误:", err);
|
||||
this.doUpload(this.AudioData.tempFilePath);
|
||||
};
|
||||
|
||||
// 无网络不允许保存:无网本地项无法上传云端,列表里「使用」也无法可靠读本地蓝牙下发
|
||||
uni.getNetworkType({
|
||||
success: (res) => {
|
||||
if (res.networkType === 'none') {
|
||||
uni.showModal({
|
||||
title: '无法保存',
|
||||
content: '当前无网络,语音需上传云端后才能正常使用与蓝牙下发。请连接 WiFi 或移动网络后再点保存。',
|
||||
showCancel: false,
|
||||
confirmText: '知道了'
|
||||
});
|
||||
return;
|
||||
}
|
||||
startOssUpload();
|
||||
},
|
||||
fail: () => {
|
||||
startOssUpload();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 执行上传操作
|
||||
doUpload(filePath) {
|
||||
const key = `${Common.pcmStorageKey}_${this.cEdit.Id}`;
|
||||
const store = uni.getStorageInfoSync();
|
||||
if (store.keys.includes(key)) return;
|
||||
// 勿因历史 pcmStorageKey_* 存在就静默 return,否则用户点保存无反应、OSS 永不上传
|
||||
const token = uni.getStorageSync('token');
|
||||
const clientid = uni.getStorageSync('clientID');
|
||||
const these = this;
|
||||
let pathForUpload = filePath;
|
||||
try {
|
||||
if (typeof plus !== 'undefined' && plus.io && plus.io.convertLocalFileSystemURL) {
|
||||
const fp = String(filePath || '');
|
||||
if (fp.indexOf('_downloads/') === 0 || fp.indexOf('_doc/') === 0) {
|
||||
const c = plus.io.convertLocalFileSystemURL(fp);
|
||||
if (c) pathForUpload = c;
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
showLoading(this, {
|
||||
text: "文件上传中"
|
||||
});
|
||||
console.log("最终上传文件路径:", filePath);
|
||||
console.log("最终上传文件路径:", pathForUpload);
|
||||
uni.uploadFile({
|
||||
url: baseURL + "/app/video/uploadAudioToOss",
|
||||
filePath: filePath,
|
||||
filePath: pathForUpload,
|
||||
name: 'file',
|
||||
header: {
|
||||
"Authorization": `Bearer ${token}`,
|
||||
@ -535,6 +534,9 @@
|
||||
if (fileUrl) cache[fileUrl] = filePath;
|
||||
if (d && typeof d === 'object' && d.id) cache[d.id] = filePath;
|
||||
uni.setStorageSync(cacheKey, cache);
|
||||
if (d && typeof d === 'object' && d.id) {
|
||||
cache100JVoiceFileForBle(deviceId, d.id, filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 合并两个存储操作
|
||||
@ -592,14 +594,13 @@
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('上传文件失败:', err);
|
||||
// 无网络时保存到本地,供蓝牙直接发送
|
||||
these.saveLocalForBle(filePath);
|
||||
uni.showToast({
|
||||
title: '网络不可用,已保存到本地,可通过蓝牙发送',
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
});
|
||||
these.timeOutCloseLoad();
|
||||
uni.showModal({
|
||||
title: '保存失败',
|
||||
content: '文件未能上传到服务器。请检查网络后重试;无网时无法保存语音。',
|
||||
showCancel: false,
|
||||
confirmText: '知道了'
|
||||
});
|
||||
},
|
||||
complete: () => {
|
||||
console.log('上传操作完成');
|
||||
|
||||
@ -28,14 +28,14 @@
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.sta_PowerPercent}}%</view>
|
||||
<view class="smallTxt">电量</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.sta_charge?dic.sta_charge[formData.sta_charge+'']:"未充电" }}
|
||||
</view>
|
||||
@ -526,7 +526,7 @@
|
||||
these.formData.bleStatu = true;
|
||||
});
|
||||
}
|
||||
|
||||
this.getWarns();
|
||||
// this.getLinkedCnt();
|
||||
},
|
||||
computed: {
|
||||
@ -673,7 +673,7 @@
|
||||
}
|
||||
|
||||
let warnKey = "102_" + these.device.id + "_warning";
|
||||
let linkKey = "102_" + these.device.id + "_linked";
|
||||
// let linkKey = "102_" + these.device.id + "_linked";
|
||||
let p1 = new Promise((succ, err) => {
|
||||
uni.getStorage({
|
||||
key: warnKey,
|
||||
@ -690,33 +690,33 @@
|
||||
});
|
||||
});
|
||||
|
||||
let p2 = new Promise((succ, err) => {
|
||||
uni.getStorage({
|
||||
key: linkKey,
|
||||
success(res) {
|
||||
console.error("获取到联机数据", res);
|
||||
let data = res.data;
|
||||
let fs = data.filter(v => {
|
||||
return !v.read
|
||||
});
|
||||
console.error("未读联机数据", fs);
|
||||
succ(fs);
|
||||
},
|
||||
fail(ex) {
|
||||
err(null);
|
||||
}
|
||||
});
|
||||
});
|
||||
// let p2 = new Promise((succ, err) => {
|
||||
// uni.getStorage({
|
||||
// key: linkKey,
|
||||
// success(res) {
|
||||
// console.error("获取到联机数据", res);
|
||||
// let data = res.data;
|
||||
// let fs = data.filter(v => {
|
||||
// return !v.read
|
||||
// });
|
||||
// console.error("未读联机数据", fs);
|
||||
// succ(fs);
|
||||
// },
|
||||
// fail(ex) {
|
||||
// err(null);
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
||||
Promise.allSettled([p1, p2]).then(results => {
|
||||
Promise.allSettled([p1]).then(results => {
|
||||
let fs = [];
|
||||
|
||||
if (results[0].status == 'fulfilled') {
|
||||
fs = fs.concat(results[0].value);
|
||||
}
|
||||
if (results[1].status == 'fulfilled') {
|
||||
fs = fs.concat(results[1].value);
|
||||
}
|
||||
// if (results[1].status == 'fulfilled') {
|
||||
// fs = fs.concat(results[1].value);
|
||||
// }
|
||||
console.error("获取到未读消息", fs);
|
||||
these.$set(these.Status.navbar.icons[0], "math", fs.length);
|
||||
});
|
||||
@ -945,7 +945,7 @@
|
||||
|
||||
|
||||
sosSetting(item, isOk) {
|
||||
|
||||
debugger;
|
||||
if (!this.permissions.includes('46') && this.Status.apiType !== 'listA') {
|
||||
|
||||
this.showPop({
|
||||
@ -1034,7 +1034,8 @@
|
||||
|
||||
});
|
||||
} else {
|
||||
task(item.key);
|
||||
let newval=this.formData.sta_LedType===item.key?'led_off':item.key;
|
||||
task(newval);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1155,7 +1156,7 @@
|
||||
this.Status.BottomMenu.activeIndex = active;
|
||||
|
||||
let msg = [];
|
||||
if (json.sta_PowerPercent <= 20 && (json.sta_charge === 0 || json.sta_charge === '0')) {
|
||||
if (json.sta_PowerPercent <= 20 && json.sta_PowerPercent!=this.formData.sta_PowerPercent && (json.sta_charge === 0 || json.sta_charge === '0')) {
|
||||
msg.push("设备电量低");
|
||||
}
|
||||
|
||||
|
||||
@ -18,14 +18,14 @@
|
||||
</view>
|
||||
<view>
|
||||
<view class="battery-v1">
|
||||
<image src="/static/images/common/dl.png" class="dlIMG"></image>
|
||||
<image src="/static/images/common/battry.png" class="dlIMG"></image>
|
||||
<view>
|
||||
<view class="battery-v2">{{deviceInfo.batteryPercentage}}%</view>
|
||||
<view class="battery-v3">电量</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="battery-v1">
|
||||
<image src="/static/images/common/nz.png" class="dlIMG" mode="aspectFit"></image>
|
||||
<image src="/static/images/common/time.png" class="dlIMG" mode="aspectFit"></image>
|
||||
<view>
|
||||
<view class="battery-v2">{{deviceInfo.batteryRemainingTime}}分钟</view>
|
||||
<view class="battery-v3">续航时间</view>
|
||||
|
||||
@ -26,14 +26,14 @@
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.sta_PowerPercent}}%</view>
|
||||
<view class="smallTxt">电量</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.xuhang}}</view>
|
||||
<view class="smallTxt">续航时间</view>
|
||||
|
||||
@ -7,14 +7,14 @@
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.sta_PowerPercent}}%</view>
|
||||
<view class="smallTxt">电量</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.xuhang}}</view>
|
||||
<view class="smallTxt">续航时间</view>
|
||||
|
||||
@ -18,14 +18,14 @@
|
||||
</view>
|
||||
<view>
|
||||
<view class="battery-v1">
|
||||
<image src="/static/images/common/dl.png" class="dlIMG"></image>
|
||||
<image src="/static/images/common/battry.png" class="dlIMG"></image>
|
||||
<view>
|
||||
<view class="battery-v2">{{deviceInfo.batteryPercentage}}%</view>
|
||||
<view class="battery-v3">电量</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="battery-v1">
|
||||
<image src="/static/images/common/nz.png" class="dlIMG" mode="aspectFit"></image>
|
||||
<image src="/static/images/common/time.png" class="dlIMG" mode="aspectFit"></image>
|
||||
<view>
|
||||
<view class="battery-v2">{{deviceInfo.batteryRemainingTime}}分钟</view>
|
||||
<view class="battery-v3">续航时间</view>
|
||||
|
||||
@ -23,29 +23,29 @@
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.sta_PowerPercent}}%</view>
|
||||
<view class="smallTxt">电量</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{battery}}</view>
|
||||
<view class="bigTxt">{{formData.sta_PowerTime}}</view>
|
||||
<view class="smallTxt">续航时间</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="warnnig" :class="formData.sta_ShakeBit!==0 && formData.showShakeBit ?'':'displayNone'">
|
||||
<view>{{formData.sta_ShakeBit==1?'设备疑似受到外力碰撞':'设备声光报警中'}}!</view>
|
||||
<view class="warnnig" :class="formData.sta_ShakeBit!==0 ?'':'displayNone'">
|
||||
<view>{{formData.sta_ShakeBit==3?'设备疑似受到外力碰撞':'设备声光报警中'}}!</view>
|
||||
<view @click.stop="SOSToggle()">
|
||||
<uni-icons type="closeempty" color="#FFFFFFde" size="16"></uni-icons>
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
|
||||
</view>
|
||||
|
||||
|
||||
@ -76,7 +76,10 @@
|
||||
<text class="lbl">设备状态</text>
|
||||
<text class="value valueFont">{{sta_system}}</text>
|
||||
</view>
|
||||
|
||||
<view class="item">
|
||||
<text class="lbl">环境温度</text>
|
||||
<text class="value " :class="heatStyle">{{formData.sta_Heat}}</text>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">定位信息</text>
|
||||
<view class="multiValue" @click.stop="gotoMap()">
|
||||
@ -108,7 +111,7 @@
|
||||
<view class="item">
|
||||
<view>
|
||||
<text class="lbl">海拔高度</text>
|
||||
<view class="value valueFont leftIndent">{{formData.sta_height}}m</view>
|
||||
<view class="value valueFont leftIndent">{{formData.sta_Height}}m</view>
|
||||
</view>
|
||||
<view>
|
||||
<text class="lbl">相对高度</text>
|
||||
@ -150,23 +153,23 @@
|
||||
<text class="smallTxt">{{FuLight}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mode " :class="{active:formData.sta_laser===1}" v-on:click.stop="laserToggle">
|
||||
<view class="mode " :class="{active:formData.sta_laser==1}" v-on:click.stop="laserToggle">
|
||||
<view class="leftImg">
|
||||
|
||||
<image class="img" src="/static/images/common/jig.png" v-show="formData.sta_laser!==1"
|
||||
<image class="img" src="/static/images/common/jig.png" v-show="formData.sta_laser!=1"
|
||||
mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/jigA.png" v-show="formData.sta_laser===1"
|
||||
<image class="img" src="/static/images/common/jigA.png" v-show="formData.sta_laser==1"
|
||||
mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<text class="bigTxt">激光模式</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mode " :class="{active:formData.sta_ShakeBit!==0}" v-on:click.stop="SOSToggle">
|
||||
<view class="mode " :class="{active:formData.sta_ShakeBit!=0}" v-on:click.stop="SOSToggle">
|
||||
<view class="leftImg">
|
||||
<image class="img" src="/static/images/common/sg.png" v-show="formData.sta_ShakeBit===0"
|
||||
<image class="img" src="/static/images/common/sg.png" v-show="formData.sta_ShakeBit==0"
|
||||
mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/sgActive.png" v-show="formData.sta_ShakeBit!==0"
|
||||
<image class="img" src="/static/images/common/sgActive.png" v-show="formData.sta_ShakeBit!=0"
|
||||
mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
@ -236,7 +239,7 @@
|
||||
<view>
|
||||
|
||||
<view class="item">
|
||||
<input maxlength="16" class="value" style="text-indent: 20rpx;" v-model="formData.msgTxt"
|
||||
<input maxlength="16" class="value" style="text-indent: 20rpx;" v-model="formData.sendMsg"
|
||||
placeholder="请输入文字" placeholder-class="usrplace" />
|
||||
</view>
|
||||
|
||||
@ -296,19 +299,19 @@
|
||||
var eventChannel = null;
|
||||
var these = null;
|
||||
var ble = null;
|
||||
var rec = null;
|
||||
var recei = null;
|
||||
var mq = null;
|
||||
var pagePath = "pages/6075J/BJQ6075J";
|
||||
var brightnessTimer = null;
|
||||
export default {
|
||||
components: {
|
||||
TextToHexV1
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
Status: {
|
||||
|
||||
|
||||
|
||||
|
||||
pageHide: false,
|
||||
apiType: "listA",
|
||||
navbar: {
|
||||
@ -325,7 +328,7 @@
|
||||
height: 90
|
||||
},
|
||||
usrToggle: true,
|
||||
|
||||
|
||||
},
|
||||
formData: {
|
||||
img: '/static/images/common/BJQ6075.png',
|
||||
@ -334,7 +337,7 @@
|
||||
sta_imei: "", //sta_imei
|
||||
sta_longitude: "", //经度
|
||||
sta_latitude: "", //纬度
|
||||
address:'',
|
||||
address: '',
|
||||
|
||||
textLines: [],
|
||||
company: "湖北星汉文化", //单位
|
||||
@ -348,19 +351,20 @@
|
||||
bleStatu: false,
|
||||
|
||||
sta_LightGrade: "", //主灯档位
|
||||
sta_LightGrade: "", //副灯档位
|
||||
sta_ShakeBit: "1", //报警状态
|
||||
sta_Side_Light: "", //副灯档位
|
||||
sta_ShakeBit: 0, //报警状态
|
||||
sta_4gSinal: "", //4G信号强度
|
||||
sta_laser: "", //激光状态
|
||||
sta_brightness: 100, //亮度
|
||||
sta_SOSGrade: "1", //强制报警状态
|
||||
|
||||
showSosGrade:false,
|
||||
showShakeBit:false,
|
||||
sta_height:'',//海拔
|
||||
sta_releaHeight:'',
|
||||
sta_BreakNews:'',
|
||||
deviceId:''
|
||||
|
||||
|
||||
|
||||
sta_Height: '', //海拔
|
||||
sta_Heat: '', //温度
|
||||
sta_releaHeight: '',
|
||||
sta_BreakNews: '',
|
||||
deviceId: ''
|
||||
},
|
||||
device: {
|
||||
id: "",
|
||||
@ -412,12 +416,12 @@
|
||||
staPowerPercent: null,
|
||||
staDetectResult: null
|
||||
},
|
||||
inteval:50
|
||||
inteval: 80
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
getbleStatu() {
|
||||
|
||||
|
||||
if (this.formData.bleStatu === true) {
|
||||
return '已连接';
|
||||
}
|
||||
@ -449,20 +453,24 @@
|
||||
}
|
||||
return state;
|
||||
},
|
||||
battery(){
|
||||
let hours = Math.floor(this.formData.sta_PowerTime / 60);
|
||||
let remainingMinutes = this.formData.sta_PowerTime % 60;
|
||||
|
||||
let xuhang = '0分';
|
||||
// 处理不同情况的显示
|
||||
if (hours === 0) {
|
||||
xuhang = `${remainingMinutes}分`;
|
||||
} else if (remainingMinutes === 0) {
|
||||
xuhang = `${hours}小时`;
|
||||
} else {
|
||||
xuhang = `${hours}小时${remainingMinutes}分`;
|
||||
|
||||
heatStyle() {
|
||||
if (this.formData.sta_Heat < 0) {
|
||||
return 'hanleng';
|
||||
}
|
||||
return xuhang;
|
||||
if (this.formData.sta_Heat >= 0 && this.formData.sta_Heat <= 30) {
|
||||
return 'green';
|
||||
}
|
||||
if (this.formData.sta_Heat > 30 && this.formData.sta_Heat <= 40) {
|
||||
return 're'
|
||||
}
|
||||
if (this.formData.sta_Heat > 40 && this.formData.sta_Heat <= 60) {
|
||||
return 'yanRe'
|
||||
}
|
||||
if (this.formData.sta_Heat > 60) {
|
||||
return 'kuRe'
|
||||
}
|
||||
return '';
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@ -486,15 +494,15 @@
|
||||
},
|
||||
onShow() {
|
||||
this.Status.pageHide = false;
|
||||
|
||||
let f=this.getDevice();
|
||||
if(f){
|
||||
these.formData.bleStatu = 'connecting';
|
||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
|
||||
console.log("连接成功")
|
||||
these.formData.bleStatu = true;
|
||||
});
|
||||
}
|
||||
|
||||
let f = this.getDevice();
|
||||
if (f) {
|
||||
these.formData.bleStatu = 'connecting';
|
||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
|
||||
console.log("连接成功")
|
||||
these.formData.bleStatu = true;
|
||||
});
|
||||
}
|
||||
},
|
||||
onHide: function() {
|
||||
this.Status.pageHide = true;
|
||||
@ -506,10 +514,10 @@
|
||||
this.initActionData();
|
||||
|
||||
this.initWatch();
|
||||
|
||||
|
||||
|
||||
rec = BleReceive.getBleReceive();
|
||||
|
||||
recei = BleReceive.getBleReceive();
|
||||
ble = BleTool.getBleTool();
|
||||
|
||||
|
||||
@ -568,9 +576,9 @@
|
||||
},
|
||||
methods: {
|
||||
getDetail() {
|
||||
|
||||
|
||||
api.getDetail(this.device.id).then(res => {
|
||||
|
||||
|
||||
if (res && res.code == 200) {
|
||||
res = res.data;
|
||||
let json = res;
|
||||
@ -586,53 +594,41 @@
|
||||
this.formData.job = personnelInfo.position;
|
||||
this.formData.usrid = personnelInfo.code
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
this.formData.sta_PowerPercent = json.staPowerPercent
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
this.formData.sta_PowerTime = json.staPowerTime;
|
||||
|
||||
|
||||
this.formData.sta_SOSGrade = json.staSOSGrade;
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
initWatch(){
|
||||
this.$watch("formData.sta_SOSGrade", (newVal, oldVal) => {
|
||||
console.log("报警状态发生变化");
|
||||
if (newVal == 1) {
|
||||
this.formData.showSosGrade = true;
|
||||
initWatch() {
|
||||
|
||||
this.$watch("formData.sta_Heat", (newVal, oldVal) => {
|
||||
if (newVal) {
|
||||
if (newVal < -30) {
|
||||
MsgError("危险:环境温度过低,当前温度" + newVal + ",请立即撤离", "确定");
|
||||
}
|
||||
if (newVal >= 40 && newVal < 60) {
|
||||
MsgWarning("注意:环境温度过高,当前温度" + newVal, "确定");
|
||||
} else if (newVal >= 60 && newVal < 80) {
|
||||
MsgWarning("警告:环境温度过高,当前温度" + newVal + ",注意停留时间", "确定");
|
||||
} else if (newVal >= 80) {
|
||||
MsgError("危险:环境温度过高,当前温度" + newVal + ",请立即撤离", "确定");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.$watch("formData.sta_ShakeBit", (newVal, oldVal) => {
|
||||
console.log("碰撞状态发生变化");
|
||||
if (newVal != 0) {
|
||||
this.formData.showShakeBit = true;
|
||||
|
||||
this.$watch("formData.sta_BreakNews", (newVal, oldVal) => {
|
||||
if (newVal) {
|
||||
MsgSuccess("用户已确认收到紧急通知", "确定", these);
|
||||
setTimeout(() => {
|
||||
these.formData.sta_BreakNews = "";
|
||||
}, 10);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
this.$watch("formData.sta_BreakNews",(newVal,oldVal)=>{
|
||||
if(newVal){
|
||||
MsgSuccess("用户已确认收到紧急通知","确定",these);
|
||||
setTimeout(()=>{
|
||||
these.formData.sta_BreakNews="";
|
||||
},10);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
this.$watch("formData.sta_PowerPercent", (newVal, oldVal) => {
|
||||
console.log("电量发生变化");
|
||||
if (newVal <=20 && this.formData.sta_system===2 || this.formData.sta_system===0) {
|
||||
if (newVal <= 20 && (this.formData.sta_system === 2 || this.formData.sta_system === 0)) {
|
||||
//电量在20%及以及下,且是未充电状态提醒
|
||||
showPop({
|
||||
message: "设备电量低于20%,请充电",
|
||||
@ -642,13 +638,13 @@
|
||||
buttonTextColor: '#232323de',
|
||||
showCancel: false,
|
||||
showHeader: false,
|
||||
visibleClose: true,
|
||||
visibleClose: true,
|
||||
textColor: '#E03434',
|
||||
iconUrl:'/static/images/common/path.png'
|
||||
},this);
|
||||
iconUrl: '/static/images/common/path.png'
|
||||
}, this);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
checkSendVideo() {
|
||||
|
||||
@ -1004,43 +1000,44 @@
|
||||
}
|
||||
|
||||
let f = this.getDevice();
|
||||
|
||||
|
||||
|
||||
|
||||
var sendImagePackets = function(ReSendNo) {
|
||||
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
|
||||
// 总数据包数
|
||||
let totalPackets = 52;
|
||||
let currentPacket = 1;
|
||||
|
||||
|
||||
if (ReSendNo) {
|
||||
totalPackets = ReSendNo;
|
||||
currentPacket = ReSendNo;
|
||||
}
|
||||
|
||||
|
||||
if (f) {
|
||||
// 发送单个数据包
|
||||
const sendNextPacket = () => {
|
||||
if (currentPacket > totalPackets) {
|
||||
hideLoading(these);
|
||||
these.closeAction();
|
||||
these.showPop({
|
||||
showPop({
|
||||
showPop: true,
|
||||
message: "上传成功",
|
||||
iconUrl: "/static/images/common/success.png",
|
||||
});
|
||||
|
||||
setTimeout(()=>{
|
||||
ble.sendString(f.deviceId, "transmit complete", f.writeServiceId, f
|
||||
.wirteCharactId);
|
||||
},1000);
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
ble.sendString(f.deviceId, "transmit complete", f
|
||||
.writeServiceId, f
|
||||
.wirteCharactId);
|
||||
}, 1000);
|
||||
|
||||
these.rgb565Data = null;
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 计算当前包的数据
|
||||
let packetSize = 250;
|
||||
// if (currentPacket <= 51) {
|
||||
@ -1048,7 +1045,7 @@
|
||||
// } else {
|
||||
// packetSize = 50; // 最后一个包100字节
|
||||
// }
|
||||
|
||||
|
||||
// 创建数据包
|
||||
const startIndex = (currentPacket - 1) * packetSize;
|
||||
const endIndex = Math.min(startIndex + packetSize, these.rgb565Data
|
||||
@ -1062,14 +1059,14 @@
|
||||
const bufferSize = 505; // 5 + packetData.length * 2; // 头部5字节 + 数据部分
|
||||
const buffer = new ArrayBuffer(bufferSize);
|
||||
const dataView = new DataView(buffer);
|
||||
|
||||
|
||||
// 填充头部
|
||||
dataView.setUint8(0, 0x55); // 帧头
|
||||
dataView.setUint8(1, 0x02); // 帧类型:开机画面
|
||||
dataView.setUint8(2, '0x' + currentPacket.toString(16).padStart(2,
|
||||
'0')); // 包序号
|
||||
|
||||
|
||||
|
||||
|
||||
if (packetData.length == 250) {
|
||||
dataView.setUint8(3, 0x01);
|
||||
dataView.setUint8(4, 0xF4);
|
||||
@ -1077,32 +1074,28 @@
|
||||
dataView.setUint8(3, 0x00);
|
||||
dataView.setUint8(4, 0x64);
|
||||
}
|
||||
|
||||
|
||||
// 填充数据(每个RGB565值占2字节)
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint16(5 + i * 2, packetData[i], false); // 大端字节序
|
||||
}
|
||||
|
||||
if (currentPacket > 51) { //第52包补FF
|
||||
for (var i = 105; i < bufferSize; i++) {
|
||||
dataView.setUint8(i, 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//发送数据包
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
|
||||
10)
|
||||
.then(() => {
|
||||
|
||||
|
||||
|
||||
|
||||
updateLoading(these, {
|
||||
text: "正在发送:" + currentPacket + "/" +
|
||||
totalPackets
|
||||
})
|
||||
currentPacket++;
|
||||
|
||||
|
||||
setTimeout(sendNextPacket, these.inteval);
|
||||
}).catch(err => {
|
||||
console.log("发送数据包失败了" + JSON.stringify(err));
|
||||
@ -1111,7 +1104,7 @@
|
||||
return;
|
||||
}
|
||||
these.closeAction();
|
||||
these.showPop({
|
||||
showPop({
|
||||
message: err.msg,
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
@ -1122,7 +1115,7 @@
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (ReSendNo) {
|
||||
sendNextPacket(ReSendNo);
|
||||
return;
|
||||
@ -1131,10 +1124,10 @@
|
||||
ble.sendString(f.deviceId, "picture transmit start", f.writeServiceId,
|
||||
f.wirteCharactId).then(() => {
|
||||
setTimeout(sendNextPacket, 120);
|
||||
|
||||
|
||||
}).catch((err) => {
|
||||
console.log("握手没有成功");
|
||||
these.showPop({
|
||||
showPop({
|
||||
message: err.msg,
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
@ -1164,10 +1157,10 @@
|
||||
|
||||
|
||||
these.rgb565Data = Common.convertToRGB565(data.piexls);
|
||||
|
||||
|
||||
setTimeout(function() {
|
||||
sendImagePackets().catch(() => {
|
||||
|
||||
|
||||
});
|
||||
}, 0)
|
||||
|
||||
@ -1205,7 +1198,7 @@
|
||||
ins_brightness: e.detail.value
|
||||
}
|
||||
|
||||
this.sendData(json, null, 'string').then(res=>{
|
||||
this.sendData(json, null, 'string').then(res => {
|
||||
this.setBleFormData();
|
||||
}).catch(ex => {
|
||||
|
||||
@ -1220,18 +1213,18 @@
|
||||
},
|
||||
getLightMode(type) {
|
||||
let item = null;
|
||||
let index = null;
|
||||
let value = null;
|
||||
if (type === 'main') {
|
||||
index = 0;
|
||||
value = this.formData.sta_LightGrade;
|
||||
item = this.dic.actionSheets[0];
|
||||
|
||||
} else {
|
||||
index = 1;
|
||||
value = this.formData.sta_Side_Light;
|
||||
item = this.dic.actionSheets[1];
|
||||
}
|
||||
|
||||
let f = item.menuItems.find(v => {
|
||||
if (v.value == this.dic.actionSheets[index].value) {
|
||||
if (v.value == value) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@ -1286,37 +1279,37 @@
|
||||
item.menuItems = [{
|
||||
text: '强光',
|
||||
icon: '/static/images/lightImg/qiang.png',
|
||||
value: '1',
|
||||
value: 1,
|
||||
key: 'ins_LightGrade'
|
||||
},
|
||||
{
|
||||
text: '工作光',
|
||||
icon: '/static/images/lightImg/work.png',
|
||||
value: '2',
|
||||
value: 2,
|
||||
key: 'ins_LightGrade'
|
||||
},
|
||||
{
|
||||
text: '节能光',
|
||||
icon: '/static/images/lightImg/jieN.png',
|
||||
value: '3',
|
||||
value: 3,
|
||||
key: 'ins_LightGrade'
|
||||
},
|
||||
{
|
||||
text: '爆闪',
|
||||
icon: '/static/images/lightImg/shan.png',
|
||||
value: '4',
|
||||
value: 4,
|
||||
key: 'ins_LightGrade'
|
||||
},
|
||||
{
|
||||
text: 'SOS',
|
||||
icon: '/static/images/lightImg/sos.png',
|
||||
value: '5',
|
||||
value: 5,
|
||||
key: 'ins_LightGrade'
|
||||
},
|
||||
{
|
||||
text: '关闭',
|
||||
icon: '/static/images/lightImg/closeLight.png',
|
||||
value: '6',
|
||||
value: 6,
|
||||
key: 'ins_LightGrade'
|
||||
}
|
||||
];
|
||||
@ -1329,31 +1322,31 @@
|
||||
item1.menuItems = [{
|
||||
text: '泛光',
|
||||
icon: '/static/images/lightImg/fan.png',
|
||||
value: '2',
|
||||
value: 2,
|
||||
key: 'ins_Side_Light'
|
||||
},
|
||||
{
|
||||
text: '泛光爆闪',
|
||||
icon: '/static/images/lightImg/fan.png',
|
||||
value: '3',
|
||||
value: 3,
|
||||
key: 'ins_Side_Light'
|
||||
},
|
||||
{
|
||||
text: '警示灯',
|
||||
icon: '/static/images/lightImg/warn.png',
|
||||
value: '1',
|
||||
value: 1,
|
||||
key: 'ins_Side_Light'
|
||||
},
|
||||
{
|
||||
text: '警示灯/泛光',
|
||||
icon: '/static/images/lightImg/warn.png',
|
||||
value: '4',
|
||||
value: 4,
|
||||
key: 'ins_Side_Light'
|
||||
},
|
||||
{
|
||||
text: '关闭',
|
||||
icon: '/static/images/lightImg/closeLight.png',
|
||||
value: '5',
|
||||
value: 5,
|
||||
key: 'ins_Side_Light'
|
||||
}
|
||||
];
|
||||
@ -1418,13 +1411,16 @@
|
||||
this.dic.actionSheets = [item, item1, item3];
|
||||
},
|
||||
SOSToggle() {
|
||||
debugger;
|
||||
if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') {
|
||||
|
||||
MsgError('无操作权限', '确定', these);
|
||||
return;
|
||||
}
|
||||
let val = 1;
|
||||
if (this.formData.sta_ShakeBit === 1) {
|
||||
if (this.formData.sta_ShakeBit == 3) {
|
||||
val = 0;
|
||||
} else if (this.formData.sta_ShakeBit == 1) {
|
||||
val = 0;
|
||||
}
|
||||
|
||||
@ -1438,22 +1434,22 @@
|
||||
console.error("出现错误", ex)
|
||||
});
|
||||
}
|
||||
let msg=val==1?'确定开启声光报警':'确定关闭声光报警';
|
||||
|
||||
showPop({
|
||||
message: msg,
|
||||
iconUrl: "/static/images/670/sgActive.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonText: '确定',
|
||||
buttonTextColor: '#232323de',
|
||||
showCancel: true,
|
||||
buttonCancelText: '取消',
|
||||
okCallback: send
|
||||
}, these);
|
||||
|
||||
|
||||
|
||||
let msg = val == 1 ? '确定开启声光报警' : '确定关闭声光报警';
|
||||
|
||||
showPop({
|
||||
message: msg,
|
||||
iconUrl: "/static/images/670/sgActive.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonText: '确定',
|
||||
buttonTextColor: '#232323de',
|
||||
showCancel: true,
|
||||
buttonCancelText: '取消',
|
||||
okCallback: send
|
||||
}, these);
|
||||
|
||||
|
||||
|
||||
},
|
||||
laserToggle() {
|
||||
if (!this.permissions.includes('2') && this.Status.apiType !== 'listA') {
|
||||
@ -1508,6 +1504,7 @@
|
||||
let key = li.key.replace(/ins_/g, 'sta_');
|
||||
this.formData[key] = li.value;
|
||||
this.setBleFormData();
|
||||
this.formData.sta_brightness = 100;
|
||||
}).catch((ex) => {
|
||||
console.error("出现错误", ex)
|
||||
});
|
||||
@ -1674,11 +1671,14 @@
|
||||
}, 0);
|
||||
},
|
||||
sendMsg() {
|
||||
debugger;
|
||||
if (!this.permissions.includes('4') && this.Status.apiType !== 'listA') {
|
||||
MsgError('无操作权限', '确定', these);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this.formData.sendMsg.padStart(16, ' ');
|
||||
|
||||
this.formData.textLines = [this.formData.sendMsg.slice(0, 8), this.formData.sendMsg.slice(8, 16)];
|
||||
@ -1907,11 +1907,13 @@
|
||||
},
|
||||
getDevice: function() {
|
||||
|
||||
console.log("LinkedList=", ble.data.LinkedList);
|
||||
console.log("this.device=", this.device);
|
||||
// console.log("LinkedList=", ble.data.LinkedList);
|
||||
// console.log("this.device=", this.device);
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
if(v.macAddress == these.device.deviceMac){
|
||||
if(!this.formData.deviceId){this.formData.deviceId=v.deviceId};
|
||||
if (v.macAddress == these.device.deviceMac) {
|
||||
if (!this.formData.deviceId) {
|
||||
this.formData.deviceId = v.deviceId
|
||||
};
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@ -1987,10 +1989,17 @@
|
||||
keys.forEach(key => {
|
||||
this.formData[key] = data[key];
|
||||
});
|
||||
|
||||
this.$set(this.dic.actionSheets[0], 'value', this.formData.sta_LightGrade);
|
||||
this.$set(this.dic.actionSheets[1], 'value', this.formData.sta_Side_Light);
|
||||
|
||||
this.setBleFormData();
|
||||
},
|
||||
|
||||
|
||||
setBleFormData() {
|
||||
if (!ble) {
|
||||
return;
|
||||
}
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
if (v.deviceId == these.formData.deviceId) {
|
||||
v.formData = these.formData;
|
||||
@ -2078,11 +2087,37 @@
|
||||
}, 1000);
|
||||
|
||||
});
|
||||
},
|
||||
bleStatuToggle() {
|
||||
let f = this.getDevice();
|
||||
if (!f) {
|
||||
this.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
if (this.formData.bleStatu === true) {
|
||||
this.formData.bleStatu = 'dicconnect';
|
||||
ble.disconnectDevice(f.deviceId).finally(r => {
|
||||
this.formData.bleStatu = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.formData.bleStatu === false || this.formData.bleStatu === 'err') {
|
||||
this.formData.bleStatu = 'connecting';
|
||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
|
||||
these.formData.bleStatu = true;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
gotoMap() {
|
||||
let promise = lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData.sta_latitude);
|
||||
promise.then(lnglat => {
|
||||
|
||||
|
||||
this.detailData.longitude = lnglat[0];
|
||||
this.detailData.latitude = lnglat[1];
|
||||
uni.navigateTo({
|
||||
@ -2097,7 +2132,7 @@
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
proDetail: function(pgetpe) {
|
||||
|
||||
@ -2914,4 +2949,20 @@
|
||||
text-indent: 10rpx;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.hanleng {
|
||||
color: #66CCFF;
|
||||
}
|
||||
|
||||
.re {
|
||||
color: #FFB74D
|
||||
}
|
||||
|
||||
.yanRe {
|
||||
color: #F57C00;
|
||||
}
|
||||
|
||||
.kuRe {
|
||||
color: #B71C1C;
|
||||
}
|
||||
</style>
|
||||
@ -7,14 +7,14 @@
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.sta_PowerPercent}}%</view>
|
||||
<view class="smallTxt">电量</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.sta_charge?dic.sta_charge[formData.sta_charge+'']:"未充电" }}
|
||||
</view>
|
||||
|
||||
@ -28,14 +28,14 @@
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.battary}}%</view>
|
||||
<view class="smallTxt">电量</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.xuhang}}</view>
|
||||
<view class="smallTxt">续航时间</view>
|
||||
|
||||
@ -29,14 +29,14 @@
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.battary}}%</view>
|
||||
<view class="smallTxt">电量</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.xuhang}}</view>
|
||||
<view class="smallTxt">续航时间</view>
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
</view>
|
||||
<view>
|
||||
<view class="battery-v1">
|
||||
<image src="/static/images/common/dl.png" class="dlIMG"></image>
|
||||
<image src="/static/images/common/battry.png" class="dlIMG"></image>
|
||||
<view>
|
||||
<view class="battery-v2"
|
||||
:style="{ color: deviceInfo.batteryPercentage < 20 ? '#FF0000' : '' }">
|
||||
@ -29,7 +29,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="battery-v1">
|
||||
<image src="/static/images/common/nz.png" class="dlIMG" mode="aspectFit"></image>
|
||||
<image src="/static/images/common/time.png" class="dlIMG" mode="aspectFit"></image>
|
||||
<view>
|
||||
<view class="battery-v2">{{ deviceInfo.batteryRemainingTime || '0' }}分钟</view>
|
||||
<view class="battery-v3">续航时间</view>
|
||||
@ -54,7 +54,7 @@
|
||||
</view>
|
||||
<view class="info-row" v-if="itemInfo.deviceMac" @click="bleStatuToggle">
|
||||
<text class="info-label">蓝牙状态</text>
|
||||
<text class="info-value status-running" >
|
||||
<text class="info-value status-running" :class="formData.bleStatu?'green':'red'" >
|
||||
{{getbleStatu}}
|
||||
</text>
|
||||
</view>
|
||||
@ -115,6 +115,17 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="mode-v1" :class="{'active':itemInfo.alarmStatus===1 || itemInfo.alarmStatus==='1'}" >
|
||||
<view class="mode-v2" @click="warnToggle">
|
||||
<image v-show="itemInfo.alarmStatus!=1" src="/static/images/common/sg.png" class="setIMG" mode="aspectFit"></image>
|
||||
<image v-show="itemInfo.alarmStatus==1" src="/static/images/common/sgActive.png" class="setIMG" mode="aspectFit"></image>
|
||||
<view>
|
||||
<view class="battery-v2">{{itemInfo.alarmStatus==1?'解除报警':'强制报警'}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="mode-v1" v-if="hasPermission('3')">
|
||||
<view class="mode-v2" @click="uploadStartup">
|
||||
<image src="/static/images/common/path7.png" class="setIMG" mode="aspectFit"></image>
|
||||
@ -273,9 +284,16 @@
|
||||
<!-- 解除报警 -->
|
||||
<CustomPopup v-if="popupType === 'cancel'" :show="showPopupFlag"
|
||||
popupBorder="1rpx solid rgba(224, 52, 52, 0.3)" :message="popupMessage"
|
||||
icon="/static/images/6170/svg.png" :confirm-text="popupConfirmText" :show-cancel="false"
|
||||
icon="/static/images/6170/svg.png" :confirm-text="popupConfirmText" :show-cancel="true"
|
||||
@confirm="onPopupConfirmPolice" confirmBtnBg="rgba(224, 52, 52, 1)" confirmBtnColor="#fff" />
|
||||
|
||||
|
||||
<!-- 强制报警 -->
|
||||
<CustomPopup v-if="popupType === 'openWarn'" :show="showPopupFlag"
|
||||
popupBorder="1rpx solid rgba(224, 52, 52, 0.3)" :message="popupMessage"
|
||||
icon="/static/images/6170/svg.png" :confirm-text="popupConfirmText" :show-cancel="true"
|
||||
@confirm="OpenWarn(1)" confirmBtnBg="rgba(224, 52, 52, 1)" confirmBtnColor="#fff" />
|
||||
|
||||
|
||||
<MsgBox ref="msgPop" />
|
||||
<global-loading ref="loading" />
|
||||
</view>
|
||||
@ -405,7 +423,7 @@
|
||||
Status: {
|
||||
pageHide: null
|
||||
},
|
||||
inteval: 120
|
||||
inteval: 1000
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -461,8 +479,7 @@
|
||||
},
|
||||
getDevice: function() {
|
||||
if (ble) {
|
||||
console.log("LinkedList=", ble.data.LinkedList);
|
||||
console.log("this.device=", this.itemInfo);
|
||||
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
if (v.macAddress == this.itemInfo.deviceMac) {
|
||||
if (!this.formData.deviceId) {
|
||||
@ -926,6 +943,7 @@
|
||||
|
||||
|
||||
},
|
||||
|
||||
// 激光确认框提交
|
||||
handleBtn() {
|
||||
|
||||
@ -1561,16 +1579,69 @@
|
||||
// 强制报警()
|
||||
handlePolice() {
|
||||
this.popupType = 'cancel';
|
||||
this.popupMessage = '确认要解除所选设备的报警状态';
|
||||
this.popupMessage = '确认解除报警状态';
|
||||
this.showPopupFlag = true;
|
||||
// this.popupConfirmText="";
|
||||
},
|
||||
OpenWarn(val){//开启/解除强制报警
|
||||
const topic = `B/${this.itemInfo.deviceImei}`;
|
||||
let message={"instruct":[7,val,0,0,0,0]};
|
||||
message=JSON.stringify(message);
|
||||
|
||||
let flag=this.mqttClient.publish(topic, message, {
|
||||
qos: 1
|
||||
});
|
||||
if(flag){
|
||||
this.itemInfo.alarmStatus=val;
|
||||
}
|
||||
|
||||
this.showPopupFlag = false;
|
||||
},
|
||||
warnToggle(){
|
||||
if(this.itemInfo.alarmStatus==1){
|
||||
this.popupType = 'cancel';
|
||||
this.popupMessage = '确认解除报警状态';
|
||||
|
||||
}else{
|
||||
this.popupType = 'openWarn';
|
||||
this.popupMessage = '确认开启报警状态';
|
||||
|
||||
}
|
||||
this.showPopupFlag = true;
|
||||
// this.popupConfirmText="开启";
|
||||
// let val=1;
|
||||
// let msg="确认开启强制报警?";
|
||||
// if(this.itemInfo.alarmStatus==1){
|
||||
// val=0;
|
||||
// msg="确认解除强制报警?";
|
||||
// }
|
||||
|
||||
// let mqSend=()=>{
|
||||
// const topic = `B/${this.itemInfo.deviceImei}`;
|
||||
// let message={"instruct":[7,val,0,0,0,0]};
|
||||
// message=JSON.stringify(message);
|
||||
|
||||
// let flag=this.mqttClient.publish(topic, message, {
|
||||
// qos: 1
|
||||
// });
|
||||
// if(flag){
|
||||
// this.itemInfo.alarmStatus=val;
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
// 解除报警逻辑
|
||||
async onPopupConfirmPolice() {
|
||||
if (this.deviceInfo.onlineStatus !== 1) {
|
||||
uni.showToast({
|
||||
title: '设备已离线',
|
||||
icon: 'none'
|
||||
});
|
||||
// uni.showToast({
|
||||
// title: '设备已离线',
|
||||
// icon: 'none'
|
||||
// });
|
||||
this.OpenWarn(0);//走mq直发
|
||||
return;
|
||||
}
|
||||
this.isPolling = true; // 标记开始轮询
|
||||
@ -1595,8 +1666,10 @@
|
||||
title: registerRes.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
this.itemInfo.alarmStatus=0;
|
||||
// 4. 获取设备状态FunctionAccessBatchStatusRule 批量
|
||||
let deviceImei = this.itemInfo.deviceImei
|
||||
let typeName = this.itemInfo.typeName
|
||||
@ -2210,6 +2283,11 @@
|
||||
width: 47%;
|
||||
display: flex;
|
||||
text-align: center;
|
||||
box-sizing: border-box;
|
||||
border: 1rpx solid #00000000;
|
||||
}
|
||||
.mode-v1.active{
|
||||
border:1rpx solid #bbe600 !important;
|
||||
}
|
||||
|
||||
.mode-v2 {
|
||||
|
||||
@ -6,14 +6,14 @@
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.battary}}%</view>
|
||||
<view class="smallTxt">电量</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.xuhang}}</view>
|
||||
<view class="smallTxt">续航时间</view>
|
||||
|
||||
@ -27,14 +27,14 @@
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.battary}}%</view>
|
||||
<view class="smallTxt">电量</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.xuhang}}</view>
|
||||
<view class="smallTxt">续航时间</view>
|
||||
|
||||
@ -22,14 +22,14 @@
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.battary}}%</view>
|
||||
<view class="smallTxt">电量</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.xuhang}}</view>
|
||||
<view class="smallTxt">续航时间</view>
|
||||
|
||||
@ -26,14 +26,14 @@
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.battary}}%</view>
|
||||
<view class="smallTxt">电量</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
|
||||
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.xuhang}}</view>
|
||||
<view class="smallTxt">续航时间</view>
|
||||
|
||||
@ -185,7 +185,7 @@
|
||||
},
|
||||
onHide: function() {
|
||||
this.Status.isPageHidden = true;
|
||||
ble.StopSearch();
|
||||
if (ble) ble.StopSearch();
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
@ -205,7 +205,6 @@
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
debugger;
|
||||
eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
eventChannel.on('detailData', function(rec) {
|
||||
@ -351,11 +350,10 @@
|
||||
// console.log("+++ 发现新设备,准备添加到列表:", JSON.stringify(device));
|
||||
|
||||
if (these.device && these.device.bluetoothName && device.name) {
|
||||
if (these.device.bluetoothName === device.name || (device.name && device.name
|
||||
.indexOf(these
|
||||
.device.bluetoothName) > -1) || (device.name && this.device
|
||||
.bluetoothName.indexOf(
|
||||
device.name) > -1)) {
|
||||
const bn = these.device.bluetoothName;
|
||||
if (these.device.bluetoothName === device.name ||
|
||||
(device.name.indexOf(bn) > -1) ||
|
||||
(bn.indexOf(device.name) > -1)) {
|
||||
device.isTarget = true;
|
||||
}
|
||||
}
|
||||
@ -530,7 +528,7 @@
|
||||
|
||||
ble.StartSearch().then(result => {
|
||||
// console.log("开始搜索成功", result);
|
||||
|
||||
these.Status.BottomMenu.show=false;
|
||||
}).catch(err => {
|
||||
console.error("开始搜索失败:", err);
|
||||
if (err.code === 10001) {
|
||||
@ -582,6 +580,9 @@
|
||||
ble.showBlueSetting(false);
|
||||
},
|
||||
DeviceVerdict(deviceId) { //判断是否是目标设备
|
||||
if (these.Status.isPageHidden) {
|
||||
return;
|
||||
}
|
||||
console.log("deviceid=", deviceId);
|
||||
console.log("these.device=", these.device)
|
||||
if (these.device) { //从设备详情过来的,回设备详情去
|
||||
@ -618,6 +619,9 @@
|
||||
}
|
||||
//找到目标设备的处理方法
|
||||
let deviceOK = () => {
|
||||
if (these.Status.isPageHidden) {
|
||||
return;
|
||||
}
|
||||
hideLoading(these);
|
||||
|
||||
eventChannel.emit('BindOver', these.device);
|
||||
@ -629,7 +633,7 @@
|
||||
|
||||
if (f && f.macAddress) {
|
||||
|
||||
if (!this.device.deviceMac) { //走服务端验证
|
||||
if (!these.device || !these.device.deviceMac) { //走服务端验证
|
||||
console.error("走服务端验证")
|
||||
request({
|
||||
url: '/app/device/getDeviceInfoByDeviceMac',
|
||||
@ -779,6 +783,9 @@
|
||||
|
||||
execLink().then((res) => {
|
||||
console.log("res=", res);
|
||||
if(this.Status.isPageHidden){
|
||||
return;
|
||||
}
|
||||
linkCallback(res);
|
||||
}).catch(ex => {
|
||||
console.error("ex=", ex)
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
<view class="scanPanel center">
|
||||
<image @click.stop="scan" class="img" src="/static/images/common/scan.png" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="txt">
|
||||
<view class="txt" @click.stop="scan">
|
||||
对准二维码进行扫描
|
||||
</view>
|
||||
|
||||
@ -284,9 +284,10 @@
|
||||
.btnOK {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-family: 'PingFang SC';
|
||||
font-size: 30rpx;
|
||||
font-size: 40rpx;
|
||||
font-weight: 400;
|
||||
letter-spacing: 5rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.btnOK.active {
|
||||
|
||||
@ -363,7 +363,7 @@
|
||||
}
|
||||
//统一通信协议方法
|
||||
let CommonSend = () => {
|
||||
let json=JSON.stringify({ins_ShakeBit:1});
|
||||
let json=JSON.stringify({ins_ShakeBit:isAlarming?1:0});
|
||||
for (let i = 0; i < deviceImeiList.length; i++) {
|
||||
let imei = deviceImeiList[i];
|
||||
mq.sendData("B/"+imei,json,false);
|
||||
|
||||
@ -18,13 +18,10 @@
|
||||
<image src="/static/images/common/more.png" mode="aspectFit" class="more"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="sendFlex"
|
||||
v-show="showSendFlex"
|
||||
>
|
||||
<view class="sendFlex" v-show="showSendFlex">
|
||||
<view class="callpolice" @click="callpolice" v-show="showWarn">报警</view>
|
||||
<view class="Sendmessage" @click="location" v-show="showMap">位置</view>
|
||||
<view class="Sendmessage" @click="handleSend"
|
||||
v-show="ShowSendmessage">发送信息</view>
|
||||
<view class="Sendmessage" @click="handleSend" v-show="ShowSendmessage">发送信息</view>
|
||||
</view>
|
||||
|
||||
<mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption"
|
||||
@ -159,22 +156,22 @@
|
||||
components: {
|
||||
MescrollUni
|
||||
},
|
||||
computed:{
|
||||
showSendFlex(){
|
||||
computed: {
|
||||
showSendFlex() {
|
||||
// return this.activeTab && this.activeTab.id !== ''&& (this.activeTabInfo.communicationMode==0 || this.activeTabInfo.communicationMode==2);
|
||||
if(this.showMap || this.ShowSendmessage || this.showWarn){
|
||||
if (this.showMap || this.ShowSendmessage || this.showWarn) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
ShowSendmessage(){
|
||||
return this.dic.showMsgTypes.indexOf(this.activeTabInfo.typeName)>-1
|
||||
ShowSendmessage() {
|
||||
return this.dic.showMsgTypes.indexOf(this.activeTabInfo.typeName) > -1
|
||||
},
|
||||
showMap(){
|
||||
return this.dic.showMapTypes.indexOf(this.activeTabInfo.typeName)>-1
|
||||
showMap() {
|
||||
return this.dic.showMapTypes.indexOf(this.activeTabInfo.typeName) > -1
|
||||
},
|
||||
showWarn(){
|
||||
return this.dic.showCallPolice.indexOf(this.activeTabInfo.typeName)>-1
|
||||
showWarn() {
|
||||
return this.dic.showCallPolice.indexOf(this.activeTabInfo.typeName) > -1
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@ -254,10 +251,11 @@
|
||||
deviceName: "", //重命名
|
||||
activeTabInfo: '',
|
||||
dic: {
|
||||
showMsgTypes: ['BJQ6170', 'HBY210', 'HBY670', 'BJQ6075', 'BJQ6075J'],//需要发送消息的类型
|
||||
showMapTypes:['BJQ6170','HBY210','HBY670','BJQ6075','HBY018A','HBY100-J','BJQ6075J','HBY008A','HBY100-Y'],//需要显示地图的类型
|
||||
showCallPolice:['BJQ6170','HBY210','HBY670','BJQ6075','HBY018A','HBY100-J','BJQ6075J','HBY008A','HBY100-Y']//需要发送报警的类型
|
||||
}
|
||||
showMsgTypes: ['BJQ6170', 'HBY210', 'HBY670', 'BJQ6075', 'BJQ6075J'], //需要发送消息的类型
|
||||
showMapTypes: ['BJQ6170', 'HBY210', 'HBY670', 'BJQ6075', 'HBY018A', 'HBY100-J', 'BJQ6075J', 'HBY008A','HBY100-Y'], //需要显示地图的类型
|
||||
showCallPolice: ['BJQ6170', 'HBY210', 'HBY670', 'BJQ6075', 'HBY018A', 'HBY100-J', 'BJQ6075J','HBY008A', 'HBY100-Y'] //需要发送报警的类型
|
||||
},
|
||||
isPageShow: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -299,8 +297,11 @@
|
||||
this.updateBleStatu();
|
||||
},
|
||||
bleStateRecovery() {
|
||||
console.log("蓝牙适配器恢复可用,重连断开的设备");
|
||||
ble.linkAllDevices();
|
||||
if (this.isPageShow) {
|
||||
console.log("蓝牙适配器恢复可用,重连断开的设备");
|
||||
ble.linkAllDevices();
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
bleBreak(res) {
|
||||
@ -738,8 +739,11 @@
|
||||
.filter(Boolean);
|
||||
},
|
||||
},
|
||||
onHide() {
|
||||
this.isPageShow = false;
|
||||
},
|
||||
onShow() {
|
||||
|
||||
this.isPageShow = true;
|
||||
if (ble) {
|
||||
//因为vue视图只能后退不能隐藏后再显示
|
||||
//所以回到首页后将其他所有页面的订阅都删除
|
||||
|
||||
@ -77,6 +77,8 @@
|
||||
import {
|
||||
Logout
|
||||
} from '@/api/common/login.js'
|
||||
import bleTool from '@/utils/BleHelper.js';
|
||||
var ble=null;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -87,6 +89,7 @@
|
||||
},
|
||||
onLoad() {
|
||||
var these=this;
|
||||
ble=bleTool.getBleTool();
|
||||
uni.getSystemInfo({
|
||||
success(res) {
|
||||
if(res.uniPlatform=='app'){
|
||||
@ -139,7 +142,12 @@
|
||||
uni.showToast({
|
||||
title: '退出成功',
|
||||
icon: 'success'
|
||||
})
|
||||
});
|
||||
if(ble){
|
||||
ble.StopSearch().catch(ex => {});
|
||||
ble.disconnectDevice().catch(ex => {});
|
||||
}
|
||||
|
||||
uni.reLaunch({
|
||||
url: '/pages/common/login/index'
|
||||
});
|
||||
|
||||
|
Before Width: | Height: | Size: 268 B After Width: | Height: | Size: 268 B |
Binary file not shown.
|
Before Width: | Height: | Size: 244 B |
Binary file not shown.
|
Before Width: | Height: | Size: 382 B |
|
Before Width: | Height: | Size: 321 B After Width: | Height: | Size: 321 B |
@ -1,536 +0,0 @@
|
||||
import request from '@/utils/request'
|
||||
import Common from '@/utils/Common.js'
|
||||
|
||||
// ================== 钃濈墮鍗忚灏佽绫?==================
|
||||
class HBY100JProtocol {
|
||||
constructor() {
|
||||
this.deviceId = ''; // 4G 鎺ュ彛鎵€闇€鐨?deviceId
|
||||
this.isBleConnected = false;
|
||||
this.bleDeviceId = ''; // 灏忕▼搴?APP涓繛鎺ヨ摑鐗欑殑 deviceId
|
||||
|
||||
// 钃濈墮鏈嶅姟涓庣壒寰佸€?UUID
|
||||
this.SERVICE_UUID = '0000AE30-0000-1000-8000-00805F9B34FB'; // 0xAE30
|
||||
this.WRITE_UUID = '0000AE03-0000-1000-8000-00805F9B34FB'; // 0xAE03
|
||||
this.NOTIFY_UUID = '0000AE02-0000-1000-8000-00805F9B34FB'; // 0xAE02
|
||||
|
||||
this.onNotifyCallback = null;
|
||||
this._fileResponseResolve = null; // 鏂囦欢涓婁紶鏃剁瓑寰呰澶?FB 05 鍝嶅簲
|
||||
}
|
||||
|
||||
// 绛夊緟璁惧 FB 05 鍝嶅簲锛岃秴鏃跺悗浠?resolve锛堣澶囧彲鑳戒笉鍝嶅簲姣忓寘锛? waitForFileResponse(timeoutMs = 2000) {
|
||||
return new Promise((resolve) => {
|
||||
const timer = setTimeout(() => {
|
||||
if (this._fileResponseResolve) {
|
||||
this._fileResponseResolve = null;
|
||||
resolve(null);
|
||||
}
|
||||
}, timeoutMs);
|
||||
this._fileResponseResolve = (result) => {
|
||||
clearTimeout(timer);
|
||||
this._fileResponseResolve = null;
|
||||
resolve(result);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
setBleConnectionStatus(status, bleDeviceId = '') {
|
||||
this.isBleConnected = status;
|
||||
if (bleDeviceId) {
|
||||
this.bleDeviceId = bleDeviceId;
|
||||
}
|
||||
}
|
||||
|
||||
onNotify(callback) {
|
||||
this.onNotifyCallback = callback;
|
||||
}
|
||||
|
||||
parseBleData(buffer) {
|
||||
const view = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
||||
if (view.length < 3) return null;
|
||||
|
||||
const header = view[0];
|
||||
const tail = view[view.length - 1];
|
||||
|
||||
// 5.1 杩炴帴钃濈墮璁惧涓诲姩涓婃姤 MAC 鍦板潃: FC + 6瀛楄妭MAC + FF
|
||||
if (header === 0xFC && tail === 0xFF && view.length >= 8) {
|
||||
const macBytes = view.slice(1, 7);
|
||||
const macAddress = Array.from(macBytes).map(b => b.toString(16).padStart(2, '0').toUpperCase()).join(':');
|
||||
const result = { type: 'mac', macAddress };
|
||||
console.log('[100J-钃濈墮] 璁惧涓婃姤MAC:', macAddress, '鍘熷:', Array.from(view).map(b => b.toString(16).padStart(2, '0').toUpperCase()).join(' '));
|
||||
if (this.onNotifyCallback) this.onNotifyCallback(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (header !== 0xFB || tail !== 0xFF) return null; // 鏍¢獙澶村熬
|
||||
|
||||
const funcCode = view[1];
|
||||
const data = view.slice(2, view.length - 1);
|
||||
const hexStr = Array.from(view).map(b => b.toString(16).padStart(2, '0').toUpperCase()).join(' ');
|
||||
|
||||
let result = { funcCode, rawData: data };
|
||||
|
||||
switch (funcCode) {
|
||||
case 0x01: result.resetType = data[0]; break;
|
||||
case 0x02: break;
|
||||
case 0x03:
|
||||
// 5.4 鑾峰彇璁惧浣嶇疆锛氱粡搴?B+绾害8B 鍧囦负 float64锛岃澶囦富鍔ㄤ笂鎶?1鍒嗛挓)涓庝富鍔ㄦ煡璇㈠搷搴旀牸寮忕浉鍚? if (data.length >= 16) {
|
||||
const lonBuf = new ArrayBuffer(8);
|
||||
const latBuf = new ArrayBuffer(8);
|
||||
new Uint8Array(lonBuf).set(data.slice(0, 8));
|
||||
new Uint8Array(latBuf).set(data.slice(8, 16));
|
||||
result.longitude = new DataView(lonBuf).getFloat64(0, true);
|
||||
result.latitude = new DataView(latBuf).getFloat64(0, true);
|
||||
}
|
||||
break;
|
||||
case 0x05:
|
||||
// 05: 鏂囦欢鏇存柊鍝嶅簲 FB 05 [fileType] [status] FF锛宻tatus: 1=鎴愬姛 2=澶辫触
|
||||
if (data.length >= 1) result.fileType = data[0];
|
||||
if (data.length >= 2) result.fileStatus = data[1]; // 1=Success, 2=Failure
|
||||
if (this._fileResponseResolve) this._fileResponseResolve(result);
|
||||
break;
|
||||
case 0x04:
|
||||
// 5.5 鑾峰彇璁惧鐢垫簮鐘舵€? 鐢垫睜瀹归噺8B + 鐢靛帇8B + 鐧惧垎姣?B + 杞﹁浇鐢垫簮1B + 缁埅鏃堕棿2B(鍒嗛挓)
|
||||
if (data.length >= 20) {
|
||||
result.batteryPercentage = data[16];
|
||||
result.vehiclePower = data[17];
|
||||
result.batteryRemainingTime = data[18] | (data[19] << 8); // 灏忕搴忥紝鍗曚綅鍒嗛挓
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
// 06: 璇煶鎾姤鍝嶅簲
|
||||
result.voiceBroadcast = data[0];
|
||||
break;
|
||||
case 0x09:
|
||||
// 09: 淇敼闊抽噺鍝嶅簲
|
||||
result.volume = data[0];
|
||||
break;
|
||||
case 0x0A:
|
||||
// 0A: 鐖嗛棯妯″紡鍝嶅簲
|
||||
result.strobeEnable = data[0];
|
||||
result.strobeMode = data[1];
|
||||
break;
|
||||
case 0x0B:
|
||||
// 0B: 淇敼璀︾ず鐏垎闂鐜囧搷搴? result.strobeFrequency = data[0];
|
||||
break;
|
||||
case 0x0C:
|
||||
// 0C: 寮哄埗澹板厜鎶ヨ鍝嶅簲
|
||||
result.alarmEnable = data[0];
|
||||
result.alarmMode = data[1];
|
||||
break;
|
||||
case 0x0D:
|
||||
// 0D: 璀︾ず鐏?LED 浜害璋冭妭鍝嶅簲
|
||||
result.redBrightness = data[0];
|
||||
result.blueBrightness = data[1];
|
||||
result.yellowBrightness = data[2];
|
||||
break;
|
||||
case 0x0E:
|
||||
// 0E: 鑾峰彇褰撳墠宸ヤ綔鏂瑰紡鍝嶅簲
|
||||
result.voiceBroadcast = data[0];
|
||||
result.alarmEnable = data[1];
|
||||
result.alarmMode = data[2];
|
||||
result.strobeEnable = data[3];
|
||||
result.strobeMode = data[4];
|
||||
result.strobeFrequency = data[5];
|
||||
result.volume = data[6];
|
||||
result.redBrightness = data[7];
|
||||
result.blueBrightness = data[8];
|
||||
result.yellowBrightness = data[9];
|
||||
break;
|
||||
}
|
||||
|
||||
const funcNames = { 0x01: '澶嶄綅', 0x02: '鍩虹淇℃伅', 0x03: '浣嶇疆', 0x04: '鐢垫簮鐘舵€?, 0x05: '鏂囦欢鏇存柊', 0x06: '璇煶鎾姤', 0x09: '闊抽噺', 0x0A: '鐖嗛棯妯″紡', 0x0B: '鐖嗛棯棰戠巼', 0x0C: '寮哄埗鎶ヨ', 0x0D: 'LED浜害', 0x0E: '宸ヤ綔鏂瑰紡' };
|
||||
const name = funcNames[funcCode] || ('0x' + funcCode.toString(16));
|
||||
console.log('[100J-钃濈墮] 璁惧鍝嶅簲 FB:', name, '瑙f瀽:', JSON.stringify(result), '鍘熷:', hexStr);
|
||||
|
||||
if (this.onNotifyCallback) {
|
||||
this.onNotifyCallback(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
sendBleData(funcCode, dataBytes = []) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!this.isBleConnected || !this.bleDeviceId) {
|
||||
return reject(new Error('钃濈墮鏈繛鎺?));
|
||||
}
|
||||
|
||||
const buffer = new ArrayBuffer(dataBytes.length + 3);
|
||||
const view = new Uint8Array(buffer);
|
||||
view[0] = 0xFA; // 鏁版嵁澶? view[1] = funcCode; // 鍔熻兘鐮? for (let i = 0; i < dataBytes.length; i++) {
|
||||
view[2 + i] = dataBytes[i];
|
||||
}
|
||||
view[view.length - 1] = 0xFF; // 缁撳熬
|
||||
const sendHex = Array.from(view).map(b => b.toString(16).padStart(2, '0').toUpperCase()).join(' ');
|
||||
console.log('[100J-钃濈墮] 涓嬪彂鎸囦护 FA:', '0x' + funcCode.toString(16).toUpperCase(), sendHex);
|
||||
|
||||
// 浣跨敤椤圭洰涓粺涓€鐨?BleHelper 鍙戦€佹暟鎹? import('@/utils/BleHelper.js').then(module => {
|
||||
const bleTool = module.default.getBleTool();
|
||||
bleTool.sendData(this.bleDeviceId, buffer, this.SERVICE_UUID, this.WRITE_UUID)
|
||||
.then(res => resolve(res))
|
||||
.catch(err => reject(err));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 绾摑鐗欐寚浠ゅ彂閫佹柟娉? deviceReset(type = 0) { return this.sendBleData(0x01, [type]); }
|
||||
getBasicInfo() { return this.sendBleData(0x02, []); }
|
||||
getLocation() { return this.sendBleData(0x03, []); }
|
||||
getPowerStatus() { return this.sendBleData(0x04, []); }
|
||||
setVoiceBroadcast(enable) { return this.sendBleData(0x06, [enable]); }
|
||||
setVolume(volume) { return this.sendBleData(0x09, [volume]); }
|
||||
setStrobeMode(enable, mode) { return this.sendBleData(0x0A, [enable, mode]); }
|
||||
setStrobeFrequency(frequency) { return this.sendBleData(0x0B, [frequency]); }
|
||||
setForceAlarm(enable, mode) { return this.sendBleData(0x0C, [enable, mode]); }
|
||||
setLightBrightness(red, blue = 0, yellow = 0) { return this.sendBleData(0x0D, [red, blue, yellow]); }
|
||||
getCurrentWorkMode() { return this.sendBleData(0x0E, []); }
|
||||
|
||||
// 0x05 鏂囦欢涓婁紶锛氬垎鐗囦紶杈擄紝鍗忚 FA 05 [fileType] [phase] [data...] FF
|
||||
// fileType: 1=璇煶 2=鍥剧墖 3=鍔ㄥ浘 4=OTA
|
||||
// phase: 0=寮€濮?1=鏁版嵁 2=缁撴潫
|
||||
// 姣忓寘鏈€澶у瓧鑺?钃濈墮锛欳HUNK_SIZE=500
|
||||
// 鏀寔 fileUrl(闇€缃戠粶涓嬭浇) 鎴?localPath(鏃犵綉缁滄椂鏈湴鏂囦欢)
|
||||
uploadVoiceFileBle(fileUrlOrLocalPath, fileType = 1, onProgress) {
|
||||
const CHUNK_SIZE = 500; // 姣忓寘鏈夋晥鏁版嵁锛屽弬鑰?6155 deviceDetail.vue
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!this.isBleConnected || !this.bleDeviceId) {
|
||||
return reject(new Error('钃濈墮鏈繛鎺?));
|
||||
}
|
||||
if (!fileUrlOrLocalPath) {
|
||||
return reject(new Error('缂哄皯鏂囦欢鍦板潃鎴栨湰鍦拌矾寰?));
|
||||
}
|
||||
const isLocalPath = !/^https?:\/\//i.test(fileUrlOrLocalPath);
|
||||
if (onProgress) onProgress(1);
|
||||
const readFromPath = (path) => {
|
||||
const doSend = (bytes) => {
|
||||
this._sendVoiceChunks(bytes, fileType, CHUNK_SIZE, onProgress)
|
||||
.then(resolve).catch(reject);
|
||||
};
|
||||
// App 绔?getFileSystemManager 鏈疄鐜帮紝鐩存帴鐢?plus.io.requestFileSystem+getFile
|
||||
readFromPathPlus(path, doSend, reject);
|
||||
};
|
||||
const readFileEntry = (entry, doSend, reject) => {
|
||||
entry.file((file) => {
|
||||
const reader = new plus.io.FileReader();
|
||||
reader.onloadend = (e) => {
|
||||
try {
|
||||
const buf = e.target.result;
|
||||
const bytes = new Uint8Array(buf);
|
||||
doSend(bytes);
|
||||
} catch (err) {
|
||||
console.error('[100J-钃濈墮] 璇诲彇ArrayBuffer寮傚父:', err);
|
||||
reject(err);
|
||||
}
|
||||
};
|
||||
reader.onerror = () => reject(new Error('璇诲彇鏂囦欢澶辫触'));
|
||||
reader.readAsArrayBuffer(file);
|
||||
}, (err) => reject(err));
|
||||
};
|
||||
const readFromPathPlus = (path, doSend, reject) => {
|
||||
if (typeof plus === 'undefined' || !plus.io) {
|
||||
console.error('[100J-钃濈墮] 褰撳墠鐜涓嶆敮鎸佹枃浠惰鍙?plus.io)');
|
||||
reject(new Error('褰撳墠鐜涓嶆敮鎸佹枃浠惰鍙?));
|
||||
return;
|
||||
}
|
||||
// _downloads/ 鐢?requestFileSystem+getFile锛堥伩鍏?resolveLocalFileSystemURL 鍗′綇锛? if (path && path.startsWith('_downloads/')) {
|
||||
const fileName = path.replace(/^_downloads\//, '');
|
||||
plus.io.requestFileSystem(plus.io.PUBLIC_DOWNLOADS, (fs) => {
|
||||
fs.root.getFile(fileName, {}, (entry) => readFileEntry(entry, doSend, reject), (err) => reject(err));
|
||||
}, (err) => reject(err));
|
||||
return;
|
||||
}
|
||||
// _doc/ 鐢?requestFileSystem(PRIVATE_DOC)锛岄€愮骇 getDirectory 鍐?getFile锛堝祵濂楄矾寰勫吋瀹癸級
|
||||
if (path && path.startsWith('_doc/')) {
|
||||
const relPath = path.replace(/^_doc\//, '');
|
||||
const parts = relPath.split('/');
|
||||
const fileName = parts.pop();
|
||||
const dirs = parts;
|
||||
plus.io.requestFileSystem(plus.io.PRIVATE_DOC, (fs) => {
|
||||
let cur = fs.root;
|
||||
const next = (i) => {
|
||||
if (i >= dirs.length) {
|
||||
cur.getFile(fileName, { create: false }, (entry) => readFileEntry(entry, doSend, reject), (err) => reject(err));
|
||||
return;
|
||||
}
|
||||
cur.getDirectory(dirs[i], { create: false }, (dir) => { cur = dir; next(i + 1); }, (err) => reject(err));
|
||||
};
|
||||
next(0);
|
||||
}, (err) => reject(err));
|
||||
return;
|
||||
}
|
||||
// 鍏朵粬璺緞鍏滃簳
|
||||
let resolvePath = path;
|
||||
if (path && path.startsWith('/') && !path.startsWith('file://')) resolvePath = 'file://' + path;
|
||||
plus.io.resolveLocalFileSystemURL(resolvePath, (entry) => readFileEntry(entry, doSend, reject), (err) => reject(err));
|
||||
};
|
||||
if (isLocalPath) {
|
||||
// 鏈湴璺緞锛氭棤缃戠粶鏃剁洿鎺ヨ鍙? readFromPath(fileUrlOrLocalPath);
|
||||
} else {
|
||||
// 缃戠粶 URL锛氫紭鍏堢敤 uni.request 鐩存帴鎷夊彇 ArrayBuffer锛堢被浼?100 璁惧锛屾棤鏂囦欢 IO锛夛紝澶辫触鍐嶈蛋 downloadFile
|
||||
let fetchUrl = fileUrlOrLocalPath;
|
||||
if (fetchUrl.startsWith('http://')) fetchUrl = 'https://' + fetchUrl.slice(7);
|
||||
uni.request({
|
||||
url: fetchUrl,
|
||||
method: 'GET',
|
||||
responseType: 'arraybuffer',
|
||||
timeout: 60000,
|
||||
success: (res) => {
|
||||
if (res.statusCode === 200 && res.data) {
|
||||
const bytes = res.data instanceof ArrayBuffer ? new Uint8Array(res.data) : new Uint8Array(res.data || []);
|
||||
if (bytes.length > 0) {
|
||||
const doSend = (b) => {
|
||||
this._sendVoiceChunks(b, fileType, CHUNK_SIZE, onProgress).then(resolve).catch(reject);
|
||||
};
|
||||
doSend(bytes);
|
||||
return;
|
||||
}
|
||||
}
|
||||
fallbackDownload();
|
||||
},
|
||||
fail: () => fallbackDownload()
|
||||
});
|
||||
const fallbackDownload = () => {
|
||||
uni.downloadFile({
|
||||
url: fetchUrl,
|
||||
success: (res) => {
|
||||
if (res.statusCode !== 200 || !res.tempFilePath) {
|
||||
reject(new Error('涓嬭浇澶辫触: ' + (res.statusCode || '鏃犺矾寰?)));
|
||||
return;
|
||||
}
|
||||
Common.moveFileToDownloads(res.tempFilePath).then((p) => readFromPath(p)).catch(() => readFromPath(res.tempFilePath));
|
||||
},
|
||||
fail: (err) => reject(err)
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_sendVoiceChunks(bytes, fileType, chunkSize, onProgress) {
|
||||
const total = bytes.length;
|
||||
const ft = (fileType & 0xFF) || 1;
|
||||
const DELAY_AFTER_START = 200; // 寮€濮嬪寘鍚庛€佺瓑璁惧鍝嶅簲鍚庡啀鍙戠殑缂撳啿(ms)
|
||||
const DELAY_PACKET = 200; // 鏁版嵁鍖呴棿寤舵椂(ms)锛岃澶囨敹涓嶅叏鏃堕€傚綋鍔犲ぇ
|
||||
const toHex = (arr) => Array.from(arr).map(b => b.toString(16).padStart(2, '0').toUpperCase()).join(' ');
|
||||
console.log('[100J-钃濈墮] 璇煶鏂囦欢鎬诲ぇ灏?', total, '瀛楄妭, fileType=', ft);
|
||||
if (onProgress) onProgress(0);
|
||||
const bleToolPromise = import('@/utils/BleHelper.js').then(m => m.default.getBleTool());
|
||||
const send = (dataBytes, label = '') => {
|
||||
const buf = new ArrayBuffer(dataBytes.length + 3);
|
||||
const v = new Uint8Array(buf);
|
||||
v[0] = 0xFA;
|
||||
v[1] = 0x05;
|
||||
for (let i = 0; i < dataBytes.length; i++) v[2 + i] = dataBytes[i];
|
||||
v[v.length - 1] = 0xFF;
|
||||
const hex = toHex(v);
|
||||
const preview = v.length <= 32 ? hex : hex.slice(0, 96) + '...';
|
||||
console.log(`[100J-钃濈墮] 鍙戦€?{label} 鍏?{v.length}瀛楄妭:`, preview);
|
||||
return bleToolPromise.then(ble => ble.sendData(this.bleDeviceId, buf, this.SERVICE_UUID, this.WRITE_UUID));
|
||||
};
|
||||
const delay = (ms) => new Promise(r => setTimeout(r, ms));
|
||||
// 寮€濮嬪寘: FA 05 [fileType] [phase=0] [size 4B LE] FF
|
||||
const startData = [ft, 0, total & 0xFF, (total >> 8) & 0xFF, (total >> 16) & 0xFF, (total >> 24) & 0xFF];
|
||||
const waitPromise = this.waitForFileResponse(1000);
|
||||
return send(startData, ' 寮€濮嬪寘')
|
||||
.then(() => { if (onProgress) onProgress(1); return waitPromise; })
|
||||
.then(() => { if (onProgress) onProgress(2); return delay(DELAY_AFTER_START); })
|
||||
.then(() => {
|
||||
let seq = 0;
|
||||
const sendNext = (offset) => {
|
||||
if (offset >= total) {
|
||||
return delay(DELAY_PACKET).then(() => send([ft, 2], ' 缁撴潫鍖?));
|
||||
}
|
||||
const chunk = bytes.slice(offset, Math.min(offset + chunkSize, total));
|
||||
const chunkData = [ft, 1, seq & 0xFF, (seq >> 8) & 0xFF, ...chunk];
|
||||
return send(chunkData, ` #${seq} 鏁版嵁鍖卄).then(() => {
|
||||
seq++;
|
||||
const pct = Math.round((offset + chunk.length) / total * 100);
|
||||
if (onProgress) onProgress(Math.min(99, Math.max(3, pct)));
|
||||
return delay(DELAY_PACKET).then(() => sendNext(offset + chunk.length));
|
||||
});
|
||||
};
|
||||
return sendNext(0);
|
||||
})
|
||||
.then(() => delay(DELAY_PACKET))
|
||||
.then(() => {
|
||||
if (onProgress) onProgress(100);
|
||||
return { code: 200, msg: '璇煶鏂囦欢宸查€氳繃钃濈墮涓婁紶' };
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ================== 鍏ㄥ眬鍗曚緥涓庣姸鎬佺鐞?==================
|
||||
const protocolInstance = new HBY100JProtocol();
|
||||
|
||||
// 鏆撮湶缁欓〉闈細鏇存柊钃濈墮杩炴帴鐘舵€?export function updateBleStatus(isConnected, bleDeviceId, deviceId) {
|
||||
protocolInstance.setBleConnectionStatus(isConnected, bleDeviceId);
|
||||
protocolInstance.deviceId = deviceId;
|
||||
console.log('[100J] 钃濈墮鐘舵€?', isConnected ? '宸茶繛鎺?鍚庣画鎸囦护璧拌摑鐗?' : '宸叉柇寮€(鍚庣画鎸囦护璧?G)', { bleDeviceId: bleDeviceId || '-', deviceId });
|
||||
}
|
||||
|
||||
// 鏆撮湶缁欓〉闈細瑙f瀽钃濈墮鎺ユ敹鍒扮殑鏁版嵁
|
||||
export function parseBleData(buffer) {
|
||||
return protocolInstance.parseBleData(buffer);
|
||||
}
|
||||
|
||||
// 鏆撮湶缁欓〉闈細钃濈墮杩炴帴鍚庝富鍔ㄦ媺鍙栫數婧愮姸鎬?鐢甸噺銆佺画鑸?
|
||||
export function fetchBlePowerStatus() {
|
||||
if (!protocolInstance.isBleConnected) return Promise.reject(new Error('钃濈墮鏈繛鎺?));
|
||||
console.log('[100J-钃濈墮] 鎷夊彇鐢垫簮鐘舵€?宸查€氳繃钃濈墮鍙戦€?FA 04 FF');
|
||||
return protocolInstance.getPowerStatus();
|
||||
}
|
||||
|
||||
// 鏆撮湶缁欓〉闈細钃濈墮杩炴帴鍚庝富鍔ㄦ媺鍙栧畾浣?浼樺厛钃濈墮锛岃澶囦篃浼氭瘡1鍒嗛挓涓诲姩涓婃姤)
|
||||
export function fetchBleLocation() {
|
||||
if (!protocolInstance.isBleConnected) return Promise.reject(new Error('钃濈墮鏈繛鎺?));
|
||||
console.log('[100J-钃濈墮] 鎷夊彇瀹氫綅 宸查€氳繃钃濈墮鍙戦€?FA 03 FF');
|
||||
return protocolInstance.getLocation();
|
||||
}
|
||||
|
||||
// 鏆撮湶缁欓〉闈細灏濊瘯閲嶈繛钃濈墮(浼樺厛绛栫暐锛氭柇绾垮悗鍙戞寚浠ゅ墠鍏堝皾璇曢噸杩?
|
||||
export function tryReconnectBle(timeoutMs = 2500) {
|
||||
if (protocolInstance.isBleConnected) return Promise.resolve(true);
|
||||
if (!protocolInstance.bleDeviceId) return Promise.resolve(false);
|
||||
return new Promise((resolve) => {
|
||||
import('@/utils/BleHelper.js').then(module => {
|
||||
const bleTool = module.default.getBleTool();
|
||||
const deviceId = protocolInstance.bleDeviceId;
|
||||
const f = bleTool.data.LinkedList.find(v => v.deviceId === deviceId);
|
||||
if (!f) {
|
||||
resolve(false);
|
||||
return;
|
||||
}
|
||||
const svc = f.writeServiceId || '0000AE30-0000-1000-8000-00805F9B34FB';
|
||||
const write = f.wirteCharactId || '0000AE03-0000-1000-8000-00805F9B34FB';
|
||||
const notify = f.notifyCharactId || '0000AE02-0000-1000-8000-00805F9B34FB';
|
||||
const timer = setTimeout(() => {
|
||||
resolve(protocolInstance.isBleConnected);
|
||||
}, timeoutMs);
|
||||
console.log('[100J] 钃濈墮浼樺厛锛氬皾璇曢噸杩?, deviceId);
|
||||
bleTool.LinkBlue(deviceId, svc, write, notify, 1).then(() => {
|
||||
clearTimeout(timer);
|
||||
protocolInstance.setBleConnectionStatus(true, deviceId);
|
||||
console.log('[100J] 钃濈墮閲嶈繛鎴愬姛');
|
||||
resolve(true);
|
||||
}).catch(() => {
|
||||
clearTimeout(timer);
|
||||
resolve(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// ================== API 鎺ュ彛 (鎷︽埅灞? ==================
|
||||
|
||||
// 鑾峰彇璇煶绠$悊鍒楄〃
|
||||
export function deviceVoliceList(params) {
|
||||
return request({
|
||||
url: `/app/video/queryAudioFileList`,
|
||||
method: 'get',
|
||||
data:params
|
||||
})
|
||||
}
|
||||
// 閲嶅懡鍚?export function videRenameAudioFile(data) {
|
||||
return request({
|
||||
url: `/app/video/renameAudioFile`,
|
||||
method: 'post',
|
||||
data:data
|
||||
})
|
||||
}
|
||||
// 鍒犻櫎璇煶鏂囦欢鍒楄〃
|
||||
export function deviceDeleteAudioFile(params) {
|
||||
return request({
|
||||
url: `/app/video/deleteAudioFile`,
|
||||
method: 'get',
|
||||
data:params
|
||||
})
|
||||
}
|
||||
|
||||
// 鏇存柊璇煶/浣跨敤璇煶锛氳摑鐗欎紭鍏堬紝4G 鍏滃簳锛堜笉褰卞搷鍘熸湁 4G 闊抽涓嬪彂锛?// 鏈?fileUrl 鎴?localPath 涓旇摑鐗欏彲鐢ㄦ椂璧拌摑鐗欙紱鍚﹀垯鎴栬摑鐗欏け璐ユ椂璧?4G锛堜笌鍘熷厛閫昏緫涓€鑷达級
|
||||
export function deviceUpdateVoice(data) {
|
||||
const httpExec = () => request({
|
||||
url: `/app/hby100j/device/updateVoice`,
|
||||
method: 'post',
|
||||
data: { id: data.id }
|
||||
});
|
||||
const localPath = data.localPath;
|
||||
const fileUrl = data.fileUrl;
|
||||
const hasLocalPath = localPath && typeof localPath === 'string' && localPath.length > 0;
|
||||
const hasFileUrl = fileUrl && typeof fileUrl === 'string' && fileUrl.length > 0;
|
||||
const fileSource = hasLocalPath ? localPath : (hasFileUrl ? fileUrl : null);
|
||||
if (!fileSource) {
|
||||
return httpExec(); // 鏃犳枃浠舵簮锛氱洿鎺?4G锛堝師鏈夐€昏緫锛? }
|
||||
const bleExec = () => protocolInstance.uploadVoiceFileBle(fileSource, 1, data.onProgress);
|
||||
return execWithBleFirst(bleExec, httpExec, '璇煶鏂囦欢涓婁紶');
|
||||
}
|
||||
// 100J淇℃伅
|
||||
export function deviceDetail(id) {
|
||||
return request({
|
||||
url: `/app/hby100j/device/${id}`,
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
// 钃濈墮浼樺厛銆?G 鍏滃簳锛氭湭杩炴帴鏃跺皾璇曢噸杩烇紱钃濈墮澶辫触鏃跺洖閫€ 4G锛堜繚鎸佸師鏈?4G 閫氳涓嶅彉锛?function execWithBleFirst(bleExec, httpExec, logName) {
|
||||
const doBle = () => bleExec().then(res => ({ ...(res || {}), _channel: 'ble' }));
|
||||
const do4G = () => httpExec().then(res => { res._channel = '4g'; return res; });
|
||||
if (protocolInstance.isBleConnected) {
|
||||
return doBle().catch(() => { console.log('[100J] 钃濈墮澶辫触锛屽洖閫€4G'); return do4G(); });
|
||||
}
|
||||
return tryReconnectBle(2500).then(reconnected => {
|
||||
return reconnected ? doBle().catch(() => { console.log('[100J] 钃濈墮澶辫触锛屽洖閫€4G'); return do4G(); }) : do4G();
|
||||
});
|
||||
}
|
||||
|
||||
// 鐖嗛棯妯″紡
|
||||
export function deviceStrobeMode(data) {
|
||||
return execWithBleFirst(
|
||||
() => protocolInstance.setStrobeMode(data.enable, data.mode).then(() => ({ code: 200, msg: '鎿嶄綔鎴愬姛(钃濈墮)' })),
|
||||
() => request({ url: `/app/hby100j/device/strobeMode`, method: 'post', data }),
|
||||
'鐖嗛棯妯″紡'
|
||||
);
|
||||
}
|
||||
|
||||
// 寮哄埗鎶ヨ
|
||||
export function deviceForceAlarmActivation(data) {
|
||||
return execWithBleFirst(
|
||||
() => protocolInstance.setForceAlarm(data.voiceStrobeAlarm, data.mode).then(() => ({ code: 200, msg: '鎿嶄綔鎴愬姛(钃濈墮)' })),
|
||||
() => request({ url: `/app/hby100j/device/forceAlarmActivation`, method: 'post', data }),
|
||||
'寮哄埗鎶ヨ'
|
||||
);
|
||||
}
|
||||
|
||||
// 鐖嗛棯棰戠巼
|
||||
export function deviceStrobeFrequency(data) {
|
||||
return execWithBleFirst(
|
||||
() => protocolInstance.setStrobeFrequency(data.frequency).then(() => ({ code: 200, msg: '鎿嶄綔鎴愬姛(钃濈墮)' })),
|
||||
() => request({ url: `/app/hby100j/device/strobeFrequency`, method: 'post', data }),
|
||||
'鐖嗛棯棰戠巼'
|
||||
);
|
||||
}
|
||||
|
||||
// 鐏厜璋冭妭浜害
|
||||
export function deviceLightAdjustment(data) {
|
||||
return execWithBleFirst(
|
||||
() => protocolInstance.setLightBrightness(data.brightness, data.brightness, data.brightness).then(() => ({ code: 200, msg: '鎿嶄綔鎴愬姛(钃濈墮)' })),
|
||||
() => request({ url: `/app/hby100j/device/lightAdjustment`, method: 'post', data }),
|
||||
'鐏厜浜害'
|
||||
);
|
||||
}
|
||||
|
||||
// 璋冭妭闊抽噺
|
||||
export function deviceUpdateVolume(data) {
|
||||
return execWithBleFirst(
|
||||
() => protocolInstance.setVolume(data.volume).then(() => ({ code: 200, msg: '鎿嶄綔鎴愬姛(钃濈墮)' })),
|
||||
() => request({ url: `/app/hby100j/device/updateVolume`, method: 'post', data }),
|
||||
'璋冭妭闊抽噺'
|
||||
);
|
||||
}
|
||||
|
||||
// 璇煶鎾斁
|
||||
export function deviceVoiceBroadcast(data) {
|
||||
return execWithBleFirst(
|
||||
() => protocolInstance.setVoiceBroadcast(data.voiceBroadcast).then(() => ({ code: 200, msg: '鎿嶄綔鎴愬姛(钃濈墮)' })),
|
||||
() => request({ url: `/app/hby100j/device/voiceBroadcast`, method: 'post', data }),
|
||||
'璇煶鎾姤'
|
||||
);
|
||||
}
|
||||
@ -38,11 +38,10 @@ class BleHelper {
|
||||
if (linkedDevices && linkedDevices.length && linkedDevices.length > 0) {
|
||||
// console.log("111111", linkedDevices);
|
||||
linkedDevices = linkedDevices.filter((v) => {
|
||||
if (v) {
|
||||
v.Linked = false;
|
||||
v.notifyState = false;
|
||||
}
|
||||
return v.device ? true : false;
|
||||
if (!v) return false;
|
||||
v.Linked = false;
|
||||
v.notifyState = false;
|
||||
return !!v.device;
|
||||
});
|
||||
}
|
||||
|
||||
@ -651,7 +650,7 @@ class BleHelper {
|
||||
BleReceive() {
|
||||
uni.onBLECharacteristicValueChange((receive) => {
|
||||
//订阅消息
|
||||
// console.log("收到订阅消息", receive);
|
||||
console.log("收到订阅消息", receive);
|
||||
let f = this.data.LinkedList.find((v) => {
|
||||
return v.deviceId == receive.deviceId;
|
||||
})
|
||||
@ -1729,28 +1728,18 @@ class BleHelper {
|
||||
return linkDevice(deviceId);
|
||||
}).then((res) => {
|
||||
|
||||
if (res) { //新连接
|
||||
if (res) { //新连接(含 createBLEConnection 刚成功)
|
||||
// console.log("11111111");
|
||||
if (fIndex == -1) {
|
||||
// console.log("开始获取服务", targetServiceId)
|
||||
return this.getService(deviceId, targetServiceId, writeCharId,
|
||||
notifyCharId); //获取服务
|
||||
} else {
|
||||
if (f.wirteCharactId && f.notifyCharactId) {
|
||||
if (!f.notifyState) {
|
||||
// console.log("开始订阅特征");
|
||||
this.subScribe(deviceId, true);
|
||||
} else {
|
||||
console.log("不订阅消息");
|
||||
}
|
||||
return Promise.resolve(true);
|
||||
} else {
|
||||
console.log("开始获取服务", targetServiceId)
|
||||
return this.getService(deviceId, targetServiceId, writeCharId,
|
||||
notifyCharId);
|
||||
}
|
||||
|
||||
|
||||
// 设备已在 LinkedList(例如缓存/重连):不能仅用缓存的 write/notify UUID 直接订阅。
|
||||
// 重连后须先 getBLEDeviceServices,否则部分机型 notifyBLECharacteristicValueChange 报 no service(10004),notify 收不到任何数据。
|
||||
console.log("已缓存设备重新连接,重新发现服务并订阅", deviceId);
|
||||
return this.getService(deviceId, targetServiceId, writeCharId,
|
||||
notifyCharId);
|
||||
}
|
||||
} else { //已连接过,直接订阅消息
|
||||
// console.log("11111111");
|
||||
|
||||
@ -14,7 +14,8 @@ class BleReceive {
|
||||
'/pages/100/HBY100': this.Receive_100.bind(this),
|
||||
'/pages/102/HBY102': this.Receive_102.bind(this),
|
||||
'/pages/6170/deviceControl/index':this.Receive_6170.bind(this),
|
||||
'/pages/100J/HBY100-J': this.Receive_100J.bind(this)
|
||||
'/pages/100J/HBY100-J': this.Receive_100J.bind(this),
|
||||
'/pages/6075J/BJQ6075J':this.Receive_6075.bind(this)
|
||||
};
|
||||
}
|
||||
|
||||
@ -49,6 +50,19 @@ class BleReceive {
|
||||
|
||||
|
||||
ReceiveData(receive, f, path, recArr) {
|
||||
// 100J:首页等场景 LinkedList 项可能未带齐 mac/device,但语音分片上传依赖 parseBleData 消费 FB 05
|
||||
const sid = receive && receive.serviceId ? String(receive.serviceId) : '';
|
||||
const is100JAe30 = /ae30/i.test(sid);
|
||||
const fReady = f && f.macAddress && f.device && f.device.id;
|
||||
if (is100JAe30 && receive && receive.bytes && receive.bytes.length >= 3 && !fReady) {
|
||||
try {
|
||||
parseBleData(new Uint8Array(receive.bytes));
|
||||
} catch (e) {
|
||||
console.warn('[100J] ReceiveData 兜底解析失败', e);
|
||||
}
|
||||
return receive;
|
||||
}
|
||||
|
||||
if (f && f.macAddress && f.device && f.device.id) {
|
||||
let handler = null;
|
||||
let keys = Object.keys(this.HandlerMap);
|
||||
@ -73,7 +87,10 @@ class BleReceive {
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log("已收到该消息,但无法处理", receive, "f:", f);
|
||||
// 100J AE30 二进制帧在 f 不完整时已在上方 parseBleData,此处不再误报「无法处理」
|
||||
if (!is100JAe30) {
|
||||
console.log("已收到该消息,但无法处理", receive, "f:", f);
|
||||
}
|
||||
}
|
||||
|
||||
return receive;
|
||||
@ -677,7 +694,8 @@ class BleReceive {
|
||||
let receiveData = {};
|
||||
try {
|
||||
if (!receive.bytes || receive.bytes.length < 3) return receiveData;
|
||||
const parsed = parseBleData(receive.bytes);
|
||||
// 与 HBY100-J 页 bleValueNotify 共用 notify,避免 parseBleData 执行两次:重复日志、FB05 双次 resolve、onNotify 双次
|
||||
const parsed = parseBleData(receive.bytes, { skipSideEffects: true });
|
||||
if (!parsed) return receiveData;
|
||||
if (parsed.longitude !== undefined) receiveData.longitude = parsed.longitude;
|
||||
if (parsed.latitude !== undefined) receiveData.latitude = parsed.latitude;
|
||||
@ -893,7 +911,36 @@ Receive_6170(receive, f, path, recArr) {
|
||||
}
|
||||
|
||||
|
||||
Receive_6075(receive,f,path,recArr){
|
||||
let receiveData = {};
|
||||
|
||||
try {
|
||||
|
||||
receiveData = JSON.parse(receive.str);
|
||||
|
||||
let recCnt = recArr.find(v => {
|
||||
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
||||
.replace(/\//g, "").toLowerCase();
|
||||
});
|
||||
if (!recCnt) {
|
||||
// if (receiveData.sta_PowerPercent <= 20) {
|
||||
// uni.showModal({
|
||||
// title: "提示",
|
||||
// content: "设备'" + f.device.deviceName + "'电量低",
|
||||
// showCancel: false
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
receiveData = {};
|
||||
console.log("文本解析失败", error)
|
||||
}
|
||||
return receiveData;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -282,7 +282,7 @@ export default {
|
||||
value: "46",
|
||||
label: "手动报警",
|
||||
checked: false,
|
||||
type: ['210','102']
|
||||
type: ['210','102','6170']
|
||||
},
|
||||
{
|
||||
value: "47",
|
||||
@ -445,7 +445,8 @@ export default {
|
||||
});
|
||||
},
|
||||
(error) => {
|
||||
console.log('文件不存在/路径错误:', error.message); // 核心问题!
|
||||
console.log('文件不存在/路径错误:', error.message);
|
||||
reject(error || new Error('resolveLocalFileSystemURL 失败'));
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user