增加蓝牙设备人员信息登记上传
This commit is contained in:
@ -17,6 +17,7 @@ function getdata(data,url,method){
|
|||||||
console.log("res=",res);
|
console.log("res=",res);
|
||||||
resolve(res);
|
resolve(res);
|
||||||
}).catch(ex=>{
|
}).catch(ex=>{
|
||||||
|
console.log("ex=",ex);
|
||||||
reject(ex);
|
reject(ex);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -145,20 +145,20 @@
|
|||||||
<script>
|
<script>
|
||||||
import TextToHexV1 from '@/components/TextToHex/TextToHexV1.vue';
|
import TextToHexV1 from '@/components/TextToHex/TextToHexV1.vue';
|
||||||
import bleTool from '@/utils/BleHelper.js';
|
import bleTool from '@/utils/BleHelper.js';
|
||||||
|
import usrApi from '@/api/670/HBY670.js'
|
||||||
import {
|
import {
|
||||||
showLoading,
|
showLoading,
|
||||||
hideLoading,
|
hideLoading,
|
||||||
updateLoading
|
updateLoading
|
||||||
} from '@/utils/loading.js'
|
} from '@/utils/loading.js'
|
||||||
import {
|
import BleReceive from '@/utils/BleReceive';
|
||||||
registerPersonInfo
|
|
||||||
} from '@/api/6170/deviceControl.js';
|
|
||||||
|
|
||||||
|
|
||||||
var ble = null;
|
var ble = null;
|
||||||
var these = null;
|
var these = null;
|
||||||
var BrighInteval = null;
|
var BrighInteval = null;
|
||||||
|
var recei = null;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
TextToHexV1
|
TextToHexV1
|
||||||
@ -261,6 +261,7 @@
|
|||||||
},
|
},
|
||||||
onLoad: function() {
|
onLoad: function() {
|
||||||
these = this;
|
these = this;
|
||||||
|
recei = BleReceive.getBleReceive();
|
||||||
ble = bleTool.getBleTool();
|
ble = bleTool.getBleTool();
|
||||||
// let bleName = 'FB_Site_UART'; //JQZM-EF4651 FB_Site_UART
|
// let bleName = 'FB_Site_UART'; //JQZM-EF4651 FB_Site_UART
|
||||||
|
|
||||||
@ -392,9 +393,13 @@
|
|||||||
|
|
||||||
return f;
|
return f;
|
||||||
},
|
},
|
||||||
bleValueNotify: function(receive) {
|
bleValueNotify: function(receive, device, path) {
|
||||||
console.log("处理接收到的数据:" + receive);
|
|
||||||
|
|
||||||
|
let str = recei.ReceiveData(receive, device, pagePath);
|
||||||
|
|
||||||
|
console.log("处理接收到的数据:" + str);
|
||||||
|
return;
|
||||||
|
let data = recei.ReceiveData(receive, device, pagePath);
|
||||||
let bytes = receive.bytes;
|
let bytes = receive.bytes;
|
||||||
|
|
||||||
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
|
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
|
||||||
@ -1120,19 +1125,16 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// let formdata = {
|
|
||||||
// code:"",
|
|
||||||
// name: these.formData.textLines[2],
|
let json = {
|
||||||
// position: these.formData.textLines[1],
|
deviceId: these.device.id,
|
||||||
// unitName: these.formData.textLines[0],
|
name: these.formData.textLines[2],
|
||||||
// deviceId: these.device.id,
|
position: these.formData.textLines[0],
|
||||||
// deviceImei: these.device.deviceImei
|
unitName: these.formData.textLines[1],
|
||||||
// };
|
code: ""
|
||||||
// registerPersonInfo(formdata).then(res=>{
|
};
|
||||||
// console.log("res=",res);
|
usrApi.sendUsr(json)
|
||||||
// }).catch(ex=>{
|
|
||||||
// console.log("ex=",ex);
|
|
||||||
// });
|
|
||||||
} else {
|
} else {
|
||||||
this.showPop({
|
this.showPop({
|
||||||
message: "出现异常发送失败",
|
message: "出现异常发送失败",
|
||||||
|
|||||||
@ -174,10 +174,8 @@
|
|||||||
updateLoading
|
updateLoading
|
||||||
} from '@/utils/loading.js'
|
} from '@/utils/loading.js'
|
||||||
import {request,baseURL} from '../../utils/request';
|
import {request,baseURL} from '../../utils/request';
|
||||||
import {
|
|
||||||
registerPersonInfo
|
|
||||||
} from '@/api/6170/deviceControl.js';
|
|
||||||
|
|
||||||
|
import usrApi from '@/api/670/HBY670.js'
|
||||||
const pagePath = "pages/650/HBY650";
|
const pagePath = "pages/650/HBY650";
|
||||||
var ble = null;
|
var ble = null;
|
||||||
var these = null;
|
var these = null;
|
||||||
@ -1199,15 +1197,15 @@
|
|||||||
});
|
});
|
||||||
these.setBleFormData();
|
these.setBleFormData();
|
||||||
|
|
||||||
// let formdata = {
|
|
||||||
// code: these.formData.id,
|
let json = {
|
||||||
// name: these.formData.name,
|
deviceId: these.device.id,
|
||||||
// position: these.formData.job,
|
name: these.formData.company,
|
||||||
// unitName: these.formData.company,
|
position: these.formData.name,
|
||||||
// deviceId: these.device.id,
|
unitName: these.formData.job,
|
||||||
// deviceImei: these.device.deviceImei
|
code: these.formData.id
|
||||||
// };
|
};
|
||||||
// registerPersonInfo(formdata);
|
usrApi.sendUsr(json)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -253,11 +253,9 @@
|
|||||||
request,
|
request,
|
||||||
baseURL
|
baseURL
|
||||||
} from '../../utils/request';
|
} from '../../utils/request';
|
||||||
import {
|
|
||||||
registerPersonInfo
|
|
||||||
} from '@/api/6170/deviceControl.js';
|
|
||||||
|
|
||||||
const pagePath = "pages/650/HBY650";
|
|
||||||
|
const pagePath = "pages/670/HBY670";
|
||||||
var ble = null;
|
var ble = null;
|
||||||
var these = null;
|
var these = null;
|
||||||
var recei = null;
|
var recei = null;
|
||||||
@ -1874,15 +1872,14 @@
|
|||||||
hideLoading(these);
|
hideLoading(these);
|
||||||
|
|
||||||
|
|
||||||
// let formdata = {
|
let json = {
|
||||||
// code: these.formData.usrid,
|
deviceId: these.device.id,
|
||||||
// name: these.formData.usrname,
|
name: these.formData.company,
|
||||||
// position: these.formData.job,
|
position: these.formData.usrname,
|
||||||
// unitName: these.formData.company,
|
unitName: these.formData.job,
|
||||||
// deviceId: these.device.id,
|
code: these.formData.usrid
|
||||||
// deviceImei: these.device.deviceImei
|
};
|
||||||
// };
|
api.sendUsr(json)
|
||||||
// registerPersonInfo(formdata);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -896,7 +896,7 @@
|
|||||||
console
|
console
|
||||||
.log(
|
.log(
|
||||||
"收到mac地址:",
|
"收到mac地址:",
|
||||||
+
|
|
||||||
this
|
this
|
||||||
.receiveData
|
.receiveData
|
||||||
.macAddress
|
.macAddress
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="btnLink" @click="Link()">
|
<view class="btnLink" @click="Link()">
|
||||||
连接
|
绑定
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<global-loading ref="loading" />
|
<global-loading ref="loading" />
|
||||||
@ -124,7 +124,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
let inteval = setInterval(this.initDevice, 5000);
|
// let inteval = setInterval(this.initDevice, 5000);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
@ -152,7 +152,7 @@
|
|||||||
ble.data.LinkedList.find((v) => {
|
ble.data.LinkedList.find((v) => {
|
||||||
if (v.deviceId == these.device.deviceId) {
|
if (v.deviceId == these.device.deviceId) {
|
||||||
for (var i = 0; i < keys.length; i++) {
|
for (var i = 0; i < keys.length; i++) {
|
||||||
// let key = keys[i];
|
let key = keys[i];
|
||||||
// if(!v.device){
|
// if(!v.device){
|
||||||
// v.device={};
|
// v.device={};
|
||||||
// }
|
// }
|
||||||
@ -221,7 +221,8 @@
|
|||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
these.Statu.bound = true;
|
these.Statu.bound = true;
|
||||||
these.Statu.boundRemark = "设备绑定成功!";
|
these.Statu.boundRemark = "设备绑定成功!";
|
||||||
|
let data=these.serverDevice;
|
||||||
|
let keys = Object.keys(data);
|
||||||
ble.data.LinkedList.find((v) => {
|
ble.data.LinkedList.find((v) => {
|
||||||
if (v.deviceId == these.device.deviceId) {
|
if (v.deviceId == these.device.deviceId) {
|
||||||
for (var i = 0; i < keys.length; i++) {
|
for (var i = 0; i < keys.length; i++) {
|
||||||
@ -251,6 +252,7 @@
|
|||||||
}).catch((ex) => {
|
}).catch((ex) => {
|
||||||
these.Statu.bound = false;
|
these.Statu.bound = false;
|
||||||
these.Statu.boundRemark = '出现了未知的异常,操作失败';
|
these.Statu.boundRemark = '出现了未知的异常,操作失败';
|
||||||
|
console.log("ex=",ex);
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
hideLoading(this);
|
hideLoading(this);
|
||||||
});
|
});
|
||||||
|
|||||||
636
unpackage/dist/dev/app-plus/app-service.js
vendored
636
unpackage/dist/dev/app-plus/app-service.js
vendored
File diff suppressed because one or more lines are too long
2
unpackage/dist/dev/app-plus/app-view.js
vendored
2
unpackage/dist/dev/app-plus/app-view.js
vendored
@ -13231,7 +13231,7 @@ var render = function () {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[_vm._v("连接")]
|
[_vm._v("绑定")]
|
||||||
),
|
),
|
||||||
_c("global-loading", { ref: "loading", attrs: { _i: 9 } }),
|
_c("global-loading", { ref: "loading", attrs: { _i: 9 } }),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -468,9 +468,14 @@ class BleHelper {
|
|||||||
this.data.LinkedList.find((v) => {
|
this.data.LinkedList.find((v) => {
|
||||||
if (v.deviceId == receive
|
if (v.deviceId == receive
|
||||||
.deviceId) {
|
.deviceId) {
|
||||||
v.macAddress = str.replace(
|
str= str.replace(
|
||||||
header, "");
|
header, "");
|
||||||
console.log("收到mac地址:", str)
|
if(str.includes(':')){
|
||||||
|
v.macAddress =str;
|
||||||
|
}else{
|
||||||
|
v.macAddress=str.replace(/(.{2})/g, '$1:').slice(0, -1)
|
||||||
|
}
|
||||||
|
console.log("收到mac地址:", v.macAddress)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
uni.setStorageSync(this.StorageKey, this.data
|
uni.setStorageSync(this.StorageKey, this.data
|
||||||
@ -507,10 +512,11 @@ class BleHelper {
|
|||||||
hexs: hexs
|
hexs: hexs
|
||||||
};
|
};
|
||||||
console.log("监听到特征值:" + JSON.stringify(recData));
|
console.log("监听到特征值:" + JSON.stringify(recData));
|
||||||
|
try{
|
||||||
if (this.cfg.receivDataCallback) {
|
if (this.cfg.receivDataCallback) {
|
||||||
|
|
||||||
if (this.cfg.receivDataCallback.length > 0) {
|
if (this.cfg.receivDataCallback.length > 0) {
|
||||||
|
console.log("有人订阅消息")
|
||||||
let path = this.getCurrentPagePath();
|
let path = this.getCurrentPagePath();
|
||||||
|
|
||||||
this.cfg.receivDataCallback.forEach((rec) => {
|
this.cfg.receivDataCallback.forEach((rec) => {
|
||||||
@ -519,10 +525,16 @@ class BleHelper {
|
|||||||
rec.callback(recData, f, path);
|
rec.callback(recData, f, path);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}else{
|
||||||
|
console.log("无人订阅消息");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log("无人订阅receivDataCallback,不处理数据");
|
console.log("无人订阅receivDataCallback,不处理数据");
|
||||||
}
|
}
|
||||||
|
}catch(ex){
|
||||||
|
console.log("ex=",ex);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -948,7 +960,7 @@ class BleHelper {
|
|||||||
var linkDevice = () => {
|
var linkDevice = () => {
|
||||||
// 添加重试次数限制
|
// 添加重试次数限制
|
||||||
let retryCount = 0;
|
let retryCount = 0;
|
||||||
const maxRetries = 10; // 最大重试次数
|
const maxRetries = 1; // 最大重试次数
|
||||||
|
|
||||||
const connect = () => {
|
const connect = () => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|||||||
@ -45,25 +45,27 @@ class BleReceive {
|
|||||||
|
|
||||||
|
|
||||||
ReceiveData(receive,f,path) {
|
ReceiveData(receive,f,path) {
|
||||||
if(f && f.macAddress && f.id){
|
if(f && f.macAddress && f.device && f.device.id){
|
||||||
let data={};
|
let data={};
|
||||||
if(f.detailPageUrl=='/pages/6155/deviceDetail'){
|
if(f.device.detailPageUrl=='/pages/6155/deviceDetail'){
|
||||||
// console.log("该设备是6155");
|
// console.log("该设备是6155");
|
||||||
data= this.Receive_6155(receive,f,path);
|
data= this.Receive_6155(receive,f,path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(f.detailPageUrl=='/pages/650/HBY650'){
|
if(f.device.detailPageUrl=='/pages/650/HBY650'){
|
||||||
// console.log("该设备是650");
|
// console.log("该设备是650");
|
||||||
data= this.Receive_650(receive,f,path);
|
data= this.Receive_650(receive,f,path);
|
||||||
}
|
}
|
||||||
if(f.detailPageUrl=='/pages/670/HBY670'){
|
if(f.device.detailPageUrl=='/pages/670/HBY670'){
|
||||||
// console.log("该设备是670");
|
// console.log("该设备是670");
|
||||||
data= this.Receive_670(receive,f,path);
|
data= this.Receive_670(receive,f,path);
|
||||||
}
|
}
|
||||||
// console.log("收到数据并处理完毕,",data);
|
// console.log("收到数据并处理完毕,",data);
|
||||||
return data;
|
return data;
|
||||||
|
}else{
|
||||||
|
console.log("已收到该消息,但无法处理",receive);
|
||||||
}
|
}
|
||||||
// console.log("已收到该消息,但无法处理",receive);
|
|
||||||
return receive;
|
return receive;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -392,8 +394,81 @@ class BleReceive {
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
Receive_6155() {
|
Receive_6155(receive,f,path) {
|
||||||
console.log("通用程序正在处理6155的数据");
|
let bytes=receive.bytes;
|
||||||
|
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
let staticLevelByte = bytes[2];
|
||||||
|
let getName = function(type) {
|
||||||
|
let name = "";
|
||||||
|
switch (type) {
|
||||||
|
case 0x02:
|
||||||
|
name = '弱光';
|
||||||
|
break;
|
||||||
|
case 0x04:
|
||||||
|
name = '工作光';
|
||||||
|
break;
|
||||||
|
case 0x01:
|
||||||
|
name = '强光';
|
||||||
|
break;
|
||||||
|
case 0x03:
|
||||||
|
name = '爆闪';
|
||||||
|
break;
|
||||||
|
case 0x00:
|
||||||
|
name = '关闭';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
let staticLevelText = getName(staticLevelByte);
|
||||||
|
|
||||||
|
// 解析照明档位
|
||||||
|
let lightingLevelByte = bytes[3];
|
||||||
|
let lightingLevelText = getName(lightingLevelByte);
|
||||||
|
|
||||||
|
|
||||||
|
// 解析剩余电量
|
||||||
|
let batteryLevelByte = bytes[4];
|
||||||
|
// 电量百分比范围检查
|
||||||
|
let batteryLevel = Math.max(0, Math.min(100, batteryLevelByte));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//充电状态
|
||||||
|
let warn = bytes[5];
|
||||||
|
if (warn == 0x00) {
|
||||||
|
warn = '未充电';
|
||||||
|
} else if (warn == 0x01) {
|
||||||
|
warn = '充电中';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解析剩余照明时间(第三和第四字节,小端序)
|
||||||
|
let lightingTime = "";
|
||||||
|
let HH = Math.max(0, Math.min(100, bytes[6]));
|
||||||
|
let mm = Math.max(0, Math.min(100, bytes[7]));
|
||||||
|
lightingTime = HH + "小时" + mm + "分钟";
|
||||||
|
let formData={};
|
||||||
|
formData.mode = staticLevelText;
|
||||||
|
formData.fuMode = lightingLevelText;
|
||||||
|
formData.battary = batteryLevel;
|
||||||
|
formData.statu = warn;
|
||||||
|
formData.xuhang = lightingTime;
|
||||||
|
|
||||||
|
if (batteryLevel <= 20) {
|
||||||
|
uni.showModal({
|
||||||
|
content:"设备电量低",
|
||||||
|
title:"提示"
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
this.setBleFormData(formData,f);
|
||||||
|
return formData;
|
||||||
|
} catch (error) {
|
||||||
|
console.log('数据解析错误:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user