完成7305,添加在详情页去绑定蓝牙设备
This commit is contained in:
@ -97,6 +97,7 @@
|
||||
const pagePath="pages/common/addBLE/addEquip";
|
||||
var ble = null;
|
||||
var these = null;
|
||||
var eventChannel=null;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -128,7 +129,11 @@
|
||||
|
||||
},
|
||||
PairEquip: [], //已配对设备
|
||||
EquipMents: [] //搜索出来的设备
|
||||
EquipMents: [], //搜索出来的设备
|
||||
device:null,
|
||||
item:{
|
||||
deviceId:''
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -145,7 +150,8 @@
|
||||
},
|
||||
onUnload(){
|
||||
ble.StopSearch();
|
||||
|
||||
ble.removeDeviceFound(pagePath);
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
},
|
||||
onLoad() {
|
||||
these = this;
|
||||
@ -170,13 +176,23 @@
|
||||
|
||||
}
|
||||
}
|
||||
},pagePath);
|
||||
// ble.addReceiveCallback((receivData) => {
|
||||
}, pagePath);
|
||||
// console.log("addEquip")
|
||||
// ble.addReceiveCallback((receivData,f,path,arr) => {
|
||||
// console.log("收到数据了:", receivData);//数据格式:{bytes:[109,97],str:"",hexs:"FA 01"}
|
||||
// if (this.item.deviceId == receivData.deviceId) {
|
||||
// console.log("11111:",receivData);
|
||||
|
||||
// // let data=uni.getStorageSync(ble.StorageKey);
|
||||
// console.log("LinkedList=",ble.data.LinkedList);
|
||||
// },pagePath);
|
||||
|
||||
// }
|
||||
|
||||
// });
|
||||
eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
eventChannel.on('detailData', function(rec) {
|
||||
console.log("接收到父页面的参数:",rec);
|
||||
these.device=rec.data;
|
||||
});
|
||||
},
|
||||
|
||||
onShow: function() {
|
||||
@ -223,7 +239,7 @@
|
||||
ble.showBlueSetting(false);
|
||||
},
|
||||
Link: function(item, index) {
|
||||
|
||||
this.item.deviceId=item.deviceId;
|
||||
showLoading(this,{
|
||||
text: "正在连接"
|
||||
});
|
||||
@ -241,6 +257,18 @@
|
||||
these.PairEquip.push(item);
|
||||
}
|
||||
console.log("连接成功");
|
||||
if(these.device){//从设备详情过来的,回设备详情去
|
||||
ble.data.LinkedList.find(v=>{
|
||||
if(v.deviceId==item.deviceId){
|
||||
v.device=these.device;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
ble.updateCache();
|
||||
uni.navigateBack();
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
url:"/pages/common/addBLE/LinkBle",
|
||||
events:{
|
||||
|
||||
Reference in New Issue
Block a user