蓝牙模块添加在web平台默认成功方便调试功能,4877功能完成

This commit is contained in:
liub
2025-10-27 10:52:17 +08:00
parent d37ccfeabc
commit 61ed91695f
13 changed files with 575 additions and 318 deletions

View File

@ -2,23 +2,24 @@
<view class="content contentBg">
<view class="eq">
<view class="leftImg" @click.stop="previewImg(formData.img)">
<image class="img" :src="formData.img?formData.img:'/static/images/4877/4877equip.png'" mode="aspectFit"></image>
<image class="img" :src="formData.img?formData.img:'/static/images/4877/4877equip.png'"
mode="aspectFit"></image>
</view>
<view class="rightTxt">
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.sta_PowerPercent}}%</view>
<view class="bigTxt">{{formData.sta_battery}}%</view>
<view class="smallTxt">电量</view>
</view>
</view>
<!-- <view class="row">
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.xuhang}}</view>
<view class="smallTxt">续航时间</view>
</view>
</view> -->
</view>
</view>
</view>
<view class="eqinfo">
@ -36,12 +37,7 @@
</view>
</view>
<view class="warnnig" v-bind:class="formData.sta_SOSType=='sos'?'':'displayNone'" @click.stop="showUnWarn('sos_off')">
<view>设备强制报警中</view>
<view class="netContent">
{{formData.warnTime}}s
</view>
</view>
<view class="lamp">
@ -245,12 +241,12 @@
var ble = null;
var these = null;
var recei = null;
var interval=null;
var interval = null;
export default {
data() {
return {
Status: {
pageHide: false,
Pop: {
showPop: false, //是否显示弹窗
popType: 'custom',
@ -311,7 +307,7 @@
},
formData: {
img: '/static/images/4877/4877equip.png',
sta_PowerPercent: '',
sta_battery: '',
xuhang: '',
blename: '',
deviceId: '',
@ -320,10 +316,14 @@
statu: '',
macAddress: '',
bleStatu: false,
sta_SOSType: '', //sos
sta_GroupType: '', //配组
sta_ArrowType: '', //箭头方向
warnTime:0
sta_address: '',
sta_VoiceType: '',
sta_VoiceVolume: '',
sta_LightType: '',
sta_LightFreq: '',
sta_LightDimmer: '',
sta_system: ''
},
dic: {
SOS: [{
@ -438,7 +438,7 @@
these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName;
these.formData.img = device.devicePic;
these.formData.bleStatu=false;
these.formData.bleStatu = false;
these.formData.deviceId = f.deviceId;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true;
@ -510,7 +510,7 @@
buttonBgColor: "#E03434",
okCallback: () => {
clearInterval(interval);
this.sosSetting({
val: val
});
@ -528,30 +528,30 @@
return;
}
let task = () => {
var json = {
ins_SOSType: this.formData.sta_SOSType==item.val?'sos_off':item.val
ins_SOSType: this.formData.sta_SOSType == item.val ? 'sos_off' : item.val
}
json = JSON.stringify(json);
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res=>{
if (this.formData.sta_SOSType === item.val) {
this.formData.sta_SOSType = 'sos_off';
} else {
this.formData.sta_SOSType = item.val;
}
if(this.formData.sta_SOSType=='sos'){
this.formData.warnTime=0;
clearInterval(interval);
interval=setInterval(()=>{
this.formData.warnTime+=1;
},1000)
}
})
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
if (this.formData.sta_SOSType === item.val) {
this.formData.sta_SOSType = 'sos_off';
} else {
this.formData.sta_SOSType = item.val;
}
if (this.formData.sta_SOSType == 'sos') {
this.formData.warnTime = 0;
clearInterval(interval);
interval = setInterval(() => {
this.formData.warnTime += 1;
}, 1000)
}
})
.catch(ex => {
this.showMsg(ex.msg);
});
@ -569,12 +569,12 @@
});
} else {
if(index!==undefined && this.formData.sta_SOSType=='sos'){
if (index !== undefined && this.formData.sta_SOSType == 'sos') {
this.showUnWarn(item.val);
}else{
task();
} else {
task();
}
}
@ -688,36 +688,58 @@
return className;
},
bleValueNotify: function(receive, device, path, recArr) { //订阅消息
if (receive.deviceId !== this.formData.deviceId) {
return;
}
console.log("收到设备的数据", receive)
let data = recei.ReceiveData(receive, device, pagePath, recArr);
console.log("处理后的数据:", data);
if (data) {
let keys = Object.keys(data);
keys.forEach(key => {
if (key in this.formData) {
this.formData[key] = data[key];
let json = recei.ReceiveData(receive, device, pagePath, recArr);
let key = 'sta_VoiceDate';
if (key in json) {
let val = json[key];
console.log("22222", val)
if (val === 'start') {
//开始发包
this.sendHex();
return;
} else if (val === 'finish') {
uni.showModal({
title: '提示',
content: "发送完成"
});
return;
} else {
//重新发送某一包
if (val > this.audioData.packetCtn) {
return;
}
});
let msg = [];
if (data.sta_SOSType == 'sos') {
msg.push("设备声光报警中");
}
if (data.sta_PowerPercent <= 20) {
msg.push("设备电量低");
this.sendHex(val);
return;
}
if (msg.length) {
msg = msg.join(",");
this.showMsg(msg);
}
these.setBleFormData();
}
let keys = Object.keys(json);
keys.forEach(key => {
if (key in this.formData) {
this.formData[key] = json[key];
}
})
// // 转换为字节数组
// const bytes = receive.bytes;
// parseData(bytes);
@ -754,7 +776,7 @@
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '去连接',
buttonTextColor: '#FFFFFFde',
buttonTextColor: '#232323de',
okCallback: function() {
uni.navigateTo({
@ -826,7 +848,7 @@
}
},
showPop: function(option) {
hideLoading(this);
let def = {
showPop: true, //是否显示弹窗
popType: 'custom',

View File

@ -2,7 +2,8 @@
<view class="content contentBg">
<view class="eq">
<view class="leftImg" @click.stop="previewImg(formData.img)">
<image class="img" :src="formData.img?formData.img:'/static/images/4877/4877equip.png'" mode="aspectFit"></image>
<image class="img" :src="formData.img?formData.img:'/static/images/4877/4877equip.png'"
mode="aspectFit"></image>
</view>
<view class="rightTxt">
<view class="row">
@ -36,7 +37,8 @@
</view>
</view>
<view class="warnnig" v-bind:class="formData.sta_SOSType=='sos'?'':'displayNone'" @click.stop="showUnWarn('sos_off')">
<view class="warnnig" v-bind:class="formData.sta_SOSType=='sos'?'':'displayNone'"
@click.stop="showUnWarn('sos_off')">
<view>设备强制报警中</view>
<view class="netContent">
{{formData.warnTime}}s
@ -47,7 +49,7 @@
<view class="lamp">
<view class="title">
<text>SOS</text>
<view @click.stop="sosSetting({val:'sos_off'})">
<view @click.stop="sosSetting({val:'sos_off'},-1)">
<image class="img" src="/static/images/common/close.png" mode="aspectFit"></image>
</view>
</view>
@ -245,12 +247,12 @@
var ble = null;
var these = null;
var recei = null;
var interval=null;
var interval = null;
export default {
data() {
return {
Status: {
pageHide: false,
Pop: {
showPop: false, //是否显示弹窗
popType: 'custom',
@ -323,7 +325,7 @@
sta_SOSType: '', //sos
sta_GroupType: '', //配组
sta_ArrowType: '', //箭头方向
warnTime:0
warnTime: 0
},
dic: {
SOS: [{
@ -398,11 +400,11 @@
ble = BleTool.getBleTool();
ble.addReceiveCallback(these.bleValueNotify, pagePath);
ble.addStateBreakCallback(these.bleStateBreak, pagePath);
ble.addStateRecoveryCallback(these.bleStateRecovry, pagePath);
ble.addDisposeCallback(these.deviceDispose, pagePath);
ble.addRecoveryCallback(these.deviceRecovry, pagePath);
ble.addReceiveCallback(this.bleValueNotify, pagePath);
ble.addStateBreakCallback(this.bleStateBreak, pagePath);
ble.addStateRecoveryCallback(this.bleStateRecovry, pagePath);
ble.addDisposeCallback(this.deviceDispose, pagePath);
ble.addRecoveryCallback(this.deviceRecovry, pagePath);
let eventChannel = this.getOpenerEventChannel();
@ -438,7 +440,7 @@
these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName;
these.formData.img = device.devicePic;
these.formData.bleStatu=false;
these.formData.bleStatu = false;
these.formData.deviceId = f.deviceId;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true;
@ -467,19 +469,18 @@
return;
}
if (this.formData.sta_ArrowType === val) {
this.formData.sta_ArrowType = 'arrow_off';
} else {
this.formData.sta_ArrowType = val;
val = 'arrow_off';
}
var json = {
ins_ArrowType: this.formData.sta_ArrowType
ins_ArrowType: val
}
json = JSON.stringify(json);
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30)
.catch(ex => {
this.showMsg(ex.msg);
});
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
this.formData.sta_ArrowType = val;
}).catch(ex => {
this.showMsg(ex.msg);
});
},
groupSetting(item, index) {
let f = this.getDevice();
@ -510,7 +511,7 @@
buttonBgColor: "#E03434",
okCallback: () => {
clearInterval(interval);
this.sosSetting({
val: val
});
@ -528,30 +529,31 @@
return;
}
let task = () => {
var json = {
ins_SOSType: this.formData.sta_SOSType==item.val?'sos_off':item.val
ins_SOSType: this.formData.sta_SOSType == item.val ? 'sos_off' : item.val
}
json = JSON.stringify(json);
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res=>{
if (this.formData.sta_SOSType === item.val) {
this.formData.sta_SOSType = 'sos_off';
} else {
this.formData.sta_SOSType = item.val;
}
if(this.formData.sta_SOSType=='sos'){
this.formData.warnTime=0;
clearInterval(interval);
interval=setInterval(()=>{
this.formData.warnTime+=1;
},1000)
}
})
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
if (this.formData.sta_SOSType === item.val) {
this.formData.sta_SOSType = 'sos_off';
} else {
this.formData.sta_SOSType = item.val;
}
if (this.formData.sta_SOSType == 'sos') {
this.formData.warnTime = 0;
clearInterval(interval);
interval = setInterval(() => {
this.formData.warnTime += 1;
}, 1000)
}
})
.catch(ex => {
this.showMsg(ex.msg);
});
@ -569,12 +571,12 @@
});
} else {
if(index!==undefined && this.formData.sta_SOSType=='sos'){
if (index !== undefined && this.formData.sta_SOSType == 'sos') {
this.showUnWarn(item.val);
}else{
task();
} else {
task();
}
}
@ -688,6 +690,9 @@
return className;
},
bleValueNotify: function(receive, device, path, recArr) { //订阅消息
if (receive.deviceId !== this.formData.deviceId) {
return;
}
console.log("收到设备的数据", receive)
let data = recei.ReceiveData(receive, device, pagePath, recArr);
console.log("处理后的数据:", data);
@ -754,7 +759,7 @@
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '去连接',
buttonTextColor: '#FFFFFFde',
buttonTextColor: '#232323de',
okCallback: function() {
uni.navigateTo({
@ -826,7 +831,7 @@
}
},
showPop: function(option) {
hideLoading(this);
let def = {
showPop: true, //是否显示弹窗
popType: 'custom',

View File

@ -357,7 +357,7 @@
these.formData.img = device.devicePic;
these.formData.id = device.id;
these.formData.deviceId = f.deviceId;
these.formData.bleStatu=false;
these.formData.bleStatu = false;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true;
});
@ -515,11 +515,14 @@
return f;
},
bleValueNotify: function(receive, device, path,recArr) {
bleValueNotify: function(receive, device, path, recArr) {
if (receive.deviceId !== this.formData.deviceId) {
return;
}
if (this.Status.pageHide) {
return;
}
let json = recei.ReceiveData(receive, device, path,recArr);
let json = recei.ReceiveData(receive, device, path, recArr);
if (!json) {
return;
}
@ -572,6 +575,7 @@
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '去连接',
buttonTextColor: '#232323de',
okCallback: function() {
// console.log("1111");
uni.navigateTo({
@ -1028,39 +1032,52 @@
this.Status.Pop.showPop = false;
},
showPop: function(option) {
hideLoading(this);
let defaultCfg = {
showHeader: false,
headerTxt: "",
showHeader: false,
showCancel: false,
borderColor: '#BBE600',
buttonBgColor: '#BBE600',
okCallback: null,
cancelCallback: null,
let def = {
showPop: true, //是否显示弹窗
popType: 'custom',
bgColor: '#383934bd',
borderColor: '#BBE600',
textColor: '#ffffffde',
buttonBgColor: '#BBE600',
buttonTextColor: '#232323DE',
iconUrl: '',
message: '',
buttonText: '确定',
clickEvt: ''
};
if (!option) {
clickEvt: '',
visiblePrompt: false,
promptTitle: '',
modelValue: '',
visibleClose: false,
okCallback: null,
showSlot: false,
buttonCancelText: '',
showCancel: false,
}
}
let keys = Object.keys(option);
for (var i = 0; i < keys.length; i++) {
let key = keys[i];
this.Status.Pop[key] = option[key];
}
keys = Object.keys(defaultCfg);
for (var i = 0; i < keys.length; i++) {
let keys = Object.keys(def);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
if (key in option) {
continue;
}
this.Status.Pop[key] = defaultCfg[key];
this.Status.Pop[key] = def[key];
}
if (option) {
keys = Object.keys(option);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
this.Status.Pop[key] = option[key];
}
}
this.Status.Pop.showPop = true;
if (!option.borderColor) {
option.borderColor = '#BBE600';
option.buttonBgColor = '#BBE600';
}
these.Status.Pop.showPop = true;
},
sendUsr() {
let f = this.getDevice();

View File

@ -247,6 +247,7 @@
data() {
return {
Status: {
pageHide: false,
showLightingSet: false,
showVolumeSet: false,
Pop: {
@ -675,6 +676,9 @@
},
bleValueNotify: function(receive, device, path) { //订阅消息
if (receive.deviceId !== this.formData.deviceId) {
return;
}
console.log("收到设备的数据", receive)
let data = recei.ReceiveData(receive, device, pagePath);
@ -717,13 +721,13 @@
showBleUnConnect() {
these.showPop({
this.showPop({
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '去连接',
buttonTextColor: '#FFFFFFde',
buttonTextColor: '#232323de',
okCallback: function() {
uni.navigateTo({
@ -731,7 +735,7 @@
events: {
BindOver: function(data) {
console.log(data)
these.formData.bleStatu=true;
these.formData.bleStatu = true;
}
},
success: function(res) {
@ -797,6 +801,7 @@
}
},
showPop: function(option) {
hideLoading(this);
let def = {
showPop: true, //是否显示弹窗
popType: 'custom',
@ -807,14 +812,16 @@
buttonTextColor: '#232323DE',
iconUrl: '',
message: '',
buttonText: '',
buttonText: '确定',
clickEvt: '',
visiblePrompt: false,
promptTitle: '',
modelValue: '',
visibleClose: false,
okCallback: null,
showSlot: false
showSlot: false,
buttonCancelText: '',
showCancel: false,
}
let keys = Object.keys(def);
@ -824,14 +831,14 @@
if (key in option) {
continue;
}
these.Status.Pop[key] = def[key];
this.Status.Pop[key] = def[key];
}
if (option) {
keys = Object.keys(option);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
these.Status.Pop[key] = option[key];
this.Status.Pop[key] = option[key];
}
}

View File

@ -192,7 +192,7 @@
data() {
return {
Status: {
pageHide: false,
Pop: {
showPop: false, //是否显示弹窗
popType: 'custom',
@ -345,10 +345,10 @@
these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName;
these.formData.img = device.devicePic;
these.formData.bleStatu=false;
these.formData.bleStatu = false;
these.formData.deviceId = f.deviceId;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res=>{
these.formData.bleStatu=true;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true;
});
these.setBleFormData();
these.getDetail();
@ -490,9 +490,12 @@
return className;
},
bleValueNotify: function(receive, device, path,recArr) { //订阅消息
bleValueNotify: function(receive, device, path, recArr) { //订阅消息
if (receive.deviceId !== this.formData.deviceId) {
return;
}
console.log("收到设备的数据", receive)
let data = recei.ReceiveData(receive, device, pagePath,recArr);
let data = recei.ReceiveData(receive, device, pagePath, recArr);
if (data) {
if ("staBlue_picture" in data) {
@ -559,7 +562,7 @@
getDetail() {
var that = this;
usrApi.getDetail(this.device.id).then(res => {
console.log("res=",res);
console.log("res=", res);
if (res && res.code == 200) {
res = res.data;
let personnelInfo = res.personnelInfo;
@ -684,7 +687,7 @@ console.log("res=",res);
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '去连接',
buttonTextColor: '#FFFFFFde',
buttonTextColor: '#232323de',
okCallback: function() {
uni.navigateTo({
@ -692,7 +695,7 @@ console.log("res=",res);
events: {
BindOver: function(data) {
console.log(data)
these.formData.bleStatu=true;
these.formData.bleStatu = true;
}
},
success: function(res) {
@ -1261,17 +1264,47 @@ console.log("res=",res);
}
},
showPop: function(option) {
hideLoading(this);
let def = {
showPop: true, //是否显示弹窗
popType: 'custom',
bgColor: '#383934bd',
borderColor: '#BBE600',
textColor: '#ffffffde',
buttonBgColor: '#BBE600',
buttonTextColor: '#232323DE',
iconUrl: '',
message: '',
buttonText: '确定',
clickEvt: '',
visiblePrompt: false,
promptTitle: '',
modelValue: '',
visibleClose: false,
okCallback: null,
showSlot: false,
buttonCancelText: '',
showCancel: false,
}
if (!option) {
option = {
a: 1
};
}
let keys = Object.keys(option);
for (var i = 0; i < keys.length; i++) {
let keys = Object.keys(def);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
these.Status.Pop[key] = option[key];
if (key in option) {
continue;
}
this.Status.Pop[key] = def[key];
}
if (option) {
keys = Object.keys(option);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
this.Status.Pop[key] = option[key];
}
}
if (!option.borderColor) {
option.borderColor = '#BBE600';
option.buttonBgColor = '#BBE600';

View File

@ -523,7 +523,7 @@
these.formData['imei'] = these.device.deviceImei;
}
these.getDetail();
these.formData.bleStatu=false;
these.formData.bleStatu = false;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true;
});
@ -531,10 +531,10 @@
},
onShow() {
this.Status.pageHide=false;
this.Status.pageHide = false;
},
onHide: function() {
this.Status.pageHide=true;
this.Status.pageHide = true;
},
onBackPress(e) {
ble.removeReceiveCallback(pagePath);
@ -628,11 +628,12 @@
return;
}
this.showPop({
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备,取消"+(4-this.Status.bleLinkCnt)+"次后不再提醒",
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备,取消" + (4 - this.Status.bleLinkCnt) + "次后不再提醒",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '去连接',
buttonTextColor: '#232323de',
showCancel: true,
cancelCallback: () => {
// this.closePop();
@ -644,7 +645,7 @@
events: {
BindOver: function(data) {
console.log(data)
these.formData.bleStatu=true;
these.formData.bleStatu = true;
}
},
success: function(res) {
@ -983,9 +984,11 @@
this.refreshFormData(receiveData, 'auto');
return receiveData;
},
bleValueNotify: function(receive, device, path,recArr) { //订阅消息
let data = recei.ReceiveData(receive, device, pagePath,recArr);
bleValueNotify: function(receive, device, path, recArr) { //订阅消息
if (receive.deviceId !== this.formData.deviceId) {
return;
}
let data = recei.ReceiveData(receive, device, pagePath, recArr);
console.log("收到设备的数据", data)
if (data) {
if ("staBlue_picture" in data) {
@ -1395,12 +1398,12 @@
clearInterval(these.Status.staticWarn.inteval);
these.Status.staticWarn.inteval = null;
these.formData.qzwarn = false;
if(this.Status.Pop.okCallback){
these.CloseWarn(false);
these.formData.SOS = 'close';
if (this.Status.Pop.okCallback) {
these.CloseWarn(false);
these.formData.SOS = 'close';
}
return;
}
these.Status.staticWarn.time = these.Status.staticWarn
@ -1433,9 +1436,10 @@
this.Status.staticWarn.time = 0;
return;
}
if (these.formData.qzwarn && these.Status.staticWarn.inteval && these.Status.staticWarn.time) {
if (these.formData.qzwarn && these.Status.staticWarn.inteval && these.Status.staticWarn
.time) {
console.log("222222");
this.Status.Pop.okCallback=null;
this.Status.Pop.okCallback = null;
these.showQzWarn(sendRb);
} else {
sendRb();
@ -2170,39 +2174,51 @@
},
showPop: function(option) {
hideLoading(this);
let defaultCfg = {
showHeader: false,
headerTxt: "",
showHeader: false,
showCancel: false,
borderColor: '#BBE600',
buttonBgColor: '#BBE600',
okCallback: null,
cancelCallback: null,
let def = {
showPop: true, //是否显示弹窗
popType: 'custom',
bgColor: '#383934bd',
borderColor: '#BBE600',
textColor: '#ffffffde',
buttonBgColor: '#BBE600',
buttonTextColor: '#232323DE',
iconUrl: '',
message: '',
buttonText: '确定',
clickEvt: '',
visiblePrompt: false,
promptTitle: '',
modelValue: '',
visibleClose: false,
okCallback: null,
showSlot: false,
buttonCancelText: '',
showCancel: false,
buttonCancelText: '取消',
clickEvt: ''
};
if (!option) {
}
}
let keys = Object.keys(option);
for (var i = 0; i < keys.length; i++) {
let key = keys[i];
this.Status.Pop[key] = option[key];
}
keys = Object.keys(defaultCfg);
for (var i = 0; i < keys.length; i++) {
let keys = Object.keys(def);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
if (key in option) {
continue;
}
this.Status.Pop[key] = defaultCfg[key];
this.Status.Pop[key] = def[key];
}
if (option) {
keys = Object.keys(option);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
this.Status.Pop[key] = option[key];
}
}
this.Status.Pop.showPop = true;
if (!option.borderColor) {
option.borderColor = '#BBE600';
option.buttonBgColor = '#BBE600';
}
these.Status.Pop.showPop = true;
},
sendUsr: function(ReSendNo) {
@ -2338,9 +2354,9 @@
// 获取当前行文字
const text = textLines[currentPacket - 1] || '';
let arr = gbk.encode(text)
console.log("arr=",arr);
console.log("arr=", arr);
let gbkData = gbk.arr2hex(arr);
console.log("gbkData=",gbkData);
console.log("gbkData=", gbkData);
// 构建数据包
const bufferSize = 5 + gbkData.length / 2; // 头部4字节 + 数据部分

View File

@ -313,7 +313,7 @@
these.formData.img = device.devicePic;
these.formData.id = device.id;
these.formData.deviceId = f.deviceId;
these.formData.bleStatu=false;
these.formData.bleStatu = false;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
console.log("连接成功")
these.formData.bleStatu = true;
@ -469,7 +469,9 @@
return f;
},
bleValueNotify: function(receive, device, path, recArr) {
if (receive.deviceId !== this.formData.deviceId) {
return;
}
if (this.Status.pageHide) {
return;
}
@ -534,6 +536,7 @@
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '去连接',
buttonTextColor: '#232323de',
okCallback: function() {
console.log("1111");
uni.navigateTo({
@ -992,39 +995,52 @@
this.Status.Pop.showPop = false;
},
showPop: function(option) {
hideLoading(this);
let defaultCfg = {
showHeader: false,
headerTxt: "",
showHeader: false,
showCancel: false,
borderColor: '#BBE600',
buttonBgColor: '#BBE600',
okCallback: null,
cancelCallback: null,
let def = {
showPop: true, //是否显示弹窗
popType: 'custom',
bgColor: '#383934bd',
borderColor: '#BBE600',
textColor: '#ffffffde',
buttonBgColor: '#BBE600',
buttonTextColor: '#232323DE',
iconUrl: '',
message: '',
buttonText: '确定',
clickEvt: ''
};
if (!option) {
clickEvt: '',
visiblePrompt: false,
promptTitle: '',
modelValue: '',
visibleClose: false,
okCallback: null,
showSlot: false,
buttonCancelText: '',
showCancel: false,
}
}
let keys = Object.keys(option);
for (var i = 0; i < keys.length; i++) {
let key = keys[i];
this.Status.Pop[key] = option[key];
}
keys = Object.keys(defaultCfg);
for (var i = 0; i < keys.length; i++) {
let keys = Object.keys(def);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
if (key in option) {
continue;
}
this.Status.Pop[key] = defaultCfg[key];
this.Status.Pop[key] = def[key];
}
if (option) {
keys = Object.keys(option);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
this.Status.Pop[key] = option[key];
}
}
this.Status.Pop.showPop = true;
if (!option.borderColor) {
option.borderColor = '#BBE600';
option.buttonBgColor = '#BBE600';
}
these.Status.Pop.showPop = true;
},
sendUsr() {
let f = this.getDevice();

View File

@ -156,14 +156,39 @@
if (these.device.deviceId == receive.deviceId) {
console.log("11111:", receive);
these.device.imei = f.imei;
if (receive.bytes[0] == 0xFC || receive.str.indexOf('mac address:') == 0) {
let flag=false;
if (receive.bytes && receive.bytes.length && receive.bytes[0] == 0xFC) {//6155 7305
if (f && f.macAddress) {
these.device.macAddress = f.macAddress;
console.log("222222");
these.Statu.isSearch = false;
these.initDevice();
flag=true;
}
}
else if(receive.str.indexOf('mac address:') == 0){//650 670
if (f && f.macAddress) {
flag=true;
}
}
else{
try{
let json=JSON.parse(receive.str);
let key = "sta_address";
if (key in json) {//100
if (f && f.macAddress) {
flag=true;
}
}
}catch(err){
console.log("出现异常,",err);
}
}
if(flag){
these.device.macAddress = f.macAddress;
console.log("222222");
these.Statu.isSearch = false;
these.initDevice();
}
}
}, pagePath);
eventChannel = this.getOpenerEventChannel();

View File

@ -27,7 +27,8 @@
<view class="item " v-for="item, index in PairEquip" v-show="PairEquip.length>0">
<view class="leftImg ">
<image src="/static/images/common/bluetooth.png" class="titleIco" mode="heightFix">
<image src="/static/images/common/bluetooth.png" class="titleIco filterNone"
mode="heightFix">
</image>
</view>
<view class="centertxt ">
@ -172,73 +173,80 @@
let search = option.search;
these = this;
eventChannel = this.getOpenerEventChannel();
// this.EquipMents = [{
// "RSSI": -55,
// "advertisData": "",
// "advertisServiceUUIDs": [
// "0000FFE0-0000-1000-8000-00805F9B34FB"
// ],
// "deviceId": "EBDA4E6F-3A28-FF65-A845-AE8CC7B78375",
// "name": "HBY670-BF74EA",
// "linkStatu": false
// },
// {
// "RSSI": -61,
// "advertisData": "",
// "advertisServiceUUIDs": [
// "0000FFE0-0000-1000-8000-00805F9B34FB"
// ],
// "deviceId": "469FB381-B47E-1E40-8073-EF50B5704AAB",
// "name": "EF4651",
// "linkStatu": false,
// "isTarget": true
// },
// {
// "RSSI": -69,
// "advertisData": "",
// "advertisServiceUUIDs": [
// "0000FFE0-0000-1000-8000-00805F9B34FB"
// ],
// "deviceId": "4F0DAC91-4391-CB07-905E-72D7F03EFCD3",
// "name": "4877-BF743D",
// "linkStatu": false
// }
// ];
const systemInfo = uni.getSystemInfoSync();
if (systemInfo.uniPlatform == 'web') {
this.EquipMents = [{
"RSSI": -55,
"advertisData": "",
"advertisServiceUUIDs": [
"0000FFE0-0000-1000-8000-00805F9B34FB"
],
"deviceId": "EBDA4E6F-3A28-FF65-A845-AE8CC7B78375",
"name": "HBY670-BF74EA",
"linkStatu": false
},
{
"RSSI": -61,
"advertisData": "",
"advertisServiceUUIDs": [
"0000FFE0-0000-1000-8000-00805F9B34FB"
],
"deviceId": "469FB381-B47E-1E40-8073-EF50B5704AAB",
"name": "EF4651",
"linkStatu": false,
"isTarget": true
},
{
"RSSI": -69,
"advertisData": "",
"advertisServiceUUIDs": [
"0000FFE0-0000-1000-8000-00805F9B34FB"
],
"deviceId": "4F0DAC91-4391-CB07-905E-72D7F03EFCD3",
"name": "4877-BF743D",
"linkStatu": false
}
];
these.PairEquip = [this.EquipMents[0]];
return;
}
let StartSubsrib = () => {
these.EquipMents = [];
ble = bleTool.getBleTool();
//蓝牙不可用的回调
ble.addStateBreakCallback(res=>{
ble.addStateBreakCallback(res => {
if (these.Status.isPageHidden) {
return;
}
console.log("处理蓝牙不可用");
hideLoading(these);
these.PairEquip=[];
these.EquipMents=[];
these.PairEquip = [];
these.EquipMents = [];
uni.showToast({
icon:'fail',
title:'蓝牙已不可用'
icon: 'fail',
title: '蓝牙已不可用'
});
these.showOpenSetting();
},pagePath);
}, pagePath);
//蓝牙再次可用的回调
ble.addStateRecoveryCallback(res=>{
ble.addStateRecoveryCallback(res => {
if (these.Status.isPageHidden) {
return;
}
uni.showToast({
icon:'success',
title:'蓝牙恢复可用'
icon: 'success',
title: '蓝牙恢复可用'
});
these.Status.BottomMenu.show = false;
these.EquipMents=[];
these.EquipMents = [];
these.refreshBleList();
},pagePath);
}, pagePath);
//蓝牙断开连接的回调
ble.addDisposeCallback(res => {
if (these.Status.isPageHidden) {
@ -469,9 +477,9 @@
}
hideLoading(these);
eventChannel.emit('BindOver',these.device);
eventChannel.emit('BindOver', these.device);
ble.updateCache();
uni.navigateBack();
return true;
@ -941,4 +949,9 @@
color: #232323;
}
.filterNone {
filter: none !important;
-webkit-filter: none !important;
}
</style>