new-20250827 一些小优化 #34

Merged
dyf merged 14 commits from liubiao/APP:new-20250827 into main 2026-02-26 09:07:26 +08:00
28 changed files with 1383 additions and 312 deletions
Showing only changes of commit 1aa11a7a38 - Show all commits

View File

@ -57,9 +57,9 @@
<text class="lbl">蓝牙名称</text> <text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text> <text class="value">{{device.bluetoothName}}</text>
</view> </view>
<view class="item"> <view class="item" @click.top="bleStatuToggle">
<text class="lbl">蓝牙状态</text> <text class="lbl">蓝牙状态</text>
<text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text> <text class="value" :class="formData.bleStatu?'green':'red'">{{getbleStatu}}</text>
</view> </view>
<!-- <view class="item"> <!-- <view class="item">
<text class="lbl">设备状态</text> <text class="lbl">设备状态</text>
@ -572,8 +572,11 @@
these.formData.bleStatu = false; these.formData.bleStatu = false;
these.formData.deviceId = f.deviceId; these.formData.deviceId = f.deviceId;
these.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
}).catch(ex=>{
these.formData.bleStatu = 'err';
}); });
these.setBleFormData(); these.setBleFormData();
@ -589,7 +592,21 @@
this.Status.pageHide = false; this.Status.pageHide = false;
}, },
computed: { 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: { methods: {
handleRightClick(item, s) { handleRightClick(item, s) {
@ -1212,12 +1229,14 @@
showLoading(this, { showLoading(this, {
text: "蓝牙恢复可用,正在连接设备" text: "蓝牙恢复可用,正在连接设备"
}); });
these.formData.bleStatu='connecting';
ble.LinkBlue(these.formData.deviceId).then(() => { ble.LinkBlue(these.formData.deviceId).then(() => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
updateLoading(these, { updateLoading(these, {
text: '连接成功' text: '连接成功'
}); });
}).catch(ex => { }).catch(ex => {
these.formData.bleStatu='err';
updateLoading(these, { updateLoading(these, {
text: ex.msg text: ex.msg
}) })
@ -1305,6 +1324,33 @@
return f; return f;
}, },
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;
}
},
setBleFormData() { setBleFormData() {
ble.data.LinkedList.find((v) => { ble.data.LinkedList.find((v) => {

View File

@ -58,9 +58,9 @@
<text class="lbl">蓝牙名称</text> <text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text> <text class="value">{{device.bluetoothName}}</text>
</view> </view>
<view class="item"> <view class="item" @click.top="bleStatuToggle">
<text class="lbl">蓝牙状态</text> <text class="lbl">蓝牙状态</text>
<text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text> <text class="value" :class="formData.bleStatu?'green':'red'">{{getbleStatu}}</text>
</view> </view>
<!-- <view class="item"> <!-- <view class="item">
<text class="lbl">设备状态</text> <text class="lbl">设备状态</text>
@ -489,8 +489,11 @@
these.formData.bleStatu = false; these.formData.bleStatu = false;
these.formData.deviceId = f.deviceId; these.formData.deviceId = f.deviceId;
these.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
}).catch(ex => {
these.formData.bleStatu = 'err';
}); });
these.formData.sta_IntrusTime = 0; these.formData.sta_IntrusTime = 0;
these.formData.sta_sosadd = ""; these.formData.sta_sosadd = "";
@ -530,6 +533,21 @@
} }
}); });
return active; return active;
},
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: { methods: {
@ -994,12 +1012,14 @@ console.error("获取到未读消息",fs);
showLoading(this, { showLoading(this, {
text: "蓝牙恢复可用,正在连接设备" text: "蓝牙恢复可用,正在连接设备"
}); });
this.formData.bleStatu = 'connecting';
ble.LinkBlue(these.formData.deviceId).then(() => { ble.LinkBlue(these.formData.deviceId).then(() => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
updateLoading(these, { updateLoading(these, {
text: '连接成功' text: '连接成功'
}); });
}).catch(ex => { }).catch(ex => {
these.formData.bleStatu = 'err';
updateLoading(these, { updateLoading(these, {
text: ex.msg text: ex.msg
}) })
@ -1216,6 +1236,32 @@ console.error("获取到未读消息",fs);
return f; return f;
}, },
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;
}
},
setBleFormData() { setBleFormData() {
ble.data.LinkedList.find((v) => { ble.data.LinkedList.find((v) => {

View File

@ -54,9 +54,9 @@
<text class="lbl">蓝牙名称</text> <text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text> <text class="value">{{device.bluetoothName}}</text>
</view> </view>
<view class="item"> <view class="item" @click.top="bleStatuToggle">
<text class="lbl">蓝牙状态</text> <text class="lbl">蓝牙状态</text>
<text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text> <text class="value" :class="formData.bleStatu?'green':'red'">{{getbleStatu}}</text>
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">信道:{{formData.sta_Channel}}</text> <text class="lbl">信道:{{formData.sta_Channel}}</text>
@ -295,7 +295,9 @@
hideLoading, hideLoading,
updateLoading updateLoading
} from '@/utils/loading.js' } from '@/utils/loading.js'
import request, { baseURL } from '@/utils/request.js'; import request, {
baseURL
} from '@/utils/request.js';
import Common from '@/utils/Common.js'; import Common from '@/utils/Common.js';
import { import {
colors as groupColors colors as groupColors
@ -556,6 +558,7 @@ import request, { baseURL } from '@/utils/request.js';
these.formData.deviceId = f.deviceId; these.formData.deviceId = f.deviceId;
these.formData.warnTime = null; these.formData.warnTime = null;
these.formData.sta_SOSType = 'sos_off'; these.formData.sta_SOSType = 'sos_off';
these.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
}); });
@ -573,9 +576,50 @@ import request, { baseURL } from '@/utils/request.js';
this.Status.pageHide = false; this.Status.pageHide = false;
}, },
computed: { 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: { 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) { handleRightClick(item, s) {
if (item && item.callback) { if (item && item.callback) {
item.callback(item, s); item.callback(item, s);
@ -1076,6 +1120,7 @@ if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') {
showLoading(this, { showLoading(this, {
text: "蓝牙恢复可用,正在连接设备" text: "蓝牙恢复可用,正在连接设备"
}); });
these.formData.bleStatu = 'connecting';
ble.LinkBlue(these.formData.deviceId).then(() => { ble.LinkBlue(these.formData.deviceId).then(() => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
updateLoading(these, { updateLoading(these, {
@ -1838,6 +1883,7 @@ if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') {
border-bottom: 1px solid #ffffff30; border-bottom: 1px solid #ffffff30;
margin: 30rpx; margin: 30rpx;
} }
.modeSetting .arrow .outCircle { .modeSetting .arrow .outCircle {
width: 120rpx; width: 120rpx;
height: 120rpx; height: 120rpx;

View File

@ -9,8 +9,8 @@
</view> </view>
<view slot="right"> <view slot="right">
<view class="navbarRight center"> <view class="navbarRight center">
<view class="imgContent" :class="{'visibilityHidden':Status.apiType!=item.apiType}" @click.stop="handleRightClick(item,index)" <view class="imgContent" :class="{'visibilityHidden':Status.apiType!=item.apiType}"
v-for="item,index in Status.navbar.icons"> @click.stop="handleRightClick(item,index)" v-for="item,index in Status.navbar.icons">
<image class="img" :src="item.src" mode="aspectFit"></image> <image class="img" :src="item.src" mode="aspectFit"></image>
<view class="baber" v-if="item.math">{{item.math>9?'9+':item.math}}</view> <view class="baber" v-if="item.math">{{item.math>9?'9+':item.math}}</view>
</view> </view>
@ -61,9 +61,9 @@
<text class="lbl">蓝牙名称</text> <text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text> <text class="value">{{device.bluetoothName}}</text>
</view> </view>
<view class="item"> <view class="item" @click.top="bleStatuToggle">
<text class="lbl">蓝牙状态</text> <text class="lbl">蓝牙状态</text>
<text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text> <text class="value" :class="formData.bleStatu?'green':'red'">{{getbleStatu}}</text>
</view> </view>
</view> </view>
<view class="lamp"> <view class="lamp">
@ -410,7 +410,7 @@
these.formData.id = device.id; these.formData.id = device.id;
these.formData.deviceId = f.deviceId; 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 => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
}); });
@ -433,12 +433,50 @@
}, },
computed: { computed: {
cModeItems: function() { 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: { 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) { handleRightClick(item, s) {
if (item && item.callback) { if (item && item.callback) {
item.callback(item, s); item.callback(item, s);
@ -580,6 +618,7 @@
showLoading(this, { showLoading(this, {
text: "蓝牙恢复可用,正在连接设备" text: "蓝牙恢复可用,正在连接设备"
}); });
these.formData.bleStatu = 'connecting';
ble.LinkBlue(these.formData.deviceId).then(() => { ble.LinkBlue(these.formData.deviceId).then(() => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
updateLoading(these, { updateLoading(these, {

View File

@ -62,9 +62,9 @@
<text class="lbl">蓝牙名称</text> <text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text> <text class="value">{{device.bluetoothName}}</text>
</view> </view>
<view class="item"> <view class="item" @click.top="bleStatuToggle">
<text class="lbl">蓝牙状态</text> <text class="lbl">蓝牙状态</text>
<text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text> <text class="value" :class="formData.bleStatu?'green':'red'">{{getbleStatu}}</text>
</view> </view>
</view> </view>
<view class="lamp"> <view class="lamp">
@ -380,7 +380,7 @@
these.formData.id = device.id; these.formData.id = device.id;
these.formData.deviceId = f.deviceId; 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 => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
}); });
@ -403,25 +403,50 @@
}, },
computed: { computed: {
RSSIRemark: function() { getbleStatu() {
let remark = '极弱'; if (this.formData.bleStatu === true) {
if (this.formData.RSSI <= 0 && this.formData.RSSI >= -30) { return '已连接';
remark = '强';
} }
if (this.formData.bleStatu === 'connecting') {
if (this.formData.RSSI < -30 && this.formData.RSSI >= -60) { return '连接中';
remark = '一般';
} }
if (this.formData.RSSI < -60 && this.formData.RSSI >= -85) { if (this.formData.bleStatu === 'dicconnect') {
remark = '弱'; return '正在断开';
} }
if (this.formData.RSSI < -85 && this.formData.RSSI >= -100) { if (this.formData.bleStatu === 'err') {
remark = '微弱'; return '连接异常';
}
return '未连接';
} }
},
}, },
methods: { 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) { handleRightClick(item, s) {
if (item && item.callback) { if (item && item.callback) {
item.callback(item, s); item.callback(item, s);
@ -574,6 +599,7 @@
showLoading(this, { showLoading(this, {
text: "蓝牙恢复可用,正在连接设备" text: "蓝牙恢复可用,正在连接设备"
}); });
these.formData.bleStatu = 'connecting';
ble.LinkBlue(these.formData.deviceId).then(() => { ble.LinkBlue(these.formData.deviceId).then(() => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
updateLoading(these, { updateLoading(these, {

View File

@ -55,9 +55,9 @@
<text class="lbl">设备名称</text> <text class="lbl">设备名称</text>
<text class="value">{{device.deviceName}}</text> <text class="value">{{device.deviceName}}</text>
</view> </view>
<view class="item"> <view class="item" @click.top="bleStatuToggle">
<text class="lbl">蓝牙状态</text> <text class="lbl">蓝牙状态</text>
<text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text> <text class="value" :class="formData.bleStatu?'green':'red'">{{getbleStatu}}</text>
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">预警级别</text> <text class="lbl">预警级别</text>
@ -401,6 +401,7 @@ import request, { baseURL } from '@/utils/request.js';
these.formData.bleStatu = false; these.formData.bleStatu = false;
these.formData.deviceId = f.deviceId; these.formData.deviceId = f.deviceId;
these.formData.bleStatu='connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
}); });
@ -419,24 +420,49 @@ import request, { baseURL } from '@/utils/request.js';
this.Status.pageHide = false; this.Status.pageHide = false;
}, },
computed: { computed: {
RSSIRemark: function() { getbleStatu(){
let remark = '极弱'; if(this.formData.bleStatu===true){
if (this.formData.RSSI <= 0 && this.formData.RSSI >= -30) { return '已连接';
remark = '强';
} }
if(this.formData.bleStatu==='connecting'){
if (this.formData.RSSI < -30 && this.formData.RSSI >= -60) { return '连接中';
remark = '一般';
} }
if (this.formData.RSSI < -60 && this.formData.RSSI >= -85) { if(this.formData.bleStatu==='dicconnect'){
remark = '弱'; return '正在断开';
} }
if (this.formData.RSSI < -85 && this.formData.RSSI >= -100) { if(this.formData.bleStatu==='err'){
remark = '微弱'; return '连接异常';
} }
return '未连接';
} }
}, },
methods: { 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;
}
},
handleRightClick(item, s) { handleRightClick(item, s) {
if (item && item.callback) { if (item && item.callback) {
item.callback(item, s); item.callback(item, s);
@ -521,6 +547,7 @@ import request, { baseURL } from '@/utils/request.js';
showLoading(this, { showLoading(this, {
text: "蓝牙恢复可用,正在连接设备" text: "蓝牙恢复可用,正在连接设备"
}); });
this.formData.bleStatu='connecting';
ble.LinkBlue(these.formData.deviceId).then(() => { ble.LinkBlue(these.formData.deviceId).then(() => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
updateLoading(these, { updateLoading(these, {

View File

@ -1,8 +1,5 @@
<template> <template>
<view class="content contentBg"> <view class="content contentBg">
<!-- <custom-navbar :title="Status.navbar.title" :showBack="Status.navbar.showBack" color="#FFFFFF"
:rightIcons="Status.navbar.icons" @icon-click="handleRightClick" backgroundColor="#121212"></custom-navbar>
-->
<uni-nav-bar :border="false" @clickLeft="prevPage" fixed="true" statusBar="true" <uni-nav-bar :border="false" @clickLeft="prevPage" fixed="true" statusBar="true"
background-color="#121212" color="#FFFFFF" :title="Status.navbar.title"> background-color="#121212" color="#FFFFFF" :title="Status.navbar.title">
<template v-slot:left><view> <template v-slot:left><view>
@ -58,9 +55,9 @@
<text class="lbl">蓝牙名称</text> <text class="lbl">蓝牙名称</text>
<text class="value valueFont">{{device.bluetoothName}}</text> <text class="value valueFont">{{device.bluetoothName}}</text>
</view> </view>
<view class="item"> <view class="item" @click.top="bleStatuToggle">
<text class="lbl">蓝牙状态</text> <text class="lbl">蓝牙状态</text>
<text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text> <text class="value" :class="formData.bleStatu?'green':'red'">{{getbleStatu}}</text>
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">设备状态</text> <text class="lbl">设备状态</text>
@ -550,7 +547,8 @@
these.formData['imei'] = these.device.deviceImei; these.formData['imei'] = these.device.deviceImei;
} }
these.getDetail(); these.getDetail();
these.formData.bleStatu = false;
these.formData.bleStatu='connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
}); });
@ -567,9 +565,49 @@
ble.removeReceiveCallback(pagePath); ble.removeReceiveCallback(pagePath);
}, },
computed: { 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: { 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() { prevPage() {
uni.navigateBack({ uni.navigateBack({
@ -629,6 +667,7 @@
showLoading(this, { showLoading(this, {
text: "蓝牙恢复可用,正在连接设备" text: "蓝牙恢复可用,正在连接设备"
}); });
this.formData.bleStatu='connecting';
ble.LinkBlue(these.formData.deviceId).then(() => { ble.LinkBlue(these.formData.deviceId).then(() => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
updateLoading(these, { updateLoading(these, {

View File

@ -60,9 +60,9 @@
</view> </view>
<view class="item"> <view class="item" @click.top="bleStatuToggle">
<text class="lbl">蓝牙状态</text> <text class="lbl">蓝牙状态</text>
<text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text> <text class="value" :class="formData.bleStatu?'green':'red'">{{getbleStatu}}</text>
</view> </view>
</view> </view>
<view class="lamp"> <view class="lamp">
@ -358,7 +358,7 @@ these.Status.apiType = data.apiType;
these.formData.id = device.id; these.formData.id = device.id;
these.formData.deviceId = f.deviceId; 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 => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
console.log("连接成功") console.log("连接成功")
these.formData.bleStatu = true; these.formData.bleStatu = true;
@ -378,21 +378,20 @@ these.Status.apiType = data.apiType;
this.Status.pageHide = false; this.Status.pageHide = false;
}, },
computed: { computed: {
RSSIRemark: function() { getbleStatu(){
let remark = '极弱'; if(this.formData.bleStatu===true){
if (this.formData.RSSI <= 0 && this.formData.RSSI >= -30) { return '已连接';
remark = '强';
} }
if(this.formData.bleStatu==='connecting'){
if (this.formData.RSSI < -30 && this.formData.RSSI >= -60) { return '连接中';
remark = '一般';
} }
if (this.formData.RSSI < -60 && this.formData.RSSI >= -85) { if(this.formData.bleStatu==='dicconnect'){
remark = '弱'; return '正在断开';
} }
if (this.formData.RSSI < -85 && this.formData.RSSI >= -100) { if(this.formData.bleStatu==='err'){
remark = '微弱'; return '连接异常';
} }
return '未连接';
}, },
getMode() { getMode() {
let txt = "关闭"; let txt = "关闭";
@ -425,6 +424,32 @@ these.Status.apiType = data.apiType;
} }
}, },
methods: { 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) { handleRightClick(item, s) {
if (item && item.callback) { if (item && item.callback) {
item.callback(item, s); item.callback(item, s);
@ -513,6 +538,7 @@ these.Status.apiType = data.apiType;
showLoading(this, { showLoading(this, {
text: "蓝牙恢复可用,正在连接设备" text: "蓝牙恢复可用,正在连接设备"
}); });
these.formData.bleStatu = 'connecting';
ble.LinkBlue(these.formData.deviceId).then(() => { ble.LinkBlue(these.formData.deviceId).then(() => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
updateLoading(these, { updateLoading(these, {

View File

@ -37,6 +37,7 @@ class BleReceive {
}); });
uni.setStorageSync(this.StorageKey, linkedList); uni.setStorageSync(this.StorageKey, linkedList);
return true;
} }
}); });
} }