1
0
forked from dyf/APP

蓝牙开始、结束搜索添加状态判定

This commit is contained in:
liub
2025-10-30 11:10:57 +08:00
parent bd56ca997b
commit c39cbcb34d
11 changed files with 104 additions and 100 deletions

View File

@ -132,7 +132,7 @@
"quickapp" : {}, "quickapp" : {},
/* */ /* */
"mp-weixin" : { "mp-weixin" : {
"appid" : "", "appid" : "wxe16dcf57e925a6b5",
"setting" : { "setting" : {
"urlCheck" : false "urlCheck" : false
}, },

View File

@ -23,13 +23,14 @@
</view> </view>
</view> </view>
<view class="eqinfo"> <view class="eqinfo">
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{formData.blename}}</text>
</view>
<view class="item"> <view class="item">
<text class="lbl">设备名称</text> <text class="lbl">设备名称</text>
<text class="value">{{formData.deviceName}}</text> <text class="value">{{device.deviceName}}</text>
</view>
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text>
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">蓝牙状态</text> <text class="lbl">蓝牙状态</text>
@ -323,48 +324,39 @@
sta_LightFreq: '', sta_LightFreq: '',
sta_LightDimmer: '', sta_LightDimmer: '',
sta_system: '' sta_system: ''
}, },
dic: { dic: {
SOS: [{ sta_VoiceType: {
text: '声光报警', "0": '关闭',
val: 'sos', "1": '消防',
img: '/static/images/4877/sg.png', "2": '公安',
activeImg: '/static/images/4877/sgActive.png' "3": '交警',
"4": '市政',
"5": '应急',
"6": '医疗',
"7": '铁道',
"8": 'app语音',
}, },
{
text: '泛光照明', sta_LightType: {
val: 'fan', "0": '关闭',
img: '/static/images/4877/fan.png', "1": '红蓝闪',
activeImg: '/static/images/4877/fanActive.png' "2": '红闪',
} "3": '黄闪',
], "4": '蓝闪',
gropus: [{ "5": '红流水',
text: '红配组', "6": '黄流水',
val: 'red_group', "7": '蓝流水'
img: '/static/images/4877/light.png',
activeImg: '/static/images/4877/lightActive.png'
}, },
{
text: '蓝配组',
val: 'blue_group', sta_system: {
img: '/static/images/4877/light.png', "0": '关机',
activeImg: '/static/images/4877/lightActive.png' "1": '仅充电',
}, "2": '开机未充电',
{ "3": '开机且充电'
text: '绿配组',
val: 'green_group',
img: '/static/images/4877/light.png',
activeImg: '/static/images/4877/lightActive.png'
},
{
text: '黄配组',
val: 'yellow_group',
img: '/static/images/4877/light.png',
activeImg: '/static/images/4877/lightActive.png'
} }
]
}, },
device: { device: {
id: "", id: "",

View File

@ -240,7 +240,7 @@
</view> </view>
</view> </view>
<!-- ======各个弹框类型======= --> <!-- ======各个弹框类型======= -->
<CustomPopup :show="currentPopup.show" v-bind="currentPopup.config" @confirm="handleConfirm" <CustomPopup :show="currentPopup.show" ="currentPopup.config" @confirm="handleConfirm"
@cancel="handleCancel" /> @cancel="handleCancel" />
</view> </view>
</view> </view>

View File

@ -24,12 +24,12 @@
</view> </view>
<view class="eqinfo"> <view class="eqinfo">
<view class="item"> <view class="item">
<text class="lbl">蓝牙名称</text> <text class="lbl">设备名称</text>
<text class="value">{{formData.blename}}</text> <text class="value">{{device.deviceName}}</text>
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">设备名称</text> <text class="lbl">蓝牙名称</text>
<text class="value">{{formData.deviceName}}</text> <text class="value">{{device.bluetoothName}}</text>
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">蓝牙状态</text> <text class="lbl">蓝牙状态</text>
@ -37,7 +37,7 @@
</view> </view>
</view> </view>
<view class="warnnig" v-bind:class="formData.sta_SOSType=='sos'?'':'displayNone'" <view class="warnnig" :class="formData.sta_SOSType=='sos'?'':'displayNone'"
@click.stop="showUnWarn('sos_off')"> @click.stop="showUnWarn('sos_off')">
<view>设备强制报警中</view> <view>设备强制报警中</view>
<view class="netContent"> <view class="netContent">

View File

@ -22,18 +22,19 @@
</view> </view>
</view> </view>
<view class="eqinfo"> <view class="eqinfo">
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{formData.blename}}</text>
</view>
<view class="item"> <view class="item">
<text class="lbl">设备名称</text> <text class="lbl">设备名称</text>
<text class="value">{{formData.deviceName}}</text> <text class="value">{{device.deviceName}}</text>
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">充电状态</text> <text class="lbl">设备状态</text>
<text class="value">{{formData.statu}}</text> <text class="value">{{formData.statu}}</text>
</view> </view>
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text>
</view>
<view class="item"> <view class="item">
<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'">{{formData.bleStatu?'已连接':'未连接'}}</text>

View File

@ -22,15 +22,15 @@
</view> </view>
</view> </view>
<view class="eqinfo"> <view class="eqinfo">
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{formData.blename}}</text>
</view>
<view class="item"> <view class="item">
<text class="lbl">设备名称</text> <text class="lbl">设备名称</text>
<text class="value">{{formData.deviceName}}</text> <text class="value">{{device.deviceName}}</text>
</view> </view>
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text>
</view>
<view class="item"> <view class="item">
<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'">{{formData.bleStatu?'已连接':'未连接'}}</text>

View File

@ -24,11 +24,11 @@
<view class="eqinfo"> <view class="eqinfo">
<view class="item"> <view class="item">
<text class="lbl">蓝牙名称</text> <text class="lbl">蓝牙名称</text>
<text class="value">{{formData.blename}}</text> <text class="value">{{device.bluetoothName}}</text>
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">设备名称</text> <text class="lbl">设备名称</text>
<text class="value">{{formData.deviceName}}</text> <text class="value">{{device.deviceName}}</text>
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">蓝牙状态</text> <text class="lbl">蓝牙状态</text>
@ -40,14 +40,14 @@
</view> </view>
</view> </view>
<view class="warnnig" v-bind:class="formData.iswarn?'':'displayNone'"> <view class="warnnig" :class="formData.iswarn?'':'displayNone'">
<view>警告!环境存在漏电电源</view> <view>警告!环境存在漏电电源</view>
<view class="netContent"> <view class="netContent">
<view v-bind:class="getWarnStyle(1)" class="net netone"></view> <view :class="getWarnStyle(1)" class="net netone"></view>
<view v-bind:class="getWarnStyle(2)" class="net nettwo"></view> <view :class="getWarnStyle(2)" class="net nettwo"></view>
<view v-bind:class="getWarnStyle(3)" class="net netsiri"></view> <view :class="getWarnStyle(3)" class="net netsiri"></view>
<view v-bind:class="getWarnStyle(4)" class="net netfour"></view> <view :class="getWarnStyle(4)" class="net netfour"></view>
<view v-bind:class="getWarnStyle(5)" class="net netfive"></view> <view :class="getWarnStyle(5)" class="net netfive"></view>
</view> </view>
</view> </view>

View File

@ -33,6 +33,10 @@
<text class="lbl">设备名称</text> <text class="lbl">设备名称</text>
<text class="value valueFont">{{device.deviceName}}</text> <text class="value valueFont">{{device.deviceName}}</text>
</view> </view>
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value valueFont">{{device.bluetoothName}}</text>
</view>
<view class="item"> <view class="item">
<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'">{{formData.bleStatu?'已连接':'未连接'}}</text>
@ -69,17 +73,17 @@
</view> </view>
</view> </view>
<view class="warnnig" v-bind:class="formData.staticWarn?'':'displayNone'"> <view class="warnnig" :class="formData.staticWarn?'':'displayNone'">
<view>警告设备静止报警中</view> <view>警告设备静止报警中</view>
<view class="netContent"> <view class="netContent">
<view v-bind:class="getWarnStyle(1)" class="net netone"></view> <view :class="getWarnStyle(1)" class="net netone"></view>
<view v-bind:class="getWarnStyle(2)" class="net nettwo"></view> <view :class="getWarnStyle(2)" class="net nettwo"></view>
<view v-bind:class="getWarnStyle(3)" class="net netsiri"></view> <view :class="getWarnStyle(3)" class="net netsiri"></view>
<view v-bind:class="getWarnStyle(4)" class="net netfour"></view> <view :class="getWarnStyle(4)" class="net netfour"></view>
<view v-bind:class="getWarnStyle(5)" class="net netfive"></view> <view :class="getWarnStyle(5)" class="net netfive"></view>
</view> </view>
</view> </view>
<view class="warnnig" v-bind:class="(formData.qzwarn && Status.staticWarn.time)?'':'displayNone'" <view class="warnnig" :class="(formData.qzwarn && Status.staticWarn.time)?'':'displayNone'"
@click="CloseWarn(true)"> @click="CloseWarn(true)">
<view>设备强制报警中</view> <view>设备强制报警中</view>
<view class="netContent"> <view class="netContent">

View File

@ -22,18 +22,20 @@
</view> </view>
</view> </view>
<view class="eqinfo"> <view class="eqinfo">
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{formData.blename}}</text>
</view>
<view class="item"> <view class="item">
<text class="lbl">设备名称</text> <text class="lbl">设备名称</text>
<text class="value">{{formData.deviceName}}</text> <text class="value">{{device.deviceName}}</text>
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">充电状态</text> <text class="lbl">设备状态</text>
<text class="value">{{formData.statu}}</text> <text class="value">{{formData.statu}}</text>
</view> </view>
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text>
</view>
<view class="item"> <view class="item">
<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'">{{formData.bleStatu?'已连接':'未连接'}}</text>

View File

@ -20,7 +20,7 @@
<view class="deviceId"> <view class="deviceId">
设备IMEI:{{device.imei}} 设备IMEI:{{device.imei}}
</view> </view>
<view class="bound" v-bind:class="boundStatu"> <view class="bound" :class="boundStatu">
{{Statu.boundRemark}} {{Statu.boundRemark}}
</view> </view>
</view> </view>

View File

@ -511,9 +511,11 @@ class BleHelper {
uni.onBluetoothAdapterStateChange((state) => { uni.onBluetoothAdapterStateChange((state) => {
// console.log('蓝牙状态发生变化:' + JSON.stringify(state)); // console.log('蓝牙状态发生变化:' + JSON.stringify(state));
this.data.discovering = state.discovering;
if (this.data.available !== state.available) { if (this.data.available !== state.available) {
this.data.available = state.available; this.data.available = state.available;
this.data.discovering = state.discovering;
if (this.data.available && this.data if (this.data.available && this.data
.isOpenBlue) { //蓝牙状态再次可用,重连所有设备 .isOpenBlue) { //蓝牙状态再次可用,重连所有设备
@ -870,10 +872,7 @@ class BleHelper {
return Promise.resolve(); return Promise.resolve();
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.data.available = false;
this.data.discovering = false;
this.data.isOpenBlue = false;
this.data.searchList = [];
this.StopSearch(); this.StopSearch();
@ -882,15 +881,19 @@ class BleHelper {
uni.closeBluetoothAdapter({ uni.closeBluetoothAdapter({
success: () => { success: () => {
// console.log("蓝牙模块已关闭"); // console.log("蓝牙模块已关闭");
this.data.available = false;
this.data.discovering = false;
this.data.isOpenBlue = false;
this.data.searchList = [];
resolve();
}, },
fail: (ex) => { fail: (ex) => {
console.error('无法关闭蓝牙模块:', ex); console.error('无法关闭蓝牙模块:', ex);
ex = this.getError(ex); ex = this.getError(ex);
reject(ex);
}, },
complete: () => { complete: () => {
resolve();
} }
}); });
@ -963,7 +966,8 @@ class BleHelper {
//停止搜索 //停止搜索
StopSearch() { StopSearch() {
if (this.data.platform == 'web') { if (this.data.platform == 'web' || !this.data.discovering) {
console.error("web平台或当前没有搜索,直接返回");
return Promise.resolve(); return Promise.resolve();
} }
let p1 = new Promise((resolve, reject) => { let p1 = new Promise((resolve, reject) => {
@ -1481,7 +1485,9 @@ class BleHelper {
// 处理 MTU 设置 // 处理 MTU 设置
if (plus.os.name === 'Android') { if (plus.os.name === 'Android') {
this.setMtu(deviceId); this.setMtu(deviceId).catch(ex=>{
console.error("mtu设置失败=",ex);
});
} }
resolve(true); resolve(true);
@ -1579,12 +1585,11 @@ class BleHelper {
_succ(mtuRes); _succ(mtuRes);
}, },
fail: (ex) => { fail: (ex) => {
console.error(
"mtu设置失败", ex);
ex = this.getError(ex); ex = this.getError(ex);
_err( _err(
ex ex
); // MTU设置失败不影响连接成功 );
}, },
complete() { complete() {
console.log("设置mtu完毕"); console.log("设置mtu完毕");