zachary преди 4 години
родител
ревизия
0741b0f54e
променени са 3 файла, в които са добавени 94 реда и са изтрити 17 реда
  1. 78 14
      components/map-sense/map-sense.js
  2. 13 3
      project.config.json
  3. 3 0
      utils/util.js

+ 78 - 14
components/map-sense/map-sense.js

@@ -16,13 +16,37 @@ const STATUS_PIC = {
 
 // 选择6档
 const TXPOWER = -55
-
+var result = 0,oldResult = -1;
 // 距离经验值(调试所得)
 const N = 3.3
 
 
 let AveLength = 10
 
+let AudioAddress={
+  0:'https://culture.4dage.com/demo/audio/1.2.mp3',
+  1:'https://culture.4dage.com/demo/audio/3.mp3',
+  2:'https://culture.4dage.com/demo/audio/4.mp3',
+  3:'https://culture.4dage.com/demo/audio/5.mp3',
+  4:'https://culture.4dage.com/demo/audio/6.mp3',
+  5:'https://culture.4dage.com/demo/audio/7.mp3',
+  6:'https://culture.4dage.com/demo/audio/8.mp3',
+  7:'https://culture.4dage.com/demo/audio/9.mp3',
+  8:'https://culture.4dage.com/demo/audio/10.mp3',
+  9:'https://culture.4dage.com/demo/audio/11.mp3',
+  10:'https://culture.4dage.com/demo/audio/12.13.mp3',
+  11:'https://culture.4dage.com/demo/audio/14.mp3',
+  12:'https://culture.4dage.com/demo/audio/15.mp3',
+  13:'https://culture.4dage.com/demo/audio/16.mp3',
+  14:'https://culture.4dage.com/demo/audio/17.mp3',
+  15:'https://culture.4dage.com/demo/audio/18.mp3',
+  16:'https://culture.4dage.com/demo/audio/19.mp3',
+  17:'https://culture.4dage.com/demo/audio/20.21.mp3',
+  18:'https://culture.4dage.com/demo/audio/22.mp3',
+  19:'https://culture.4dage.com/demo/audio/23.mp3',
+  20:'https://culture.4dage.com/demo/audio/24.mp3',
+}
+
 Component({
   /**
    * 组件的属性列表
@@ -131,30 +155,69 @@ Component({
             })
 
             // 筛选器,筛选出配对的一组信标
-            let signSelect = [0,0,0];           //记录各组的信标出现数量,投票选择最多的,依次是prologue,annexHall,mainHall
-            const prologue = ['10001','10002']                    //序厅
-            const annexHall = ['10003','10004']                    //附厅
-            const mainHall = ['10005','10006']                     //主厅
-            const R = 6                                           //设定范围半径
+            let signSelect = new Array(21).fill(0);           //记录各组的信标出现数量,投票选择最多的,依次是prologue,annexHall,mainHall
+            // const prologue = ['10001','10002']                    //序厅
+            // const annexHall = ['10003','10004','10005','10006','10007']                    //附厅
+            // const mainHall = ['10008']                     //主厅
+            let group = [
+              ['10001','10002'],['10003'],
+              ['10004'],['10005'],['10006'],
+              ['10007'],['10008'],['10009'],
+              ['10010'],['10011'],['10012','10013'],
+              ['10014'],['10015'],['10016'],
+              ['10017'],['10018'],['10019'],
+              ['10020','10021'],['10022'],
+              ['10023'],['10024']
+            ];
+              // 1:['10001','10002'],2:['10003'],
+              // 3:['10004'],4:['10005'],5:['10006'],
+              // 6:['10007'],7:['10008'],8:['10009'],
+              // 9:['10010'],10:['10011'],11:['10012','10013'],
+              // 12:['10014'],13:['10015'],14:['10016'],
+              // 15:['10017'],16:['10018'],17:['10019'],
+              // 18:['10020','10021'],19:['10022'],
+              // 20:['10023'],21:['10024']
+            
+            const R = 2.1                                      //设定范围半径
+            // console.log(accuracyList);
             Object.keys(accuracyList).forEach(key=>{
               let aveAccuracy = BeaconUtils.arrayAverage(accuracyList[key])
 
               if(aveAccuracy < R){
-                if(prologue.includes(key)){
-                  signSelect[0] += 1;
-                }else if(annexHall.includes(key)){
-                  signSelect[1] += 1;
-                }else if(mainHall.includes(key)){
-                  signSelect[2] += 1;
+                // if(prologue.includes(key)){
+                //   signSelect[0] += 1;
+                // }else if(annexHall.includes(key)){
+                //   signSelect[1] += 1;
+                // }else if(mainHall.includes(key)){
+                //   signSelect[2] += 1;
+                // }
+                for(let i = 0;i<group.length;i++){
+                  if(group[i].includes(key)){
+                    signSelect[i] += accuracyList[key].length;
+                  }
                 }
               }
             })
+            // console.log(signSelect);
             //对小于预设半径的信号进行数量投票
-            let result = BeaconUtils.maxIndex(signSelect);
+            result = BeaconUtils.maxIndex(signSelect);
             console.log('result',result);
+            if(result!=null && result != oldResult){
+              innerAudioContext.stop();
+              innerAudioContext.destroy();
+              innerAudioContext.autoplay = true;
+              innerAudioContext.src = AudioAddress[result];
+              // console.log(innerAudioContext.src);
+              innerAudioContext.play();
+              oldResult = result;
+            }else{
+              innerAudioContext.play();
+            }
+
             
             this.setData({
               classfiy,
+              result,
               status:'2'
             })
           })
@@ -221,6 +284,7 @@ Component({
     getAudios() {
       http.get('/api/web/getAudioIndex')
         .then(res => {
+          console.log(res);
           let { data } = res,target = {};
           data.forEach(item => {
             switch (item.type) {
@@ -238,7 +302,7 @@ Component({
             }
           })
           this.setData({
-            audio_address: target
+            audio_address: target,
           })
         })
     }

+ 13 - 3
project.config.json

@@ -8,6 +8,7 @@
     "es6": true,
     "enhance": false,
     "postcss": true,
+    "preloadBackgroundData": false,
     "minified": true,
     "newFeature": false,
     "coverView": true,
@@ -19,14 +20,23 @@
     "checkInvalidKey": true,
     "checkSiteMap": true,
     "uploadWithSourceMap": true,
+    "compileHotReLoad": false,
+    "lazyloadPlaceholderEnable": false,
+    "useMultiFrameRuntime": true,
+    "useApiHook": true,
+    "useApiHostProcess": false,
     "babelSetting": {
       "ignore": [],
       "disablePlugins": [],
       "outputPath": ""
     },
-    "useMultiFrameRuntime": true,
-    "useApiHook": true,
-    "useApiHostProcess": false
+    "enableEngineNative": false,
+    "useIsolateContext": true,
+    "userConfirmedBundleSwitch": false,
+    "packNpmManually": false,
+    "packNpmRelationList": [],
+    "minifyWXSS": true,
+    "showES6CompileOption": false
   },
   "compileType": "miniprogram",
   "libVersion": "2.17.0",

+ 3 - 0
utils/util.js

@@ -124,6 +124,9 @@ getOneGuassionArray: function(size, kerR, sigma) {
         max = arr[i];
       }
     }
+    if(arr[index] == 0){
+      return null;
+    }
     return index;
   }
 }