优化蓝牙搜索页面的动画闪烁感,优化从设备页面去匹配蓝牙时给出目标设备的提示
This commit is contained in:
@ -157,7 +157,7 @@
|
||||
}
|
||||
})
|
||||
|
||||
let inteval = setInterval(this.initDevice, 5000);
|
||||
let inteval = setInterval(this.initDevice, 10000);
|
||||
},
|
||||
methods: {
|
||||
|
||||
@ -182,7 +182,7 @@
|
||||
}
|
||||
}).then(res => {
|
||||
|
||||
// console.log("获取设备信息", res);
|
||||
console.log("获取设备信息", res);
|
||||
if (res && res.code == 200) {
|
||||
let data = res.data;
|
||||
this.serverDevice=data;
|
||||
|
||||
@ -51,6 +51,7 @@
|
||||
<view class="list searchList">
|
||||
<view class="item" v-on:click="Link(item,index)" v-for="item, index in EquipMents"
|
||||
v-show="!item['linkStatu']">
|
||||
<view class="before" v-if="item.isTarget"></view>
|
||||
<view class="leftImg ">
|
||||
<image src="/static/images/BLEAdd/bluetooth.png" class="titleIco" mode="heightFix">
|
||||
</image>
|
||||
@ -60,14 +61,15 @@
|
||||
<text>{{item.name?item.name:'Unnamed'}}</text>
|
||||
|
||||
</view>
|
||||
<view class="id" >
|
||||
|
||||
<view class="id">
|
||||
<text>信号强度:{{110+item.RSSI>100?100:110+item.RSSI}}%</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="rightIco center">
|
||||
|
||||
|
||||
|
||||
|
||||
<image :src="isItemLink(item,index)" class="img" mode="aspectFit">
|
||||
</image>
|
||||
@ -162,122 +164,149 @@
|
||||
ble.removeDeviceFound(pagePath);
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
},
|
||||
onLoad() {
|
||||
onLoad(option) {
|
||||
let search = option.search;
|
||||
these = this;
|
||||
ble = bleTool.getBleTool();
|
||||
//已连接过但删除了设备
|
||||
// let delArr = ble.data.deletedEqs.map(v => {
|
||||
// return {
|
||||
// "deviceId": v.deviceId,
|
||||
// "name": v.name,
|
||||
// "RSSI": -99,
|
||||
// "localName": v.name,
|
||||
// }
|
||||
// });
|
||||
// //已连接过但没绑定过的设备
|
||||
// let noDev = ble.data.LinkedList.filter(v => {
|
||||
// return !(v.device && v.device.id);
|
||||
// }).map(v => {
|
||||
// return {
|
||||
// "deviceId": v.deviceId,
|
||||
// "name": v.name,
|
||||
// "RSSI": -99,
|
||||
// "localName": v.name,
|
||||
// }
|
||||
// });
|
||||
// delArr = delArr.concat(noDev);
|
||||
|
||||
// console.log("可能搜不到的设备=", delArr);
|
||||
this.EquipMents = []; //delArr;
|
||||
|
||||
|
||||
|
||||
ble.addDeviceFound((arr) => {
|
||||
|
||||
arr = arr.devices;
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
|
||||
arr[i].linkStatu = false;
|
||||
if (!arr[i].name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let f = these.EquipMents.find((v, index) => {
|
||||
if (v.deviceId == arr[i].deviceId) {
|
||||
// v.RSSI=arr[i].RSSI;//同一设备上报更新信号强度
|
||||
these.$set(these.EquipMents[index], 'RSSI', arr[i].RSSI);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (!f) {
|
||||
console.log("发现新设备,", arr[i]);
|
||||
arr[i].name=arr[i].name.replace('JQZM-','');
|
||||
these.EquipMents.push(arr[i]);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
// console.log("equip=", these.EquipMents)
|
||||
}, pagePath);
|
||||
// console.log("addEquip")
|
||||
ble.addReceiveCallback((receivData, f, path, arr) => {
|
||||
if (f.macAddress && these.device) {
|
||||
clearInterval(this.Status.intval);
|
||||
this.Status.intval = null;
|
||||
this.Status.time = null;
|
||||
|
||||
showLoading(these, {
|
||||
text: '正在验证设备'
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
these.DeviceVerdict(f.deviceId);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
|
||||
}, pagePath);
|
||||
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
|
||||
// }
|
||||
// ];
|
||||
|
||||
|
||||
let StartSubsrib = () => {
|
||||
these.EquipMents=[];
|
||||
ble = bleTool.getBleTool();
|
||||
|
||||
|
||||
|
||||
|
||||
ble.addDeviceFound((arr) => {
|
||||
|
||||
arr = arr.devices;
|
||||
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
|
||||
arr[i].linkStatu = false;
|
||||
if (!arr[i].name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let f = these.EquipMents.find((v, index) => {
|
||||
if (v.deviceId == arr[i].deviceId) {
|
||||
|
||||
these.$set(these.EquipMents[index], 'RSSI', arr[i].RSSI);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (!f) {
|
||||
console.log("发现新设备,", arr[i]);
|
||||
|
||||
if (these.device && these.device.bluetoothName) {
|
||||
if (these.device.bluetoothName === arr[i].name || arr[i].name.indexOf(these
|
||||
.device.bluetoothName) > -1 || these.device.bluetoothName.indexOf(arr[
|
||||
i].name) > -1) {
|
||||
arr[i].isTarget = true;
|
||||
}
|
||||
}
|
||||
arr[i].name = arr[i].name.replace('JQZM-', '');
|
||||
these.EquipMents.push(arr[i]);
|
||||
}
|
||||
}
|
||||
console.log("EquipMents=", these.EquipMents)
|
||||
}, pagePath);
|
||||
|
||||
ble.addReceiveCallback((receivData, f, path, arr) => {
|
||||
if (f.macAddress && these.device) {
|
||||
clearInterval(this.Status.intval);
|
||||
this.Status.intval = null;
|
||||
this.Status.time = null;
|
||||
|
||||
showLoading(these, {
|
||||
text: '正在验证设备'
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
these.DeviceVerdict(f.deviceId);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
|
||||
}, pagePath);
|
||||
|
||||
}
|
||||
|
||||
if (search) {
|
||||
StartSubsrib();
|
||||
}
|
||||
|
||||
eventChannel.on('detailData', function(rec) {
|
||||
console.log("接收到父页面的参数:", rec);
|
||||
these.device = rec.data;
|
||||
StartSubsrib();
|
||||
these.refreshBleList();
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
onShow: function() {
|
||||
|
||||
|
||||
// this.EquipMents = [];
|
||||
|
||||
// this.PairEquip = [];
|
||||
ble && ble.StartSearch().then(res => {
|
||||
console.log("开始搜索成功", res);
|
||||
}).catch((ex) => {
|
||||
console.log("开始搜索出现异常", ex);
|
||||
if (ex.code == 10001) {
|
||||
these.showOpenSetting();
|
||||
}
|
||||
});
|
||||
this.refreshBleList();
|
||||
},
|
||||
methods: {
|
||||
refreshBleList() {
|
||||
if (!ble) {
|
||||
return;
|
||||
}
|
||||
console.log("111111");
|
||||
|
||||
ble.StopSearch().then(res => {
|
||||
console.log("停止搜索成功");
|
||||
// console.log("停止搜索成功");
|
||||
this.EquipMents = [];
|
||||
ble.StartSearch().then(result => {
|
||||
console.log("开始搜索成功");
|
||||
// console.log("开始搜索成功");
|
||||
}).catch(err => {
|
||||
console.log("err=", err);
|
||||
console.error("开始搜索失败,err=", err);
|
||||
if(err.code===10001){
|
||||
these.showOpenSetting();
|
||||
}else{
|
||||
uni.showModal({
|
||||
title:'提示',
|
||||
content:'出现异常:'+err.msg
|
||||
});
|
||||
}
|
||||
});
|
||||
}).catch(ex => {
|
||||
console.log("ex=", ex);
|
||||
console.error("ex=", ex);
|
||||
});
|
||||
},
|
||||
isItemLink: function(item, index) {
|
||||
@ -339,7 +368,6 @@
|
||||
updateLoading(these, {
|
||||
text: "设备Mac地址错误,请重选设备连接"
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
hideLoading(these);
|
||||
}, 1000)
|
||||
@ -465,6 +493,7 @@
|
||||
}
|
||||
|
||||
execLink().then((res) => {
|
||||
console.log("res=", res);
|
||||
linkCallback(res);
|
||||
}).catch(ex => {
|
||||
console.log("ex=", ex)
|
||||
@ -565,7 +594,7 @@
|
||||
.animate .titleIco {
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
|
||||
|
||||
}
|
||||
|
||||
.circle {
|
||||
@ -575,7 +604,8 @@
|
||||
animation: expand 4s infinite ease-out;
|
||||
display: inline-block;
|
||||
transform: translate(-50%, -50%);
|
||||
border:1rpx solid #bbe6003d;
|
||||
border: 1rpx solid #bbe6003d;
|
||||
animation: expand 5s infinite ease-in-out;
|
||||
}
|
||||
|
||||
.circle:nth-child(2) {
|
||||
@ -587,21 +617,22 @@
|
||||
}
|
||||
|
||||
@keyframes expand {
|
||||
0% {
|
||||
width: 0;
|
||||
height: 0;
|
||||
opacity: 0.8;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
100% {
|
||||
width: 18.75rem;
|
||||
height: 18.75rem;
|
||||
opacity: 0.2;
|
||||
|
||||
}
|
||||
0% {
|
||||
width: 0;
|
||||
height: 0;
|
||||
opacity: 0.8;
|
||||
}
|
||||
80% {
|
||||
width: 18.75rem;
|
||||
height: 18.75rem;
|
||||
opacity: 0.2;
|
||||
}
|
||||
100% {
|
||||
|
||||
width: 0.5rem;
|
||||
height: 0.5rem;
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
.mainContent {
|
||||
@ -659,7 +690,9 @@
|
||||
flex-wrap: nowrap;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
margin-top: 10rpx;
|
||||
margin-top: 20rpx;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.list .item .leftImg {
|
||||
@ -680,6 +713,33 @@
|
||||
|
||||
}
|
||||
|
||||
.list .item .before {
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
right: 0px;
|
||||
content: "";
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-right: 30rpx solid #bbe600d4;
|
||||
border-top: 30rpx solid transparent;
|
||||
animation-delay: 1s;
|
||||
animation: fade 1.5s infinite ease-in-out;
|
||||
}
|
||||
|
||||
@keyframes fade {
|
||||
0% {
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
50% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 0.3;
|
||||
}
|
||||
}
|
||||
|
||||
.list .item .rightIco {
|
||||
width: 40rpx;
|
||||
height: 100%;
|
||||
@ -695,7 +755,7 @@
|
||||
.list .item .leftImg .titleIco {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
filter:invert(100%);
|
||||
filter: invert(100%);
|
||||
}
|
||||
|
||||
.list .item .name {
|
||||
|
||||
Reference in New Issue
Block a user