|
@@ -63,31 +63,39 @@ Component({
|
|
|
},
|
|
|
toHandle() {
|
|
|
let aveArr = []
|
|
|
+
|
|
|
+
|
|
|
this.openBluetooth(()=>{
|
|
|
startBeaconDiscovery({uuids: ['FDA50693-A4E2-4FB1-AFCF-C6EB07647825']}).then((res)=>{
|
|
|
wx.onBeaconUpdate(data=>{
|
|
|
- if (!arr) {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if (aveArr.length == 10) {
|
|
|
+ if (aveArr.length == AveLength) {
|
|
|
aveArr[0] = data.beacons
|
|
|
}
|
|
|
else{
|
|
|
aveArr.push(data.beacons)
|
|
|
}
|
|
|
-
|
|
|
+ let all = []
|
|
|
aveArr.forEach(item => {
|
|
|
- item = item.map(sub=>{
|
|
|
- sub.accuracy
|
|
|
- })
|
|
|
-
|
|
|
+ all = all.concat(item)
|
|
|
});
|
|
|
|
|
|
- console.log(aveArr,'=========');
|
|
|
-
|
|
|
- // let aaa = BeaconUtils.arrayAverage(arr)
|
|
|
+ let classfiy = BeaconUtils.classification(all,'major')
|
|
|
+ Object.keys(classfiy).forEach(key=>{
|
|
|
+ //每个major的AveLength个元素数组
|
|
|
+ let arr = classfiy[key].map(item=>{
|
|
|
+ return item.accuracy
|
|
|
+ })
|
|
|
+ //每个major的平均值
|
|
|
+ let ave = BeaconUtils.arrayAverage(arr)
|
|
|
+ classfiy[key].forEach(item=>{
|
|
|
+ item.accuracy = ave
|
|
|
+ })
|
|
|
+ })
|
|
|
|
|
|
+ this.setData({
|
|
|
+ classfiy,
|
|
|
+ status:'2'
|
|
|
+ })
|
|
|
})
|
|
|
}).catch(()=>{
|
|
|
wx.showToast({
|
|
@@ -98,28 +106,7 @@ Component({
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
- startBeaconDiscovery() {
|
|
|
- wx.startBeaconDiscovery({
|
|
|
- uuids: ['FDA50693-A4E2-4FB1-AFCF-C6EB07647825'],
|
|
|
- success: function (res) {
|
|
|
-
|
|
|
- },
|
|
|
- fail: function (e) {
|
|
|
- wx.showToast({
|
|
|
- title: '连接失败',
|
|
|
- icon: 'error',
|
|
|
- duration: 500
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- // 超时停止扫描
|
|
|
- // setTimeout(function () {
|
|
|
- // wx.stopBeaconDiscovery({
|
|
|
- // success: function () {
|
|
|
- // }
|
|
|
- // });
|
|
|
- // }, 1 * 1000);
|
|
|
- },
|
|
|
+
|
|
|
stopBeaconDiscovery() {
|
|
|
var that = this;
|
|
|
console.log('这是取消连接')
|
|
@@ -169,6 +156,7 @@ Component({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
getAudios() {
|
|
|
http.get('/api/web/getAudioIndex')
|
|
|
.then(res => {
|