tremble 4 vuotta sitten
vanhempi
commit
e75b9c552c

+ 5 - 5
hotspot/src/views/Home.vue

@@ -200,11 +200,6 @@ export default {
       }
     },
     fixUrl(item) {
-      let condition =
-        item.indexOf("http://") > -1 || item.indexOf("https://") > -1;
-      if (!condition) {
-        return "https://" + item;
-      }
       return item;
     },
     slideto(action) {
@@ -235,6 +230,10 @@ export default {
 .mb-intro {
   color: #fff;
   padding: 10px;
+  position: fixed;
+  top: 50%;
+  transform: translateY(-50%);
+  left: 0;
   > p {
     line-height: 1.5;
     letter-spacing: 1px;
@@ -244,6 +243,7 @@ export default {
     }
   }
 }
+
 .home {
   width: 100%;
   height: 100%;

+ 23 - 35
macaoApplets/components/map-sense/map-sense.js

@@ -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 => {

+ 16 - 0
macaoApplets/utils/util.js

@@ -36,6 +36,22 @@ arrayAverage:function (arr) {
    return tmp
 },
 
+//数组分类
+classification:function (list,key) {
+  let data = {}
+  for(var i = 0; i < list.length; i++) {
+      if(!data[list[i][key]]) {
+          var arr = [];
+          arr.push(list[i]);
+          data[list[i][key]] = arr;
+      }else {
+          data[list[i][key]].push(list[i])
+      }
+  }
+
+  return data
+},
+
 //求一维队列某点的高斯模糊权重 @param(队列长度,目标位置, 平均差)
 getOneGuassionArray: function(size, kerR, sigma) {
     if (size % 2 > 0) {