完成HBY102

This commit is contained in:
liub
2025-11-17 15:30:57 +08:00
parent cb9ed0b1da
commit 18fd446b07
8 changed files with 164 additions and 51 deletions

View File

@ -9,14 +9,14 @@
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.sta_battery}}%</view>
<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>
<view class="txt">
<view class="bigTxt">{{formData.sta_system?dic.sta_system[formData.sta_system]:"" }}</view>
<view class="bigTxt">{{formData.sta_charge?dic.sta_charge[formData.sta_charge]:"" }}</view>
<view class="smallTxt">设备状态</view>
</view>
</view>
@ -42,10 +42,18 @@
</view>
<!-- <view class="item">
<text class="lbl">设备状态</text>
<text class="value">{{formData.sta_system?dic.sta_system[formData.sta_system]:"" }}</text>
<text class="value">{{formData.sta_charge?dic.sta_charge[formData.sta_charge]:"" }}</text>
</view> -->
</view>
<view class="warnnig" :class="(formData.sta_Intrusion===1)?'':'displayNone'"
>
<view>闯入报警</view>
<view class="netContent">
{{formData.sta_IntrusTime}}s
</view>
</view>
<view class="lampMode">
<view class="sosContent">
<view class="btnSos openSos center" :class="{active:formData.sta_LedType==='led_alarm'}"
@ -57,6 +65,9 @@
</view>
</view>
@ -174,15 +185,16 @@
} from '../../utils/request';
import Common from '@/utils/Common.js'
const pagePath = "/pages/100/HBY100";
const pagePath = "/pages/102/HBY102";
var ble = null;
var these = null;
var recei = null;
var interval = null;
var brightnessTimer = null;
var volumeTimer = null;
var hzTimer = null;
var instrusionTime = null;
export default {
data() {
return {
@ -240,21 +252,23 @@
usrToggle: false,
},
formData: {
img: '/static/images/common/HBY100J.png',
sta_battery: '',
img: '/static/images/common/HBY102.png',
sta_PowerPercent: '',
xuhang: '',
blename: '',
deviceId: '',
deviceName: '',
RSSI: '',
statu: '',
macAddress: '',
sta_address: '',
bleStatu: false,
sta_LedType: '',
sta_RadarType: '',
sta_Online: '',
warnTime: ''
warnTime: '',
sta_Intrusion: 0,
sta_IntrusTime: ''
},
dic: {
@ -317,11 +331,9 @@
group: 'sta_LedType'
}
],
sta_system: {
"0": '关机',
"1": '充电',
"2": '开机未充电',
"3": '开机且充电',
sta_charge: {
"0": '未充电',
"1": '充电'
}
},
@ -355,6 +367,8 @@
onUnload() {
console.log("页面卸载,释放资源");
ble.removeAllCallback(pagePath);
clearInterval(instrusionTime);
instrusionTime = 0;
},
onLoad: function() {
these = this;
@ -407,6 +421,8 @@
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true;
});
these.formData.sta_IntrusTime=0;
these.formData.sta_Intrusion=0;
these.setBleFormData();
@ -536,7 +552,7 @@
reject();
});
});
return promise();
return promise;
}
@ -568,11 +584,11 @@
if (item.key == 'led_alarm' && this.formData.sta_LedType == 'led_alarm') {
return;
}
if (item.key == 'led_off' && this.formData.sta_LedType !== 'led_alarm') {
return;
}
let f = this.getDevice();
@ -595,8 +611,6 @@
}
json = JSON.stringify(json);
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
this.formData.sta_LedType = val;
these.setBleFormData();
resolve();
@ -630,7 +644,7 @@
buttonBgColor: "#E03434",
okCallback: () => {
task(item.key).then(r => {
}).catch(ex => {
@ -735,23 +749,50 @@
if (receive.deviceId !== this.formData.deviceId) {
return;
}
if (this.Status.pageHide) {
return;
}
let json = recei.ReceiveData(receive, device, pagePath, recArr);
console.log("json=",json)
let keys = Object.keys(json);
keys.forEach(key => {
if (key in this.formData) {
// console.log("key=",key+",value=",json[key]);
this.formData[key] = json[key] + "";
console.log("key=",key+",value=",json[key]);
this.formData[key] = json[key] ;
}
});
if (this.formData.sta_battery <= 20) {
this.showMsg("设备电量低");
let msg = [];
if (this.formData.sta_PowerPercent <= 20) {
msg.push("设备电量低");
}
if (this.formData.sta_Intrusion === 1) {
msg.push("闯入报警中");
clearInterval(instrusionTime);
instrusionTime = 0;
setInterval(() => {
instrusionTime++;
if(instrusionTime>60){
this.formData.sta_Intrusion=0;
clearInterval(instrusionTime);
return;
}
this.formData.sta_IntrusTime=instrusionTime;
}, 1000);
}else{
clearInterval(instrusionTime);
instrusionTime=0;
this.formData.sta_IntrusTime=0;
}
if (msg.length > 0) {
this.showMsg(msg.join(','));
}
},
getDevice: function() {