完成HBY102
This commit is contained in:
@ -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'}"
|
||||
@ -62,6 +70,9 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<view class="lamp">
|
||||
<view class="title">
|
||||
<text>警示灯</text>
|
||||
@ -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;
|
||||
|
||||
}
|
||||
|
||||
@ -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();
|
||||
@ -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() {
|
||||
|
||||
|
||||
@ -328,7 +328,7 @@
|
||||
these.EquipMents.push(arr[i]);
|
||||
}
|
||||
}
|
||||
console.log("EquipMents=", these.EquipMents)
|
||||
// console.log("EquipMents=", these.EquipMents)
|
||||
}, pagePath);
|
||||
//收到设备的消息回调
|
||||
ble.addReceiveCallback((receivData, f, path, arr) => {
|
||||
|
||||
BIN
static/images/common/HBY102.png
Normal file
BIN
static/images/common/HBY102.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
@ -6,6 +6,11 @@ const serviceDic = [ //合作供应商的蓝牙主服务
|
||||
"writeId": "0000FFE1-0000-1000-8000-00805F9B34FB",
|
||||
"notifyId": "0000FFE2-0000-1000-8000-00805F9B34FB"
|
||||
},
|
||||
{
|
||||
"serviceId": "0000FFF0-0000-1000-8000-00805F9B34FB",
|
||||
"writeId": "0000FFF2-0000-1000-8000-00805F9B34FB",
|
||||
"notifyId": "0000FFF1-0000-1000-8000-00805F9B34FB"
|
||||
},
|
||||
{
|
||||
"serviceId": "0000AE30-0000-1000-8000-00805F9B34FB",
|
||||
"writeId": "0000AE03-0000-1000-8000-00805F9B34FB",
|
||||
@ -638,9 +643,9 @@ class BleHelper {
|
||||
let arr = [];
|
||||
for (var i = 0; i < res.devices.length; i++) {
|
||||
let item = res.devices[i];
|
||||
if(item.name){
|
||||
console.log("发现新设备",item.name+" "+item.RSSI);
|
||||
}
|
||||
// if(item.name){
|
||||
// console.log("发现新设备",item.name+" "+item.RSSI);
|
||||
// }
|
||||
|
||||
let f = serviceDic.find(v => {
|
||||
return item.advertisServiceUUIDs
|
||||
@ -648,7 +653,7 @@ class BleHelper {
|
||||
});
|
||||
if (f) {
|
||||
|
||||
console.log("发现目标设备:", item);
|
||||
// console.log("发现目标设备:", item);
|
||||
arr.push(item);
|
||||
}
|
||||
|
||||
@ -1203,7 +1208,7 @@ class BleHelper {
|
||||
deviceId: id,
|
||||
success: (res) => {
|
||||
if (res.services && res.services.length > 0) {
|
||||
// console.log("获取到服务:" + JSON.stringify(res));
|
||||
console.log("获取到服务:" + JSON.stringify(res));
|
||||
|
||||
this.data.LinkedList.find((v) => {
|
||||
if (v.deviceId == id) {
|
||||
@ -1228,7 +1233,7 @@ class BleHelper {
|
||||
});
|
||||
|
||||
if (se) {
|
||||
// console.log("合作供应商的", s)
|
||||
console.log("合作供应商的", s)
|
||||
this.data.LinkedList.find((v) => {
|
||||
if (v.deviceId == id) {
|
||||
v.writeServiceId = s.serviceId;
|
||||
@ -1246,7 +1251,9 @@ class BleHelper {
|
||||
// notifyCharId));
|
||||
|
||||
|
||||
} else {
|
||||
} else
|
||||
|
||||
{
|
||||
console.error("预设的蓝牙服务和特征中找不到");
|
||||
for (var i = 0; i < res.services.length; i++) {
|
||||
let service = res.services[i];
|
||||
@ -1266,6 +1273,7 @@ class BleHelper {
|
||||
|
||||
Promise.all(promises)
|
||||
.then(results => {
|
||||
console.log("results= ",results);
|
||||
if (!s) {
|
||||
//非指定供应商的设备,走订阅消息
|
||||
return this.subScribe(id, true);
|
||||
@ -1326,10 +1334,10 @@ class BleHelper {
|
||||
serviceId: serviceId,
|
||||
success: (res) => {
|
||||
|
||||
// console.log("获取到特征:" + JSON.stringify(res));
|
||||
// res.characteristics.forEach((v) => {
|
||||
// v.serviceId = serviceId;
|
||||
// });
|
||||
console.log("获取到特征:" + JSON.stringify(res));
|
||||
res.characteristics.forEach((v) => {
|
||||
v.serviceId = serviceId;
|
||||
});
|
||||
|
||||
//写特征
|
||||
let writeChar = res.characteristics.find(char => {
|
||||
|
||||
@ -7,7 +7,8 @@ class BleReceive {
|
||||
'/pages/650/HBY650': this.Receive_650.bind(this),
|
||||
'/pages/670/HBY670': this.Receive_670.bind(this),
|
||||
'/pages/4877/BJQ4877': this.Receive_4877.bind(this),
|
||||
'/pages/100/HBY100': this.Receive_100.bind(this)
|
||||
'/pages/100/HBY100': this.Receive_100.bind(this),
|
||||
'/pages/102/HBY102':this.Receive_102.bind(this)
|
||||
};
|
||||
}
|
||||
|
||||
@ -561,6 +562,44 @@ class BleReceive {
|
||||
}
|
||||
|
||||
|
||||
Receive_102(receive,f,path,recArr){
|
||||
let receiveData={};
|
||||
|
||||
try {
|
||||
|
||||
console.log("str=",receive.str);
|
||||
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: "设备电量低",
|
||||
showCancel: false
|
||||
});
|
||||
}
|
||||
if (receiveData.sta_Intrusion===1) {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "闯入报警中",
|
||||
showCancel: false
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
receiveData = {};
|
||||
console.log("文本解析失败",error)
|
||||
}
|
||||
return receiveData;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -363,4 +363,16 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
getOSAndUpload(){
|
||||
let os=uni.getSystemInfoSync().platform;
|
||||
let url=''
|
||||
if(os==='ios'){
|
||||
url='https://apps.apple.com/cn/app/星汉物联/id6752555460'
|
||||
}
|
||||
|
||||
else if(os==='android'){
|
||||
url='https://www.pgyer.com/xhwl';
|
||||
}
|
||||
return {os:os,url:url};
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
import config from '../config/index.js';
|
||||
export const env = 'production'; //production development //开发of线上 改这里就行
|
||||
export const env = 'development'; //production development //开发of线上 改这里就行
|
||||
const BASE = config[env];
|
||||
const request = (options) => {
|
||||
console.log("options"+JSON.stringify(options),BASE.BASE_URL)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import request, {
|
||||
baseURL
|
||||
} from '@/utils/request.js'
|
||||
|
||||
import Common from '@/utils/Common.js'
|
||||
/**
|
||||
* 检查并执行wgt热更新
|
||||
* @param {String} updateUrl - 检查更新的接口地址
|
||||
@ -178,10 +178,20 @@ function downloadAndInstallWgt(wgtUrl) {
|
||||
var wating = plus.nativeUI.showWaiting({
|
||||
title: "下载中0%"
|
||||
});
|
||||
// uni.showLoading({
|
||||
// title: '更新下载中...',
|
||||
// mask: true
|
||||
// });
|
||||
|
||||
//手动更新
|
||||
let ManualUpdate=()=>{
|
||||
setTimeout(()=>{
|
||||
|
||||
let url=Common.getOSAndUpload().url
|
||||
plus.runtime.openURL(url, (res) => {
|
||||
uni.showToast({
|
||||
title: '打开失败',
|
||||
icon: 'none'
|
||||
});
|
||||
});
|
||||
},1000);
|
||||
}
|
||||
|
||||
// 1. 下载wgt包
|
||||
const downloadTask = uni.downloadFile({
|
||||
@ -219,20 +229,22 @@ function downloadAndInstallWgt(wgtUrl) {
|
||||
|
||||
wating.close();
|
||||
uni.showToast({
|
||||
title: '安装失败: ' + error.message,
|
||||
title: '安装失败,请手动下载更新;' + error.message,
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
});
|
||||
console.error('wgt安装失败:', error);
|
||||
ManualUpdate();
|
||||
});
|
||||
|
||||
} else {
|
||||
wating.close();
|
||||
uni.showToast({
|
||||
title: '下载失败',
|
||||
title: '下载失败,请手动下载更新;',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
ManualUpdate();
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
@ -243,6 +255,7 @@ function downloadAndInstallWgt(wgtUrl) {
|
||||
duration: 2000
|
||||
});
|
||||
console.error('wgt下载失败:', err);
|
||||
ManualUpdate();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user