1
0
forked from dyf/APP

Compare commits

..

2 Commits

19 changed files with 5433 additions and 1610 deletions

69
App.vue
View File

@ -6,26 +6,26 @@
onLaunch: function() {
//以下代码仅在开发时使用,否则会出现不可预知的问题。
//清除登陆之外的所有信息;
// let store=uni.getStorageInfoSync();
// store.keys.forEach((val,index,array)=>{
// if(val=="tokenTime"){
// let time=uni.getStorageSync(val);
// if(!time){
// time=0;
// }
// let currTime=new Date().getTime();
// if(currTime>=time){
// uni.removeStorageSync(val);
// uni.removeStorageSync("token");
// uni.removeStorageSync("clientID");
// }
// }
// else if(val=="token" || val=="clientID"){
// console.log("忽略登陆信息");
// }else{
// uni.removeStorageSync(val);
// }
// });
let store=uni.getStorageInfoSync();
store.keys.forEach((val,index,array)=>{
if(val=="tokenTime"){
let time=uni.getStorageSync(val);
if(!time){
time=0;
}
let currTime=new Date().getTime();
if(currTime>=time){
uni.removeStorageSync(val);
uni.removeStorageSync("token");
uni.removeStorageSync("clientID");
}
}
else if(val=="token" || val=="clientID"){
console.log("忽略登陆信息");
}else{
uni.removeStorageSync(val);
}
});
//以上代码仅在开发时使用,否则会出现不可预知的问题。
uni.getSystemInfo({success:function(res){
@ -47,21 +47,24 @@
<style lang="scss">
@import 'vk-uview-ui/index.scss';
// uni-slider .uni-slider-handle-wrapper {
// border-radius: 20rpx;
// }
// uni-slider .uni-slider-thumb {
// width: 66rpx !important;
// height: 80rpx !important;
// margin-top: -40rpx !important;
// border-radius: 16rpx !important;
// margin-left: -72rpx !important;
/* #ifdef APP-ANDROID */
//苹果应用以下样式后Slider不可拖动
uni-slider .uni-slider-handle-wrapper {
border-radius: 20rpx;
}
uni-slider .uni-slider-thumb {
width: 66rpx !important;
height: 80rpx !important;
margin-top: -40rpx !important;
border-radius: 16rpx !important;
margin-left: -72rpx !important;
}
uni-slider .uni-slider-handle-wrapper {
height: 88rpx;
position: relative;
// }
// uni-slider .uni-slider-handle-wrapper {
// height: 88rpx;
// position: relative;
// }
/* #endif */
.custom-file-picker .file-picker__box-content {
background: rgba(26, 26, 26, 1);
border: none !important;

View File

@ -6,7 +6,7 @@ const config = {
API_PREFIX: '',
// MQTT 配置
MQTT_HOST: '47.120.79.150',
MQTT_PORT: 9083,
MQTT_PORT: 8083,
MQTT_USERNAME: 'admin',
MQTT_PASSWORD: '#YtvpSfCNG'
},
@ -16,7 +16,7 @@ const config = {
API_PREFIX: '',
// MQTT 配置
MQTT_HOST: '47.120.79.150',
MQTT_PORT: 9083,
MQTT_PORT: 8083,
MQTT_USERNAME: 'admin',
MQTT_PASSWORD: '#YtvpSfCNG'
}

View File

@ -2,7 +2,7 @@
"name" : "星汉物联",
"appid" : "__UNI__A21EF43",
"description" : "设备管控",
"versionName" : "1.0.24",
"versionName" : "1.0.25",
"versionCode" : "100",
"transformPx" : false,
/* 5+App */

View File

@ -1,11 +1,6 @@
{
"pages": [
// {
// "path": "pages/BlueTooth/ModeSetting/index",
// "style": {
// "navigationBarTitleText": "设备类型"
// }
// },
{
"path": "pages/common/login/index",
@ -113,16 +108,16 @@
{
"path": "pages/common/addBLE/addEquip",
"style": {
"navigationBarTitleText": "添加设备"
"navigationBarTitleText": "扫描设备"
}
},
{
"path": "pages/common/addBLE/LinkBle",
"style": {
"navigationBarTitleText": "扫描到的设备"
"navigationBarTitleText": "绑定设备"
}
},
{
{
"path": "pages/6155/deviceDetail",
"style": {
"navigationBarTitleText": "HBY 6155"
@ -197,7 +192,12 @@
"navigationBarTitleText": "呼叫"
}
},
{
"path": "pages/BlueTooth/ModeSetting/index",
"style": {
"navigationBarTitleText": "设备类型"
}
},
{
"path": "pages/BlueTooth/ModeSetting/VideoSend",
"style": {
@ -284,10 +284,16 @@
}
},
{
"path" : "pages/BlueTooth/ModeSetting/4877",
"path": "pages/BlueTooth/ModeSetting/4877",
"style": {
"navigationBarTitleText": ""
}
},
{
"path" : "pages/7305/BJQ7305",
"style" :
{
"navigationBarTitleText" : ""
"navigationBarTitleText" : "BJQ7305"
}
}

View File

@ -55,7 +55,7 @@
</view>
<view class="rightTxt">
<text class="bigTxt">主灯模式</text>
<text class="smallTxt">强光模式</text>
<text class="smallTxt">{{getMode}}</text>
</view>
</view>
<view class="mode marginLeft fleft" v-on:click.stop="ModeSetting('fu')">
@ -308,6 +308,7 @@
// } else {
// link();
// }
console.log("6155");
ble.addReceiveCallback(these.bleValueNotify);
let eventChannel = this.getOpenerEventChannel();
@ -316,7 +317,7 @@
let device = data.data;
these.device = device;
console.log("收到父页面的参数:" + JSON.stringify(device));
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v);
@ -328,12 +329,7 @@
if (!f) {
these.showPop({
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
these.showBleUnConnect();
return;
}
let form = f.formData;
@ -381,6 +377,35 @@
if (this.formData.RSSI < -85 && this.formData.RSSI >= -100) {
remark = '微弱';
}
},
getMode() {
let txt = "关闭";
if (this.Status.BottomMenu.type == 'fu') {
return txt;
}
switch (this.formData.mode) {
case 0:
txt = "强光模式";
break;
case 1:
txt = "弱光模式";
break;
case 2:
txt = "爆闪模式";
break;
case 3:
txt = "关闭";
break;
default:
txt = "关闭";
break;
}
return txt;
}
},
methods: {
@ -395,11 +420,11 @@
},
bleValueNotify: function(receive, device, path) {
let str = recei.ReceiveData(receive, device, pagePath);
let str = recei.ReceiveData(receive, device, path);
console.log("处理接收到的数据:" + str);
return;
let data = recei.ReceiveData(receive, device, pagePath);
let data = recei.ReceiveData(receive, device, path);
let bytes = receive.bytes;
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
@ -504,16 +529,40 @@
}
});
},
checkImgUpload: function() {
let f = these.getDevice();
if (!f) {
these.showPop({
showBleUnConnect() {
this.showPop({
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '去连接',
okCallback: function() {
console.log("1111");
uni.navigateTo({
url: "/pages/common/addBLE/addEquip",
events: {
BindOver: function(data) {
console.log(data)
}
},
success: function(res) {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('detailData', {
data: these.device
})
},
fail(ex) {
console.log("跳转失败", ex);
}
})
}
});
},
checkImgUpload: function() {
let f = these.getDevice();
if (!f) {
these.showBleUnConnect();
return;
}
@ -595,8 +644,8 @@
these.showPop({
message: "上传成功",
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
borderColor : '#BBE600',
buttonBgColor : '#BBE600'
borderColor: '#BBE600',
buttonBgColor: '#BBE600'
});
resolve();
@ -766,10 +815,10 @@
text: '强光',
icon: '/static/images/6155/DeviceDetail/qiang.png'
},
{
text: '工作光',
icon: '/static/images/6155/DeviceDetail/fan.png'
},
// {
// text: '工作光',
// icon: '/static/images/6155/DeviceDetail/fan.png'
// },
{
text: '弱光',
icon: '/static/images/6155/DeviceDetail/ruo.png'
@ -822,15 +871,10 @@
}
this.closeMenu();
},
setMode(mode, type) {
let dataValue = 0;
this.setBleFormData();
this.currentMode = mode;
switch (mode) {
@ -842,25 +886,25 @@
dataValue = 0x01;
} else if (type == 'fu') {
dataValue = 0x0A;
dataValue = 0x04;
}
break;
case 1:
dataValue = 0x04;
break;
case 2:
dataValue = 0x02;
break;
case 3:
// case 2:
// dataValue = 0x02;
// break;
case 2:
dataValue = 0x03;
break;
case 4:
case 3:
dataValue = 0x0B;
break;
}
console.log("dataValue=", dataValue)
// console.log("dataValue=", dataValue)
// 构建数据包
var buffer = new ArrayBuffer(6);
var dataView = new DataView(buffer);
@ -876,12 +920,7 @@
// 发送数据
if (!f) {
these.showPop({
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
these.showBleUnConnect();
return;
}
@ -890,7 +929,8 @@
});
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 30).then(() => {
this.formData.mode = mode;
this.setBleFormData();
}).catch((ex) => {
these.showPop({
message: "发送失败," + ex.msg,
@ -934,38 +974,54 @@
},
HidePop: function() {
console.log("1111");
if (this.Status.Pop.clickEvt == 'SendUsr') {
}
if (this.Status.Pop.okCallback) {
this.Status.Pop.okCallback();
}
this.Status.Pop.showPop = false;
},
showPop: function(option) {
if (!option) {
option = {
a: 1
hideLoading(this);
let defaultCfg = {
showHeader: false,
headerTxt: "",
showHeader: false,
showCancel: false,
borderColor: '#BBE600',
buttonBgColor: '#BBE600',
okCallback: null,
cancelCallback: null,
popType: 'custom',
buttonText: '确定',
clickEvt: ''
};
if (!option) {
}
let keys = Object.keys(option);
for (var i = 0; i < keys.length; i++) {
let key = keys[i];
these.Status.Pop[key] = option[key];
this.Status.Pop[key] = option[key];
}
if (!option.borderColor) {
option.borderColor = '#BBE600';
option.buttonBgColor = '#BBE600';
keys = Object.keys(defaultCfg);
for (var i = 0; i < keys.length; i++) {
let key = keys[i];
if (key in option) {
continue;
}
these.Status.Pop.showPop = true;
this.Status.Pop[key] = defaultCfg[key];
}
this.Status.Pop.showPop = true;
},
sendUsr() {
let f = this.getDevice();
if (!f) {
these.showPop({
text: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
these.showBleUnConnect()
return;
}
showLoading(these, {
@ -1120,8 +1176,8 @@
this.showPop({
message: "发送成功",
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
borderColor : '#BBE600',
buttonBgColor : '#BBE600'
borderColor: '#BBE600',
buttonBgColor: '#BBE600'
});
@ -1129,9 +1185,9 @@
let json = {
deviceId: these.device.id,
name: these.formData.textLines[2],
name: these.formData.textLines[1],
position: these.formData.textLines[0],
unitName: these.formData.textLines[1],
unitName: these.formData.textLines[2],
code: ""
};
usrApi.sendUsr(json)

View File

@ -293,6 +293,7 @@
these = this;
recei = BleReceive.getBleReceive();
ble = BleTool.getBleTool();
console.log("650")
ble.addReceiveCallback(these.bleValueNotify);
let eventChannel = this.getOpenerEventChannel();
@ -312,12 +313,7 @@
if (!f) {
these.showPop({
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
these.showBleUnConnect();
return;
}
let form = f.formData;
@ -555,12 +551,7 @@
these.setBleFormData();
});
} else {
these.showPop({
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
these.showBleUnConnect();
hideLoading(these);
}
}
@ -569,6 +560,34 @@
},
showBleUnConnect(){
this.showPop({
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText:'去连接',
okCallback:function(){
console.log("1111");
uni.navigateTo({
url:"/pages/common/addBLE/addEquip",
events: {
BindOver: function(data) {
console.log(data)
}
},
success: function(res) {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('detailData', { data: these.device })
},
fail(ex){
console.log("跳转失败",ex);
}
})
}
});
},
LampToggle: function() {
this.formData.cMode = !this.formData.cMode;
@ -1143,12 +1162,7 @@
let f = this.getDevice();
if (!f) {
these.showPop({
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
these.showBleUnConnect();
return;
}
showLoading(this, {

View File

@ -44,7 +44,7 @@
</view>
<view class="warnnig" v-bind:class="formData.staticWarn?'':'displayNone'">
<view>警告环境存在漏电电源</view>
<view>警告设备静止报警中</view>
<view class="netContent">
<view v-bind:class="getWarnStyle(1)" class="net netone"></view>
<view v-bind:class="getWarnStyle(2)" class="net nettwo"></view>
@ -55,7 +55,7 @@
</view>
<view class="warnnig" v-bind:class="(formData.qzwarn && Status.staticWarn.time)?'':'displayNone'"
@click="CloseWarn(true)">
<view>设备强制闪烁报警中</view>
<view>设备强制报警中</view>
<view class="netContent">
{{Status.staticWarn.time}}s
</view>
@ -90,7 +90,9 @@
:src="formData.SOS=='sg'?'/static/images/670/sgActive.png':'/static/images/670/sg.png'"
mode="aspectFit"></image>
</view>
<view class="txt">声光报警</view>
<view :class="(formData.qzwarn && Status.staticWarn.time)?'':'displayNone'">
报警中{{Status.staticWarn.time}}</view>
<view :class="(formData.qzwarn && Status.staticWarn.time)?'displayNone':''" class="txt">声光报警</view>
</view>
<view class="item" @click="sosSetting('rb')" :class="formData.SOS=='rb'?'active':''">
<view class="imgContent center">
@ -296,7 +298,8 @@
visiblePrompt: false,
promptTitle: '设备名称',
modelValue: '',
visibleClose: false
visibleClose: false,
},
BottomMenu: {
show: false,
@ -344,7 +347,7 @@
Lat: "", //纬度
address: "", //地址
modeCurr: "", //档位
SOS: "sg", //sos
SOS: "", //sos
lightCurr: "qiang", //照明模式
company: "", //单位
usrname: "", //姓名
@ -400,6 +403,7 @@
these = this;
recei = BleReceive.getBleReceive();
ble = BleTool.getBleTool();
console.log("670")
ble.addReceiveCallback(these.bleValueNotify);
let eventChannel = this.getOpenerEventChannel();
@ -688,9 +692,9 @@
if (this.formData.imei) {
this.initMQ();
}
if (these.formData.staticWarn) { //有静止报警
if (this.formData.staticWarn) { //有静止报警
these.showPop({
message: "环境存在漏电电源",
message: "设备静止报警中",
iconUrl: "/static/images/6155/DeviceDetail/warnning.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
@ -701,7 +705,7 @@
}
these.setBleFormData();
this.setBleFormData();
},
getDevice: function() {
@ -805,15 +809,15 @@
setTimeout(task, 0);
},
CloseWarn: function(ispop) {
CloseWarn: function(ispop) { //解除强制报警
let closeEvt = () => {
{
these.Status.Pop.showPop = false;
these.formData.qzwarn = false;
clearInterval(these.Status.staticWarn.inteval);
let closeSOS = () => {
let requestCloseSOS = () => {
let json = {
ins_SOSGrade: [0]
};
@ -821,6 +825,7 @@
this.sendMQ(json).then((res) => {
console.log("4g发送成功");
}).catch((ex) => {
console.log("ex=", ex);
these.showPop({
@ -832,34 +837,15 @@
}).finally(() => {
hideLoading(these);
this.formData.SOS = 'close';
these.setBleFormData();
});
}
let closeWarn = () => {
let json = {
ins_ShakeBit: [0]
};
this.sendMQ(json).then((res) => {
console.log("4g发送成功");
}).catch((ex) => {
console.log("ex=", ex);
these.showPop({
message: "通信异常,请检查手机或设备网络",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
}).finally(() => {
hideLoading(these);
these.setBleFormData();
});
}
let f = this.getDevice();
let buffer = null;
if (f) {
@ -867,51 +853,53 @@
buffer = new ArrayBuffer(6);
let dataView = new DataView(buffer);
dataView.setUint8(0, 0x55); // 帧头
dataView.setUint8(1, 0x06); // 帧类型
dataView.setUint8(2, 0x01); // 包序号
dataView.setUint8(3, 0x00); // 数据长度
dataView.setUint8(4, 0x01); // 数据长度
dataView.setUint8(5, 0x71); // 数据
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(
() => {
console.log("关闭强制报警成功")
dataView.setUint8(0, 0x55); // 帧头
dataView.setUint8(1, 0x05); // 帧类型
dataView.setUint8(2, 0x01); // 包序号
dataView.setUint8(3, 0x00); // 数据长度
dataView.setUint8(4, 0x01); // 数据长度
dataView.setUint8(5, 0x68);
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10)
.then(() => {
console.log("成功");
});
dataView.setUint8(5, 0x6A); // 数据
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(
() => {
console.log("关闭强制报警成功")
}).catch(ex => {
closeSOS();
// closeWarn();
requestCloseSOS();
}).finally(() => {
this.formData.SOS = 'close';
these.setBleFormData();
});
} else {
closeSOS();
// closeWarn();
}
requestCloseSOS();
}
}
if (!ispop) {
closeEvt();
return;
}
this.showQzWarn(closeEvt);
},
showQzWarn(callback) {
let message = '持续报警时间' + this.Status.staticWarn.time;
if (this.Status.Pop.clickEvt == 'time' && this.Status.Pop.showPop) {
this.Status.Pop.message = message
return;
}
this.showPop({
showHeader: true,
headerTxt: "强制报警",
message: '持续报警时间' + this.Status.staticWarn.time,
message: message,
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: "解除报警",
okCallback: closeEvt
okCallback: callback,
clickEvt: 'time'
});
},
sosSetting: function(type) {
if (this.formData.SOS == type) {
@ -922,7 +910,7 @@
text: "请稍候..."
});
let task = () => {
this.formData.SOS = type;
let dic = {
ble: {
rb: 0x68,
@ -944,6 +932,8 @@
let requestSend = () => {
this.sendMQ(json).then((res) => {
console.log("4g发送成功");
}).catch((ex) => {
console.log("ex=", ex);
these.showPop({
@ -961,7 +951,7 @@
}
let SendCmd = () => {
let bleSendCmd = () => {
let f = this.getDevice();
let buffer = null;
if (f) {
@ -979,21 +969,6 @@
() => {
console.log("蓝牙发送成功了");
// dic = {
// close: 0x71
// }
// if (type in dic) {
// dataView.setUint8(1, 0x06); // 帧类型
// dataView.setUint8(5, 0x71); // 数据
// } else {
// dataView.setUint8(1, 0x06); // 帧类型
// dataView.setUint8(5, 0x70); // 数据
// }
// ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
// 10).then(() => {
// console.log("蓝牙发送报警成功", type);
// })
hideLoading(these);
these.setBleFormData();
@ -1007,27 +982,18 @@
}
}
if (type !== 'sg') {
SendCmd();
} else {
this.showPop({
message: '确定开启声光报警模式?',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: function() {
these.formData.qzwarn = true;
these.Status.staticWarn.time = 180;
let OpenSOS = () => {
these.formData.qzwarn = true; //标记为强制报警了
these.Status.staticWarn.time = 50;
this.formData.SOS = type;
let loopFunc = () => {
if (these.Status.staticWarn.inteval === null) {
return;
}
if (these.Status.staticWarn.time === 0) {
console.log("111111");
clearInterval(these.Status.staticWarn.inteval);
these.Status.staticWarn.inteval = null;
@ -1038,14 +1004,48 @@
}
these.Status.staticWarn.time = these.Status.staticWarn
.time - 1;
if (these.Status.Pop.clickEvt == 'time' && this.Status.Pop.showPop) {
console.log("111111");
this.showQzWarn(this.Status.Pop.okCallback);
}
}
these.Status.staticWarn.inteval = setInterval(() => {
loopFunc();
}, 1000)
SendCmd();
bleSendCmd();
}
if (type == 'rb') { //红蓝报警
this.formData.SOS = type;
bleSendCmd();
return;
}
if (type == 'sg') //强制报警
{
this.showPop({
message: '确定开启声光报警模式?',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: OpenSOS,
buttonText: "开启"
});
return;
}
if (type == 'close') {
if (this.formData.SOS = 'sg') { //解除声光报警
this.CloseWarn(true);
} else {
this.formData.SOS = type;
bleSendCmd();
}
}
}
@ -1522,7 +1522,30 @@
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '去连接',
okCallback: function() {
console.log("1111");
uni.navigateTo({
url: "/pages/common/addBLE/addEquip",
events: {
BindOver: function(data) {
console.log(data)
}
},
success: function(res) {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('detailData', {
data: these.device
})
},
fail(ex) {
console.log("跳转失败", ex);
}
})
}
});
return;
}
let uploadVideo = () => {
@ -1747,7 +1770,9 @@
buttonBgColor: '#BBE600',
okCallback: null,
cancelCallback: null,
popType: 'custom'
popType: 'custom',
buttonText: '确定',
clickEvt: ''
};
if (!option) {
@ -1755,7 +1780,7 @@
let keys = Object.keys(option);
for (var i = 0; i < keys.length; i++) {
let key = keys[i];
these.Status.Pop[key] = option[key];
this.Status.Pop[key] = option[key];
}
keys = Object.keys(defaultCfg);
for (var i = 0; i < keys.length; i++) {
@ -1763,10 +1788,10 @@
if (key in option) {
continue;
}
these.Status.Pop[key] = defaultCfg[key];
this.Status.Pop[key] = defaultCfg[key];
}
these.Status.Pop.showPop = true;
this.Status.Pop.showPop = true;
},
sendUsr: function(ReSendNo) {

1720
pages/7305/BJQ7305.vue Normal file

File diff suppressed because it is too large Load Diff

View File

@ -226,8 +226,7 @@
<script>
import gbk from '@/utils/gbk.js';
import MqttClient from '@/utils/mqtt.js';
import {
request,
import request,{
baseURL
} from '@/utils/request.js';
var videoChannel = null;

View File

@ -12,7 +12,7 @@
设备名:{{device.deviceName}}
</view>
<view class="deviceId">
ID:{{device.deviceId}}
设备Mac:{{device.macAddress}}
</view>
<view class="bound" v-bind:class="boundStatu">
{{Statu.boundRemark}}
@ -86,15 +86,16 @@
onLoad(option) {
these = this;
ble = bleTool.getBleTool();
console.log("LinkBle")
ble.addReceiveCallback((receive, f, path) => {
console.log("收到设备消息,", receive);
if (these.device.deviceId == receive.deviceId) {
// console.log("11111");
console.log("11111:",receive);
if (receive.bytes[0] == 0xFC || receive.str.indexOf('mac address:') == 0) {
if (f && f.macAddress) {
these.device.macAddress = f.macAddress;
// console.log("222222");
console.log("222222");
these.initDevice();
}
}
@ -233,7 +234,7 @@
v.device[key] = data[key];
}
ble.setBleData();
ble.updateCache();
}
});

View File

@ -97,6 +97,7 @@
const pagePath="pages/common/addBLE/addEquip";
var ble = null;
var these = null;
var eventChannel=null;
export default {
data() {
return {
@ -128,7 +129,11 @@
},
PairEquip: [], //已配对设备
EquipMents: [] //搜索出来的设备
EquipMents: [], //搜索出来的设备
device:null,
item:{
deviceId:''
}
}
},
computed: {
@ -145,7 +150,8 @@
},
onUnload(){
ble.StopSearch();
ble.removeDeviceFound(pagePath);
ble.removeReceiveCallback(pagePath);
},
onLoad() {
these = this;
@ -170,13 +176,23 @@
}
}
},pagePath);
// ble.addReceiveCallback((receivData) => {
}, pagePath);
// console.log("addEquip")
// ble.addReceiveCallback((receivData,f,path,arr) => {
// console.log("收到数据了:", receivData);//数据格式:{bytes:[109,97],str:"",hexs:"FA 01"}
// if (this.item.deviceId == receivData.deviceId) {
// console.log("11111:",receivData);
// // let data=uni.getStorageSync(ble.StorageKey);
// console.log("LinkedList=",ble.data.LinkedList);
// },pagePath);
// }
// });
eventChannel = this.getOpenerEventChannel();
eventChannel.on('detailData', function(rec) {
console.log("接收到父页面的参数:",rec);
these.device=rec.data;
});
},
onShow: function() {
@ -223,7 +239,7 @@
ble.showBlueSetting(false);
},
Link: function(item, index) {
this.item.deviceId=item.deviceId;
showLoading(this,{
text: "正在连接"
});
@ -241,6 +257,18 @@
these.PairEquip.push(item);
}
console.log("连接成功");
if(these.device){//从设备详情过来的,回设备详情去
ble.data.LinkedList.find(v=>{
if(v.deviceId==item.deviceId){
v.device=these.device;
return true;
}
return false;
});
ble.updateCache();
uni.navigateBack();
return;
}
uni.navigateTo({
url:"/pages/common/addBLE/LinkBle",
events:{

View File

@ -144,6 +144,8 @@
deviceUnbind, //删除设备
deviceReName
} from '@/api/common/index.js'
import BleHelper from '@/utils/BleHelper.js';
var ble=null;
export default {
onPullDownRefresh() {
// 执行下拉刷新时的操作,比如重新获取数据
@ -389,6 +391,8 @@
this.deleteShow = false
// 关闭所有滑动项
this.$refs.swipeAction.closeAll();
ble && ble.DropDevice(data.id);
} else {
uni.showToast({
title: res.msg,
@ -555,6 +559,7 @@
console.log('列表收到消息了么');
this.onIntall()
});
ble=BleHelper.getBleTool();
},
beforeDestroy() {
// 组件销毁前移除监听器

View File

@ -1,8 +1,8 @@
var isReady=false;var onReadyCallbacks=[];
var isServiceReady=false;var onServiceReadyCallbacks=[];
var __uniConfig = {"pages":["pages/common/login/index","pages/common/index/index","pages/common/user/index","pages/common/scan/scan","pages/common/qrcode/qrcode","pages/common/send/index","pages/common/userAgreement/index","pages/common/privacyAgreement/index","pages/common/aboutUs/index","pages/6170/deviceControl/index","pages/6170/callPolice/index","pages/210/deviceControl/index","pages/common/operationVideo/index","pages/common/addvideo/index","pages/common/operatingInstruct/index","pages/common/productDes/index","pages/common/addBLE/addEquip","pages/common/addBLE/LinkBle","pages/6155/deviceDetail","pages/6155/ImgCrop","pages/common/map/index","pages/common/allType/index","pages/6170/allShare/index","pages/6170/share/index","pages/6170/shareDevices/index","pages/6170/shareManagement/index","pages/210/onlineDevice/index","pages/210/addDevice/index","pages/210/historyRecords/index","pages/210/call/index","pages/BlueTooth/ModeSetting/VideoSend","pages/BlueTooth/ModeSetting/VideoSend_1","pages/BlueTooth/ModeSetting/VideoSend_670","pages/BlueTooth/ModeSetting/HBY650","pages/BlueTooth/ModeSetting/HBY650_1","pages/BlueTooth/ModeSetting/ModeSetting","pages/BlueTooth/ModeSetting/update","pages/BlueTooth/ModeSetting/HBY6155","pages/BlueTooth/ModeSetting/HBY6155V1","pages/BlueTooth/ModeSetting/HBY670V1","pages/670/HBY670","pages/650/HBY650","pages/670/History","pages/BlueTooth/ModeSetting/4877"],"window":{"navigationBarTextStyle":"white","navigationBarTitleText":"uni-app","navigationBarBackgroundColor":"#121212","backgroundColor":"#121212"},"tabBar":{"color":"#fff","selectedColor":"#BBE600","backgroundColor":"#202020","list":[{"pagePath":"pages/common/index/index","text":"我的设备","iconPath":"/static/tabs/device.png","selectedIconPath":"/static/tabs/device-HL.png"},{"pagePath":"pages/common/user/index","text":"我的","iconPath":"/static/tabs/my.png","selectedIconPath":"/static/tabs/my-HL.png"}]},"darkmode":false,"nvueCompiler":"uni-app","nvueStyleCompiler":"uni-app","renderer":"auto","splashscreen":{"alwaysShowBeforeRender":true,"autoclose":false},"appname":"星汉物联","compilerVersion":"4.75","entryPagePath":"pages/common/login/index","networkTimeout":{"request":60000,"connectSocket":60000,"uploadFile":60000,"downloadFile":60000}};
var __uniRoutes = [{"path":"/pages/common/login/index","meta":{"isQuit":true},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/index/index","meta":{"isQuit":true,"isTabBar":true},"window":{"navigationStyle":"custom","enablePullDownRefresh":true}},{"path":"/pages/common/user/index","meta":{"isQuit":true,"isTabBar":true},"window":{"navigationBarTitleText":"我的"}},{"path":"/pages/common/scan/scan","meta":{},"window":{"navigationBarTitleText":"扫描"}},{"path":"/pages/common/qrcode/qrcode","meta":{},"window":{"navigationBarTitleText":"扫描到的设备"}},{"path":"/pages/common/send/index","meta":{},"window":{"navigationBarTitleText":"发送信息","enablePullDownRefresh":true}},{"path":"/pages/common/userAgreement/index","meta":{},"window":{"navigationBarTitleText":"用户协议"}},{"path":"/pages/common/privacyAgreement/index","meta":{},"window":{"navigationBarTitleText":"隐私协议"}},{"path":"/pages/common/aboutUs/index","meta":{},"window":{"navigationBarTitleText":"关于我们"}},{"path":"/pages/6170/deviceControl/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/6170/callPolice/index","meta":{},"window":{"navigationBarTitleText":"报警","enablePullDownRefresh":true}},{"path":"/pages/210/deviceControl/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/operationVideo/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/addvideo/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/operatingInstruct/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/productDes/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/addBLE/addEquip","meta":{},"window":{"navigationBarTitleText":"添加设备"}},{"path":"/pages/common/addBLE/LinkBle","meta":{},"window":{"navigationBarTitleText":"扫描到的设备"}},{"path":"/pages/6155/deviceDetail","meta":{},"window":{"navigationBarTitleText":"HBY 6155"}},{"path":"/pages/6155/ImgCrop","meta":{},"window":{"navigationBarTitleText":"图像裁剪","navigationStyle":"custom","fullscreen":true}},{"path":"/pages/common/map/index","meta":{},"window":{"navigationBarTitleText":"地图"}},{"path":"/pages/common/allType/index","meta":{},"window":{"navigationBarTitleText":"所有类型"}},{"path":"/pages/6170/allShare/index","meta":{},"window":{"navigationBarTitleText":"所有分享"}},{"path":"/pages/6170/share/index","meta":{},"window":{"navigationBarTitleText":"分享"}},{"path":"/pages/6170/shareDevices/index","meta":{},"window":{"navigationBarTitleText":"分享设备"}},{"path":"/pages/6170/shareManagement/index","meta":{},"window":{"navigationBarTitleText":"分享管理"}},{"path":"/pages/210/onlineDevice/index","meta":{},"window":{"navigationBarTitleText":"联机设备"}},{"path":"/pages/210/addDevice/index","meta":{},"window":{"navigationBarTitleText":"添加联机设备"}},{"path":"/pages/210/historyRecords/index","meta":{},"window":{"navigationBarTitleText":"历史记录"}},{"path":"/pages/210/call/index","meta":{},"window":{"navigationBarTitleText":"呼叫"}},{"path":"/pages/BlueTooth/ModeSetting/VideoSend","meta":{},"window":{"navigationBarTitleText":"发送视频"}},{"path":"/pages/BlueTooth/ModeSetting/VideoSend_1","meta":{},"window":{"navigationBarTitleText":"发送视频"}},{"path":"/pages/BlueTooth/ModeSetting/VideoSend_670","meta":{},"window":{"navigationBarTitleText":"发送视频"}},{"path":"/pages/BlueTooth/ModeSetting/HBY650","meta":{},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/BlueTooth/ModeSetting/HBY650_1","meta":{},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/BlueTooth/ModeSetting/ModeSetting","meta":{},"window":{"navigationBarTitleText":"7307-0.96TFT"}},{"path":"/pages/BlueTooth/ModeSetting/update","meta":{},"window":{"navigationBarTitleText":"版本更新"}},{"path":"/pages/BlueTooth/ModeSetting/HBY6155","meta":{},"window":{"navigationBarTitleText":"HBY6155"}},{"path":"/pages/BlueTooth/ModeSetting/HBY6155V1","meta":{},"window":{"navigationBarTitleText":"HBY6155_V1"}},{"path":"/pages/BlueTooth/ModeSetting/HBY670V1","meta":{},"window":{"navigationBarTitleText":"HBY670"}},{"path":"/pages/670/HBY670","meta":{},"window":{"navigationBarTitleText":"HBY670","navigationStyle":"custom"}},{"path":"/pages/650/HBY650","meta":{},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/670/History","meta":{},"window":{"navigationBarTitleText":"历史记录"}},{"path":"/pages/BlueTooth/ModeSetting/4877","meta":{},"window":{"navigationBarTitleText":""}}];
var __uniConfig = {"pages":["pages/common/login/index","pages/common/index/index","pages/common/user/index","pages/common/scan/scan","pages/common/qrcode/qrcode","pages/common/send/index","pages/common/userAgreement/index","pages/common/privacyAgreement/index","pages/common/aboutUs/index","pages/6170/deviceControl/index","pages/6170/callPolice/index","pages/210/deviceControl/index","pages/common/operationVideo/index","pages/common/addvideo/index","pages/common/operatingInstruct/index","pages/common/productDes/index","pages/common/addBLE/addEquip","pages/common/addBLE/LinkBle","pages/6155/deviceDetail","pages/6155/ImgCrop","pages/common/map/index","pages/common/allType/index","pages/6170/allShare/index","pages/6170/share/index","pages/6170/shareDevices/index","pages/6170/shareManagement/index","pages/210/onlineDevice/index","pages/210/addDevice/index","pages/210/historyRecords/index","pages/210/call/index","pages/BlueTooth/ModeSetting/index","pages/BlueTooth/ModeSetting/VideoSend","pages/BlueTooth/ModeSetting/VideoSend_1","pages/BlueTooth/ModeSetting/VideoSend_670","pages/BlueTooth/ModeSetting/HBY650","pages/BlueTooth/ModeSetting/HBY650_1","pages/BlueTooth/ModeSetting/ModeSetting","pages/BlueTooth/ModeSetting/update","pages/BlueTooth/ModeSetting/HBY6155","pages/BlueTooth/ModeSetting/HBY6155V1","pages/BlueTooth/ModeSetting/HBY670V1","pages/670/HBY670","pages/650/HBY650","pages/670/History","pages/BlueTooth/ModeSetting/4877","pages/7305/BJQ7305"],"window":{"navigationBarTextStyle":"white","navigationBarTitleText":"uni-app","navigationBarBackgroundColor":"#121212","backgroundColor":"#121212"},"tabBar":{"color":"#fff","selectedColor":"#BBE600","backgroundColor":"#202020","list":[{"pagePath":"pages/common/index/index","text":"我的设备","iconPath":"/static/tabs/device.png","selectedIconPath":"/static/tabs/device-HL.png"},{"pagePath":"pages/common/user/index","text":"我的","iconPath":"/static/tabs/my.png","selectedIconPath":"/static/tabs/my-HL.png"}]},"darkmode":false,"nvueCompiler":"uni-app","nvueStyleCompiler":"uni-app","renderer":"auto","splashscreen":{"alwaysShowBeforeRender":true,"autoclose":false},"appname":"星汉物联","compilerVersion":"4.75","entryPagePath":"pages/common/login/index","networkTimeout":{"request":60000,"connectSocket":60000,"uploadFile":60000,"downloadFile":60000}};
var __uniRoutes = [{"path":"/pages/common/login/index","meta":{"isQuit":true},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/index/index","meta":{"isQuit":true,"isTabBar":true},"window":{"navigationStyle":"custom","enablePullDownRefresh":true}},{"path":"/pages/common/user/index","meta":{"isQuit":true,"isTabBar":true},"window":{"navigationBarTitleText":"我的"}},{"path":"/pages/common/scan/scan","meta":{},"window":{"navigationBarTitleText":"扫描"}},{"path":"/pages/common/qrcode/qrcode","meta":{},"window":{"navigationBarTitleText":"扫描到的设备"}},{"path":"/pages/common/send/index","meta":{},"window":{"navigationBarTitleText":"发送信息","enablePullDownRefresh":true}},{"path":"/pages/common/userAgreement/index","meta":{},"window":{"navigationBarTitleText":"用户协议"}},{"path":"/pages/common/privacyAgreement/index","meta":{},"window":{"navigationBarTitleText":"隐私协议"}},{"path":"/pages/common/aboutUs/index","meta":{},"window":{"navigationBarTitleText":"关于我们"}},{"path":"/pages/6170/deviceControl/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/6170/callPolice/index","meta":{},"window":{"navigationBarTitleText":"报警","enablePullDownRefresh":true}},{"path":"/pages/210/deviceControl/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/operationVideo/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/addvideo/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/operatingInstruct/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/productDes/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/addBLE/addEquip","meta":{},"window":{"navigationBarTitleText":"扫描设备"}},{"path":"/pages/common/addBLE/LinkBle","meta":{},"window":{"navigationBarTitleText":"绑定设备"}},{"path":"/pages/6155/deviceDetail","meta":{},"window":{"navigationBarTitleText":"HBY 6155"}},{"path":"/pages/6155/ImgCrop","meta":{},"window":{"navigationBarTitleText":"图像裁剪","navigationStyle":"custom","fullscreen":true}},{"path":"/pages/common/map/index","meta":{},"window":{"navigationBarTitleText":"地图"}},{"path":"/pages/common/allType/index","meta":{},"window":{"navigationBarTitleText":"所有类型"}},{"path":"/pages/6170/allShare/index","meta":{},"window":{"navigationBarTitleText":"所有分享"}},{"path":"/pages/6170/share/index","meta":{},"window":{"navigationBarTitleText":"分享"}},{"path":"/pages/6170/shareDevices/index","meta":{},"window":{"navigationBarTitleText":"分享设备"}},{"path":"/pages/6170/shareManagement/index","meta":{},"window":{"navigationBarTitleText":"分享管理"}},{"path":"/pages/210/onlineDevice/index","meta":{},"window":{"navigationBarTitleText":"联机设备"}},{"path":"/pages/210/addDevice/index","meta":{},"window":{"navigationBarTitleText":"添加联机设备"}},{"path":"/pages/210/historyRecords/index","meta":{},"window":{"navigationBarTitleText":"历史记录"}},{"path":"/pages/210/call/index","meta":{},"window":{"navigationBarTitleText":"呼叫"}},{"path":"/pages/BlueTooth/ModeSetting/index","meta":{},"window":{"navigationBarTitleText":"设备类型"}},{"path":"/pages/BlueTooth/ModeSetting/VideoSend","meta":{},"window":{"navigationBarTitleText":"发送视频"}},{"path":"/pages/BlueTooth/ModeSetting/VideoSend_1","meta":{},"window":{"navigationBarTitleText":"发送视频"}},{"path":"/pages/BlueTooth/ModeSetting/VideoSend_670","meta":{},"window":{"navigationBarTitleText":"发送视频"}},{"path":"/pages/BlueTooth/ModeSetting/HBY650","meta":{},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/BlueTooth/ModeSetting/HBY650_1","meta":{},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/BlueTooth/ModeSetting/ModeSetting","meta":{},"window":{"navigationBarTitleText":"7307-0.96TFT"}},{"path":"/pages/BlueTooth/ModeSetting/update","meta":{},"window":{"navigationBarTitleText":"版本更新"}},{"path":"/pages/BlueTooth/ModeSetting/HBY6155","meta":{},"window":{"navigationBarTitleText":"HBY6155"}},{"path":"/pages/BlueTooth/ModeSetting/HBY6155V1","meta":{},"window":{"navigationBarTitleText":"HBY6155_V1"}},{"path":"/pages/BlueTooth/ModeSetting/HBY670V1","meta":{},"window":{"navigationBarTitleText":"HBY670"}},{"path":"/pages/670/HBY670","meta":{},"window":{"navigationBarTitleText":"HBY670","navigationStyle":"custom"}},{"path":"/pages/650/HBY650","meta":{},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/670/History","meta":{},"window":{"navigationBarTitleText":"历史记录"}},{"path":"/pages/BlueTooth/ModeSetting/4877","meta":{},"window":{"navigationBarTitleText":""}},{"path":"/pages/7305/BJQ7305","meta":{},"window":{"navigationBarTitleText":"BJQ7305"}}];
__uniConfig.onReady=function(callback){if(__uniConfig.ready){callback()}else{onReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"ready",{get:function(){return isReady},set:function(val){isReady=val;if(!isReady){return}const callbacks=onReadyCallbacks.slice(0);onReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
__uniConfig.onServiceReady=function(callback){if(__uniConfig.serviceReady){callback()}else{onServiceReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"serviceReady",{get:function(){return isServiceReady},set:function(val){isServiceReady=val;if(!isServiceReady){return}const callbacks=onServiceReadyCallbacks.slice(0);onServiceReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
service.register("uni-app-config",{create(a,b,c){if(!__uniConfig.viewport){var d=b.weex.config.env.scale,e=b.weex.config.env.deviceWidth,f=Math.ceil(e/d);Object.assign(__uniConfig,{viewport:f,defaultFontSize:Math.round(f/20)})}return{instance:{__uniConfig:__uniConfig,__uniRoutes:__uniRoutes,global:void 0,window:void 0,document:void 0,frames:void 0,self:void 0,location:void 0,navigator:void 0,localStorage:void 0,history:void 0,Caches:void 0,screen:void 0,alert:void 0,confirm:void 0,prompt:void 0,fetch:void 0,XMLHttpRequest:void 0,WebSocket:void 0,webkit:void 0,print:void 0}}}});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -40,9 +40,9 @@ class BleHelper {
onDeviceFound: [], //发现新设备的事件
receivDataCallback: [] //接收到数据的事件
}
this.addReceiveCallback((a, b, c) => {
recei.ReceiveData(a, b, c);
}, "BleReceiveData");
// this.addReceiveCallback((a, b, c) => {
// recei.ReceiveData(a, b, c);
// }, "BleReceiveData");
this.dic = {
errRemarks: [{
key: '10000',
@ -104,6 +104,36 @@ class BleHelper {
}
}
DropDevice(bleId, deviceId) {
let flag = false;
for (var i = 0; i < this.data.LinkedList.length; i++) {
let item = this.data.LinkedList[i];
if (bleId) {
if (item.deviceId == bleId) {
this.data.LinkedList.splice(i, 1);
flag = true;
break;
}
} else {
if (item.device && item.device.id) {
this.data.LinkedList.splice(i, 1);
flag = true;
break;
}
}
}
if (flag) {
this.updateCache();
}
}
updateCache() {
console.log("this.StorageKey=", this.StorageKey)
uni.setStorageSync(this.StorageKey, this.data.LinkedList);
}
linkAllDevices() {
console.log("模块启动时,自动连接已连接过的设备", this.data.LinkedList);
@ -111,7 +141,7 @@ class BleHelper {
for (var i = 0; i < this.data.LinkedList.length; i++) {
let device = this.data.LinkedList[i];
// console.log("自动连接绑定过的设备:" + device.deviceId);
if(device.macAddress && device.device && device.device.id){
if (device.macAddress && device.device && device.device.id) {
this.LinkBlue(device.deviceId, device.writeServiceId, device.wirteCharactId, device
.notifyCharactId);
}
@ -162,7 +192,7 @@ class BleHelper {
let key = currKey ? currKey : this.getCurrentPagePath();
if (key) {
console.log("key=" + key);
// console.log("key=" + key);
let f = this.cfg.onDeviceFound.findIndex((v) => {
return v.key == key;
});
@ -205,7 +235,7 @@ class BleHelper {
removeReceiveCallback(currKey) {
let key = currKey ? currKey : this.getCurrentPagePath();
if (key) {
console.log("移除消息回调:" + key);
// console.log("移除消息回调:" + key);
let f = this.cfg.receivDataCallback.findIndex((v) => {
return v.key == key;
});
@ -399,8 +429,8 @@ class BleHelper {
v.notifyState = false;
return true;
});
uni.setStorageSync(this.StorageKey, this.data
.LinkedList);
this.updateCache();
}
});
@ -417,8 +447,7 @@ class BleHelper {
}
return false;
});
uni.setStorageSync(this.StorageKey, this.data
.LinkedList);
this.updateCache();
} else {
// console.log("蓝牙连接已恢复,", res);
}
@ -464,22 +493,26 @@ class BleHelper {
let header = "mac address:";
if (str.indexOf(header) == 0) { //650以文本传输mac
console.log("str=", str);
this.data.LinkedList.find((v) => {
if (v.deviceId == receive
.deviceId) {
str= str.replace(
let macStr = str.replace(
header, "");
if(str.includes(':')){
v.macAddress =str;
}else{
v.macAddress=str.replace(/(.{2})/g, '$1:').slice(0, -1)
if (macStr.includes(':')) {
v.macAddress = macStr;
} else {
v.macAddress = macStr
.replace(
/(.{2})/g, '$1:')
.slice(0, -1)
}
console.log("收到mac地址:", v.macAddress)
str = header + v.macAddress;
console.log("收到mac地址:", v
.macAddress)
}
});
uni.setStorageSync(this.StorageKey, this.data
.LinkedList);
this.updateCache();
}
if (bytes[0] == 0xFC) { //6155以0xFC开头代表mac地址
@ -495,8 +528,7 @@ class BleHelper {
// console.log("收到mac地址:", str)
}
});
uni.setStorageSync(this.StorageKey, this
.data.LinkedList);
this.updateCache();
}
}
console.log("str=", str);
@ -511,28 +543,36 @@ class BleHelper {
str: str,
hexs: hexs
};
console.log("监听到特征值:" + JSON.stringify(recData));
try{
// console.log("监听到特征值:" + JSON.stringify(recData));
try {
if (this.cfg.receivDataCallback) {
if (this.cfg.receivDataCallback.length > 0) {
console.log("有人订阅消息")
let path = this.getCurrentPagePath();
this.cfg.receivDataCallback.forEach((rec) => {
console.log("有人订阅消息")
this.cfg.receivDataCallback.forEach((
rec) => {
console.log("有人订阅消息111",)
if (rec.callback) {
rec.callback(recData, f, path);
try{
rec.callback(recData, f,
path, this.cfg
.receivDataCallback);
}catch(err){
console.log("订阅消息出现异常",err);
}
}
})
}else{
} else {
console.log("无人订阅消息");
}
} else {
console.log("无人订阅receivDataCallback,不处理数据");
}
}catch(ex){
console.log("ex=",ex);
} catch (ex) {
console.log("ex=", ex);
}
});
@ -687,9 +727,10 @@ class BleHelper {
}
// console.log("c=", c);
let startSubScribe = (id, serviceId, characteristicId) => {
console.log("serviceId=",serviceId);
console.log("characteristicId=",characteristicId);
return new Promise((succ, err) => {
// console.log("serviceId=", serviceId);
// console.log("characteristicId=", characteristicId);
let p1 = new Promise((succ, err) => {
uni.notifyBLECharacteristicValueChange({
deviceId: id,
serviceId: serviceId,
@ -707,7 +748,10 @@ class BleHelper {
v.notifyState = state;
}
});
succ();
// console.log("success SubScribe");
succ(
res
); //见了鬼了有时候执行了succ但promise永远pending了
},
fail: (ex) => {
@ -715,9 +759,27 @@ class BleHelper {
}
});
});
let p2 = new Promise((succ, err) => {
setTimeout(() => {
err({
code: -1
});
}, 50);
});
return new Promise((succ, err) => {
Promise.race([p1, p2]).then(succ).catch(ex => {
if (ex.code == -1) {
succ();
return;
}
err(ex);
})
});
}
let promies = new Array();
if(c.Characteristics && c.Characteristics.length){
if (c.Characteristics && c.Characteristics.length) {
for (var i = 0; i < c.Characteristics.length; i++) {
let item = c.Characteristics[i];
let serviceId = item.serviceId;
@ -730,22 +792,28 @@ class BleHelper {
}
if (promies.length > 0) {
Promise.allSettled(promies).then((results) => {
// console.log("234324324324");
Promise.allSettled(promies).then((results) => {
// console.log("11111");
results.forEach((result, index) => {
if (result.status === "fulfilled") {
console.log(`操作${index + 1}成功:`, result.value);
// console.log(`操作${index + 1}成功:`, result.value);
} else {
console.log(`操作${index + 1}失败:`, result.reason
.message);
// console.log(`操作${index + 1}失败:`, result.reason
// .message);
}
});
resolve();
}).catch((ex) => {
// console.log("222222");
reject(ex);
}).finally(() => {
// console.log("finally")
});
} else {
// console.log("33333");
resolve();
}
@ -777,8 +845,7 @@ class BleHelper {
v.services = res.services;
}
});
uni.setStorageSync(this.StorageKey,
this.data.LinkedList);
this.updateCache();
var promises = [];
let se = res.services.find((v) => {
@ -918,7 +985,7 @@ class BleHelper {
uni.setStorageSync(this.StorageKey, this.data.LinkedList);
this.updateCache();
resolve(res);
},
fail: (ex) => {
@ -960,18 +1027,20 @@ class BleHelper {
var linkDevice = () => {
// 添加重试次数限制
let retryCount = 0;
const maxRetries = 1; // 最大重试次数
const maxRetries = 5; // 最大重试次数
const connect = () => {
return new Promise((resolve, reject) => {
if (fIndex > -1 && f?.Linked) {
console.log("当前已连接,跳过其他步骤");
// console.log("当前已连接,跳过其他步骤");
resolve(false);
return;
}
if (!this.data.available) {
reject(this.getError({ code: 10001 }));
reject(this.getError({
code: 10001
}));
return;
}
@ -996,8 +1065,9 @@ class BleHelper {
this.data.LinkedList.push(cr);
}
uni.setStorageSync(this.StorageKey, this.data.LinkedList);
console.log("LinkedList=", this.data.LinkedList);
this.updateCache();
console.log("LinkedList=", this.data
.LinkedList);
// 处理 MTU 设置
if (plus.os.name === 'Android') {
@ -1005,12 +1075,15 @@ class BleHelper {
deviceId: deviceId,
mtu: 512,
success: (mtu) => {
console.log("mtu设置成功", mtu);
console.log("mtu设置成功",
mtu);
resolve(true);
},
fail: () => {
console.log("mtu设置失败");
resolve(true); // MTU设置失败不影响连接成功
resolve(
true
); // MTU设置失败不影响连接成功
}
});
} else {
@ -1053,21 +1126,21 @@ class BleHelper {
}).then((res) => {
if (res) { //新连接
console.log("11111111");
// console.log("11111111");
if (fIndex == -1) {
console.log("开始获取服务", targetServiceId)
// console.log("开始获取服务", targetServiceId)
return this.getService(deviceId, targetServiceId, writeCharId,
notifyCharId); //获取服务
} else {
if(f.wirteCharactId && f.notifyCharactId){
if (f.wirteCharactId && f.notifyCharactId) {
if (!f.notifyState) {
console.log("开始订阅特征");
// console.log("开始订阅特征");
this.subScribe(deviceId, true);
}else{
} else {
console.log("不订阅消息");
}
return Promise.resolve(true);
}else{
} else {
console.log("开始获取服务", targetServiceId)
return this.getService(deviceId, targetServiceId, writeCharId,
notifyCharId);
@ -1076,7 +1149,7 @@ class BleHelper {
}
} else { //已连接过,直接订阅消息
console.log("11111111");
// console.log("11111111");
if (fIndex > -1 && f && !f.notifyState) {
this.subScribe(deviceId, true);
@ -1085,13 +1158,13 @@ class BleHelper {
}
}).then(() => {
// console.log("then.....");
setTimeout(() => {
resolve();
}, 500);
}).catch((ex) => {
////console.log("出现异常", ex);
console.log("出现异常", ex);
reject(ex);
});
});
@ -1200,14 +1273,14 @@ class BleHelper {
})); //没有找到指定设备
return;
}
console.log("device=", device);
// console.log("device=", device);
uni.writeBLECharacteristicValue({
deviceId: device.deviceId,
serviceId: device.writeServiceId,
characteristicId: device.wirteCharactId,
value: buffer,
success: () => {
console.log("发送数据成功");
// console.log("发送数据成功");
succ();
},
fail: (ex) => {
@ -1305,9 +1378,7 @@ class BleHelper {
return result;
}
setBleData() {
uni.setStorageSync(this.StorageKey, this.data.LinkedList);
}
}
let instance = null;

View File

@ -44,21 +44,21 @@ class BleReceive {
}
ReceiveData(receive,f,path) {
ReceiveData(receive,f,path,recArr) {
if(f && f.macAddress && f.device && f.device.id){
let data={};
if(f.device.detailPageUrl=='/pages/6155/deviceDetail'){
// console.log("该设备是6155");
data= this.Receive_6155(receive,f,path);
data= this.Receive_6155(receive,f,path,recArr);
}
if(f.device.detailPageUrl=='/pages/650/HBY650'){
// console.log("该设备是650");
data= this.Receive_650(receive,f,path);
data= this.Receive_650(receive,f,path,recArr);
}
if(f.device.detailPageUrl=='/pages/670/HBY670'){
// console.log("该设备是670");
data= this.Receive_670(receive,f,path);
data= this.Receive_670(receive,f,path,recArr);
}
// console.log("收到数据并处理完毕,",data);
return data;
@ -70,7 +70,7 @@ class BleReceive {
}
Receive_650(receive,f,path) {
Receive_650(receive,f,path,recArr) {
console.log("通用程序正在处理650的数据",receive);
var parseData = () => {
@ -253,8 +253,8 @@ class BleReceive {
}
Receive_670(receive,f,path){
Receive_670(receive,f,path,recArr){
console.log("pagh=",path);
var todo = (bytes) =>{
// console.log("todo",receive);
let receiveData = {};
@ -316,6 +316,21 @@ class BleReceive {
receiveData.staticWarn = staticWarn;
receiveData.fourGStrenth = fourGStrenth;
receiveData.SOS=sosTxt;
this.setBleFormData(receiveData,f);
console.log("recArr=",recArr);
let recCnt=recArr.find(v=>{
return v.key == f.device.detailPageUrl;
});
if(!recCnt){
if (this.formData.staticWarn) { //有静止报警
uni.showModal({
title:"警告",
content:"设备静止报警中",
showCancel:false
});
}
}
} catch(error) {
console.log('数据解析错误:', error);
}
@ -394,7 +409,7 @@ class BleReceive {
return data;
}
Receive_6155(receive,f,path) {
Receive_6155(receive,f,path,recArr) {
let bytes=receive.bytes;
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
try {

View File

@ -1,3 +1,5 @@
import request,{baseURL} from '@/utils/request.js'
/**
* 检查并执行wgt热更新
* @param {String} updateUrl - 检查更新的接口地址
@ -13,53 +15,90 @@ function checkAndUpdateWgt(updateUrl) {
plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
const currentVersion = widgetInfo.version;
console.log("当前版本:" + currentVersion);
// 2. 调用后端接口检查是否有更新
uni.request({
url: updateUrl,
method: 'GET',
data: {
currentVersion: currentVersion,
platform: uni.getSystemInfoSync().platform
},
success: (res) => {
uni.hideLoading();
console.log("res=", res)
if (res.statusCode === 200) {
const updateInfo = res.data.data;
if (!updateInfo.hasUpdate) {
request({
url:'/app/auth/version',
method: 'get'
}).then(res=>{
console.log("检查版本更新:",res);
let os=plus.os.name.toLowerCase();
if(res.code!=200){
return;
}
// 3. 显示更新提示
let f=res.data.find(v=>{
if(v.dictLabel.toLowerCase()==os){
return true;
}
return false;
});
if(f){
if(f.dictValue==currentVersion){
return;
}
uni.showModal({
title: '检测到更新',
content: updateInfo.description || '有新版本可用,是否立即更新?',
content: '当前版本“'+currentVersion+'”,发现新版本“'+f.dictValue+'”,是否立即更新?',
confirmText: '立即更新',
cancelText: '稍后更新',
success: (modalRes) => {
if (modalRes.confirm) {
downloadAndInstallWgt(updateInfo.downloadUrl);
downloadAndInstallWgt(f.remark);
}
}
});
} else {
uni.showToast({
title: '当前已是最新版本',
icon: 'none',
duration: 2000
});
}
},
fail: (err) => {
uni.hideLoading();
uni.showToast({
title: '检查更新失败',
icon: 'none',
duration: 2000
});
console.error('检查更新失败:', err);
}
}).catch(ex=>{
console.log("检查更新失败:",ex);
});
// 2. 调用后端接口检查是否有更新
// uni.request({
// url: updateUrl,
// method: 'GET',
// data: {
// currentVersion: currentVersion,
// platform: uni.getSystemInfoSync().platform
// },
// success: (res) => {
// uni.hideLoading();
// console.log("res=", res)
// if (res.statusCode === 200) {
// const updateInfo = res.data.data;
// if (!updateInfo.hasUpdate) {
// return;
// }
// // 3. 显示更新提示
// uni.showModal({
// title: '检测到更新',
// content: updateInfo.description || '有新版本可用,是否立即更新?',
// confirmText: '立即更新',
// cancelText: '稍后更新',
// success: (modalRes) => {
// if (modalRes.confirm) {
// downloadAndInstallWgt(updateInfo.downloadUrl);
// }
// }
// });
// } else {
// uni.showToast({
// title: '当前已是最新版本',
// icon: 'none',
// duration: 2000
// });
// }
// },
// fail: (err) => {
// uni.hideLoading();
// uni.showToast({
// title: '检查更新失败',
// icon: 'none',
// duration: 2000
// });
// console.error('检查更新失败:', err);
// }
// });
});
}