diff --git a/pages/100/HBY100.vue b/pages/100/HBY100.vue
index 824c995..5e2d73b 100644
--- a/pages/100/HBY100.vue
+++ b/pages/100/HBY100.vue
@@ -57,9 +57,9 @@
蓝牙名称
{{device.bluetoothName}}
-
+
蓝牙状态
- {{formData.bleStatu?'已连接':'未连接'}}
+ {{getbleStatu}}
@@ -58,9 +55,9 @@
蓝牙名称
{{device.bluetoothName}}
-
+
蓝牙状态
- {{formData.bleStatu?'已连接':'未连接'}}
+ {{getbleStatu}}
设备状态
@@ -550,7 +547,8 @@
these.formData['imei'] = these.device.deviceImei;
}
these.getDetail();
- these.formData.bleStatu = false;
+
+ these.formData.bleStatu='connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true;
});
@@ -567,9 +565,49 @@
ble.removeReceiveCallback(pagePath);
},
computed: {
-
+ getbleStatu(){
+ if(this.formData.bleStatu===true){
+ return '已连接';
+ }
+ if(this.formData.bleStatu==='connecting'){
+ return '连接中';
+ }
+ if(this.formData.bleStatu==='dicconnect'){
+ return '正在断开';
+ }
+ if(this.formData.bleStatu==='err'){
+ return '连接异常';
+ }
+ return '未连接';
+ }
},
methods: {
+ bleStatuToggle(){
+ let f=this.getDevice();
+ if(!f){
+ this.showBleUnConnect();
+ return;
+ }
+ if(this.formData.bleStatu===true){
+ this.formData.bleStatu='dicconnect';
+ ble.disconnectDevice(f.deviceId).finally(r=>{
+ this.formData.bleStatu=false;
+ });
+ return;
+ }
+
+ if(this.formData.bleStatu===false || this.formData.bleStatu==='err'){
+ this.formData.bleStatu='connecting';
+ ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
+ these.formData.bleStatu = true;
+ }).catch(ex=>{
+ these.formData.bleStatu = 'err';
+ });
+ return;
+ }
+
+
+ },
prevPage() {
uni.navigateBack({
@@ -629,6 +667,7 @@
showLoading(this, {
text: "蓝牙恢复可用,正在连接设备"
});
+ this.formData.bleStatu='connecting';
ble.LinkBlue(these.formData.deviceId).then(() => {
these.formData.bleStatu = true;
updateLoading(these, {
diff --git a/pages/7305/BJQ7305.vue b/pages/7305/BJQ7305.vue
index 780e97a..65c8033 100644
--- a/pages/7305/BJQ7305.vue
+++ b/pages/7305/BJQ7305.vue
@@ -60,9 +60,9 @@
-
+
蓝牙状态
- {{formData.bleStatu?'已连接':'未连接'}}
+ {{getbleStatu}}
@@ -358,7 +358,7 @@ these.Status.apiType = data.apiType;
these.formData.id = device.id;
these.formData.deviceId = f.deviceId;
- these.formData.bleStatu = false;
+ these.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
console.log("连接成功")
these.formData.bleStatu = true;
@@ -378,22 +378,21 @@ these.Status.apiType = data.apiType;
this.Status.pageHide = false;
},
computed: {
- RSSIRemark: function() {
- let remark = '极弱';
- if (this.formData.RSSI <= 0 && this.formData.RSSI >= -30) {
- remark = '强';
- }
-
- if (this.formData.RSSI < -30 && this.formData.RSSI >= -60) {
- remark = '一般';
- }
- if (this.formData.RSSI < -60 && this.formData.RSSI >= -85) {
- remark = '弱';
- }
- if (this.formData.RSSI < -85 && this.formData.RSSI >= -100) {
- remark = '微弱';
- }
- },
+ getbleStatu(){
+ if(this.formData.bleStatu===true){
+ return '已连接';
+ }
+ if(this.formData.bleStatu==='connecting'){
+ return '连接中';
+ }
+ if(this.formData.bleStatu==='dicconnect'){
+ return '正在断开';
+ }
+ if(this.formData.bleStatu==='err'){
+ return '连接异常';
+ }
+ return '未连接';
+ },
getMode() {
let txt = "关闭";
if (this.Status.BottomMenu.type == 'fu') {
@@ -425,6 +424,32 @@ these.Status.apiType = data.apiType;
}
},
methods: {
+ bleStatuToggle(){
+ let f=this.getDevice();
+ if(!f){
+ this.showBleUnConnect();
+ return;
+ }
+ if(this.formData.bleStatu===true){
+ this.formData.bleStatu='dicconnect';
+ ble.disconnectDevice(f.deviceId).finally(r=>{
+ this.formData.bleStatu=false;
+ });
+ return;
+ }
+
+ if(this.formData.bleStatu===false || this.formData.bleStatu==='err'){
+ these.formData.bleStatu = 'connecting';
+ ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
+ these.formData.bleStatu = true;
+ }).catch(ex=>{
+ these.formData.bleStatu = 'err';
+ });
+ return;
+ }
+
+
+ },
handleRightClick(item, s) {
if (item && item.callback) {
item.callback(item, s);
@@ -513,6 +538,7 @@ these.Status.apiType = data.apiType;
showLoading(this, {
text: "蓝牙恢复可用,正在连接设备"
});
+ these.formData.bleStatu = 'connecting';
ble.LinkBlue(these.formData.deviceId).then(() => {
these.formData.bleStatu = true;
updateLoading(these, {
diff --git a/utils/BleReceive.js b/utils/BleReceive.js
index 5a75818..e4a7caf 100644
--- a/utils/BleReceive.js
+++ b/utils/BleReceive.js
@@ -37,6 +37,7 @@ class BleReceive {
});
uni.setStorageSync(this.StorageKey, linkedList);
+ return true;
}
});
}