tremble hace 4 años
padre
commit
2bc3032e1c

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 3266 - 0
code/src/components/emoji/biaoqing.js


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 3956 - 0
code/src/components/emoji/emoji_sorites.css


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 1 - 0
code/src/components/emoji/emoji_sorites.css.map


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 4747 - 0
code/src/components/emoji/emoji_sorites.less


BIN
code/src/components/emoji/expression.png


+ 274 - 0
code/src/components/emoji/index.vue

@@ -0,0 +1,274 @@
+<template>
+  <div>
+    <div class="biaoqingContent">
+      <img
+        class="expression"
+        @click.stop="show = !show"
+        src="./expression.png"
+      />
+      <!--      表情选择框-->
+      <div class="box" v-if="show" @click.stop>
+        <div class="left">
+          <ul>
+            <li
+              v-for="(item, index) in biaoqingList"
+              :key="index"
+              :class="['cursor', biaoqingActive === index ? 'active' : '']"
+            >
+              <div @click="bqNameChange(index, item.iconArr)">
+                {{ item.name }}
+              </div>
+            </li>
+          </ul>
+        </div>
+        <div class="right">
+          <button
+            v-for="(i, index) in rightList"
+            :key="index"
+            class="emoji"
+            @click.stop="insertHtmlAtCaret(i.icon)"
+          >
+          <span>{{i.icon}}</span>
+          </button>
+        </div>
+      </div>
+    </div>
+  </div>
+</template>
+<script>
+// 定义最后光标对象
+
+import { biaoqingArr } from "./biaoqing.js";
+export default {
+  props: {
+    //表情框宽度
+    width: {
+      type: String,
+      default: "50%",
+    },
+    //表情框高度
+    height: {
+      type: String,
+      default: "200px",
+    },
+    //表情框ID
+    id: {
+      type: String,
+      default: "text",
+    },
+    //内容
+    value: {
+      type: String,
+      default: "",
+    },
+  },
+  data() {
+    return {
+      lastEditRange: "",
+      content: "",
+      show: false,
+      biaoqingList: biaoqingArr,
+      biaoqingActive: 0,
+      rightList: [],
+      allList: [],
+    };
+  },
+  watch: {
+    value() {
+      this.valueChange();
+    },
+  },
+  methods: {
+    valueChange() {
+      if (!this.value) return;
+      let str = this.value;
+      let newStr = this.forArr(this.forArr(str), "className");
+      document.getElementById(this.id).innerHTML = newStr;
+    },
+    //替换emoji 表情图片
+    forArr(str, _type) {
+      for (let j = 0; j < this.allList.length; j++) {
+        let val = this.allList[j];
+        let reg = _type === "className" ? `alt${val.className}` : val.icon;
+        if (_type === "className") {
+          str = str.replace(new RegExp(reg, "g"), val.icon);
+        } else {
+          str = str.replace(
+            new RegExp(reg, "g"),
+            `<img style="vertical-align: sub;" src="http://tkeasyemoji.oss-cn-shanghai.aliyuncs.com/images/placeholder.png" class="${val.className}" alt="alt${val.className}">`
+          );
+        }
+      }
+      return str;
+    },
+    //失去焦点 内容返回
+    onBlur() {
+      let text = document.getElementById(this.id).innerHTML;
+      this.content = text
+        .replace(
+          /<img style="vertical-align: sub;" src="http:\/\/tkeasyemoji\.oss-cn-shanghai\.aliyuncs\.com\/images\/placeholder\.png" class="/g,
+          ""
+        )
+        .replace(/alt="/g, "")
+        .replace(/">/g, "")
+        .replace(/bg-.{7}/g, "");
+      this.$emit("contentChange", {
+        id: this.id,
+        value: this.content,
+      });
+    },
+    // 表情title点击事件
+    bqNameChange(index, arr) {
+      this.biaoqingActive = index;
+      this.rightList = arr;
+    },
+    contentClick() {
+      // 获取选定对象
+      var selection = getSelection();
+      // 设置最后光标对象
+      this.lastEditRange = selection.getRangeAt(0);
+    },
+    //表情插入文本框
+    insertHtmlAtCaret(icon) {
+      this.$emit('select',icon)
+    },
+  },
+
+  created() {
+    this.rightList = biaoqingArr[0].iconArr;
+    biaoqingArr.forEach((e) => {
+      this.allList = this.allList.concat(e.iconArr);
+    });
+  },
+  mounted() {
+    this.valueChange();
+    let that = this;
+    document.body.onclick = function() {
+      that.show = false;
+    };
+  },
+  components: {},
+};
+</script>
+<style>
+@import "./emoji_sorites.css";
+</style>
+<style lang="less" scoped>
+.contentBox {
+  border: 1px solid #ccc;
+  border-radius: 5px;
+  padding: 10px;
+  font-size: 16px;
+  position: relative;
+}
+.biaoqingContent {
+  padding: 5px;
+  width: 30px;
+  margin: 5px auto;
+  position: relative;
+  .expression {
+    width: 20px;
+    margin: 5px 0;
+    cursor: pointer;
+  }
+
+  .box {
+    border: 1px solid #73a8f9;
+    width:400px;
+    min-height: 400px;
+    box-shadow: 0px 0px 16px rgba(0, 0, 0, 0.2);
+    background: #fff;
+    top: 100%;
+    z-index: 999;
+    right: 0;
+    display: flex;
+    position: absolute;
+  }
+  .left {
+    width: 90px;
+    height: 100%;
+    display: table-cell;
+    border-right: 1px solid #ebebeb;
+
+    padding: 4px;
+
+    ul {
+      padding: 0;
+      margin: 0;
+      text-align: center;
+      list-style-type: none;
+
+      li {
+        height: 30px;
+        line-height: 30px;
+        cursor: pointer;
+        font-size: 14px;
+        overflow: hidden;
+        text-overflow: ellipsis;
+        white-space: nowrap;
+
+        button {
+          border: none;
+          background: none;
+          width: 100%;
+          height: 100%;
+        }
+      }
+    }
+
+    .active {
+      background-color: #3171d1;
+      color: #ffffff;
+      border-radius: 4px;
+
+      button {
+        color: #ffffff;
+      }
+    }
+  }
+  .right {
+    flex: 1;
+    padding-left: 10px;
+    padding-top: 15px;
+    overflow: auto;
+
+    button {
+      border: none;
+      padding: 0;
+      cursor: pointer;
+      width: 32px;
+      height: 32px;
+    }
+
+    .emoji {
+      display: inline-block;
+      padding: 3px;
+      border: 1px solid transparent;
+      cursor: pointer;
+      background: #fff;
+
+      &:hover {
+        height: 32px;
+        background-color: #ddded8;
+        border: 1px solid #b3c1fd;
+        border-radius: 4px;
+      }
+    }
+  }
+  //样式一
+  .box0 {
+  }
+}
+
+@media screen and (max-width: 600px) {
+  .biaoqingContent {
+      .box {
+        width: 80vw;
+        right: -10vw;
+        max-height: 26vh;
+        min-height: unset;
+        overflow-y: auto;
+      }
+  }
+}
+</style>

BIN
code/src/components/emoji/placeholder.png


+ 1 - 0
code/src/pages/index/index.vue

@@ -32,6 +32,7 @@ import history from '@/pages/history'
 import bg from '@/components/background'
 
 
+// http://192.168.0.44:8110/
 let temp = ''
 const outKey = "791"
 const inKey = "762"

+ 50 - 11
code/src/pages/tunnel/index.vue

@@ -67,10 +67,14 @@
                   rows="7"
                 >
                 </textarea>
-                <span>{{ msg.length }}/100</span>
+                <div class="rightbotom">
+                  <span>{{ msg.length }}/100</span>
+                  <emoji @select="selectEmoji" :type="0" id="biaoqing1"/>
+                </div>
+
                 <div class="btn">
                   <span @click="leaveMsg" class="primary">提交</span>
-                  <span @click="(msg = ''), (nickName = '')">取消</span>
+                  <span @click="(msg = ''), (nickName = '')">重置</span>
                 </div>
 
                 <div class="leaveSuccess" v-if="isSuccess">
@@ -200,7 +204,10 @@
               rows="7"
             >
             </textarea>
-            <span>{{ msg.length }}/100</span>
+            <div class="rightbotom">
+                  <span>{{ msg.length }}/100</span>
+                  <emoji @select="selectEmoji" :type="0" id="biaoqing1"/>
+                </div>
             <div class="link"></div>
             <div class="btn">
               <span @click="leaveMsg" class="primary">提交</span>
@@ -220,6 +227,8 @@
 </template>
 
 <script>
+import emoji from "@/components/emoji";
+
 export default {
   data() {
     return {
@@ -234,7 +243,12 @@ export default {
       showTips:false
     };
   },
+  components:{emoji},
   methods: {
+    selectEmoji(data){
+      this.msg += data
+      console.log(data,'-------------')
+    },
     showLyfn() {
       this.showLy = true;
       this.activeComment = "";
@@ -256,12 +270,12 @@ export default {
       this.$nextTick(() => {
         this.$refs.nicknameinput && this.$refs.nicknameinput.focus();
         this.$refs.mbnicknameinput && this.$refs.mbnicknameinput.focus();
-        this.$refs.nicknameinput.classList.add('redp');
-        this.$refs.contenttextarea.classList.add('redp');
+        this.$refs.nicknameinput && this.$refs.nicknameinput.classList.add('redp');
+        this.$refs.nicknameinput && this.$refs.contenttextarea.classList.add('redp');
       });
     },
     removeredp(e){
-        e.target.classList.remove('redp');
+        e.target && e.target.classList.remove('redp');
     },
     async getMessage() {
       this.msg = "";
@@ -280,6 +294,8 @@ export default {
       return str.substring(0, str.length - 3);
     },
     async leaveMsg() {
+      this.$refs.nicknameinput && this.$refs.nicknameinput.classList.remove('redp');
+      this.$refs.contenttextarea && this.$refs.contenttextarea.classList.remove('redp');
       if (!this.nickName || !this.msg) {
         return alert("请填写完整");
       }
@@ -538,12 +554,23 @@ h2 {
         padding-left: 10px;
         padding-top: 10px;
       }
-      > span {
+      .rightbotom{
+        position: absolute;
         transform: translateY(0);
         top: unset;
-        bottom: 50px;
+        bottom: 30px;
         right: 14px;
+        display: flex;
+        align-items: center;
+        z-index: 99;
+        > span {
+          font-size: 14px;
+          color: #ACACAC;
+          display: inline-block;
+          margin-right: 5px;
+        }
       }
+     
       .btn {
         font-size: 14px;
         display: flex;
@@ -598,6 +625,8 @@ h2 {
       margin-bottom: 10px;
       .info {
         position: relative;
+        border-bottom: 1px solid #ddd;
+        padding-bottom: 10px;
         .name {
           color: #cf7b0e;
           vertical-align: middle;
@@ -765,11 +794,21 @@ h2 {
         border: none;
         padding: 10px 10px 10px;
       }
-      > span {
+      .rightbotom{
+        position: absolute;
         transform: translateY(0);
         top: unset;
-        bottom: 55px;
+        bottom: 40px;
         right: 14px;
+        display: flex;
+        align-items: center;
+        z-index: 99;
+        > span {
+          font-size: 14px;
+          color: #ACACAC;
+          display: inline-block;
+          margin-left: 10px;
+        }
       }
       .link {
         width: 90%;
@@ -827,7 +866,7 @@ h2 {
         color: #fcd67b;
         > ul {
           > li {
-            border-bottom: 1px solid #fcd67b;
+            border-bottom: none;
             padding: 20px 0;
             &:last-of-type {
               border-bottom: none;

+ 1 - 1
macaoApplets/components/audio-play/audio-play.wxml

@@ -1,6 +1,6 @@
 <!--components/audio-play.wxml-->
 <view class="audio">
-  <image class="bg-img" mode="aspectFill" src="{{targetUrl}}{{audio.icon}}"></image>
+  <image class="bg-img" src="{{targetUrl}}{{audio.icon}}"></image>
   <image class="icon-img" bindtap="startMusic" src="{{cdn_url}}/project/pause.png"
     style="display:{{isPlay?'none':'block'}}">
   </image>

+ 22 - 23
macaoApplets/components/audio-play/audio-play.wxss

@@ -3,54 +3,53 @@
   position: relative;
   width:45%;
   display:inline-block;
-  margin: 20rpx 0;
+  margin:1%;
 }
 .audio .bg-img {
-  width:220rpx;
-  height:220rpx;
+  width:100%;
+  height:15vh;
   display:inline-block
 }
 .audio .icon-img {
-  width:80rpx;
-  height:80rpx;
+  width:5vh;
+  height:5vh;
   position:absolute;
   top:50%;
   left:50%;
-  transform: translate(-50%,-50%);
+  margin-left:-2.5vh;
+  margin-top:-2.5vh;
 }
 
 .audio .free-MusicProgress {
   position: absolute;
   width: 100%;
   height: 20%;
-  background: rgba(0,0,0,0.6);
-  bottom: 0;
-  left: 0;
+  bottom: 6%;
+  background: #000000;
+  opacity: 0.6;
 }
-
-
 .audio .free-MusicProgress .before-progress {
-  width: 50%;
-  height:6rpx;
+  width:80%;
+  height:2px;
   position: absolute;
   top: 50%;
-  transform: translateY(-50%);
-  background: rgba(255,255,255,0.8);
-  margin-left: 10%;
-  overflow: hidden;
-  border: none;
+  background: rgba(255,255,255,0.3);
+  margin:0 10%;
 }
 .audio .free-MusicProgress .progress {
+  height: 100%;
   background: #38A2D7;
-  height:6rpx;
+  
 }
 
 
 .audio .free-MusicProgress .durationTime {
   position: absolute;
-  top: 20%;
-  right: 5%;
-  display: inline-block;
-  font-size: 20rpx;
+  top: 22%;
+  right: 6%;
+  font-size: 10px;
+  font-family: Microsoft YaHei;
+  font-weight: 400;
   color: #FFFFFF;
+  opacity: 0.67;
 }

+ 1 - 1
macaoApplets/components/big-pic/big-pic.wxml

@@ -2,7 +2,7 @@
   <view class="column" wx:for='{{audioList}}' wx:key="id">
     <view class="title">
       <text class="txt">{{item.title}}</text>
-      <image class="jiantou" src="{{cdn_url}}/project/icon-bottom.png"></image>
+      <image class="title-img" src="{{cdn_url}}/project/icon-bottom.png"></image>
     </view>
     <view class="con-list">
       <audio-play wx:for='{{item.list}}' wx:key="id" audio="{{item}}"></audio-play>

+ 28 - 18
macaoApplets/components/big-pic/big-pic.wxss

@@ -1,36 +1,46 @@
 .content {
   width: 100%;
-  height: 80%;
+  height: 962rpx;
   background: #FFFFFF;
   box-shadow: 0rpx 6rpx 12rpx rgba(0, 0, 0, 0.65);
+  opacity: 1;
   border-radius: 0 0 10rpx;
-  overflow: auto;
+  margin: 0 auto;
+  overflow: scroll;
+}
+
+.content {
+  box-sizing: border-box;
+}
+
+.content .main {
+  box-sizing: border-box;
+  width: 100%;
 }
 
 .content .column {
-  background: linear-gradient(180deg, #D4D4D4 0%, rgba(212, 212, 212, 0) 40%);
-  width: calc(100% - 40rpx);
-  padding: 0 20rpx;
+  width: 100%;
 }
 
 .content .column .title {
   width: 100%;
-  font-size: 24rpx;
-  color: #38A2D7;
+  height: 100%;
   padding: 30rpx 0;
-  display: flex;
-  align-items: center;
+  font-size: 13px;
+  font-family: Microsoft YaHei;
+  font-weight: 400;
+  color: #38A2D7;
+  background: linear-gradient(180deg, #D4D4D4 0%, rgba(212, 212, 212, 0) 100%);
+  padding: 5% 4%;
+  box-sizing: border-box;
 }
-
-
-.content .column .title .jiantou {
-  display: inline-block;
-  width: 30rpx;
-  height: 24rpx;
-  margin-left:12rpx;
+.content .column .title .title-img {
+  width:5%;
+  height:2vh;
+  margin-left:2%;
 }
 
 .content .column .con-list {
-  padding: 0 4%;
-  border-top: 1rpx solid rgba(112, 112, 112, 0.5);
+  margin: 0 4%;
+  border-top: 1px solid #707070;
 }

+ 18 - 9
macaoApplets/components/list-audio/list-audio.wxss

@@ -5,19 +5,24 @@
 }
 
 .list .title {
-  font-size: 24rpx;
+  font-size: 12px;
+  font-family: Microsoft YaHei;
+  font-weight: 400;
+  line-height: 16px;
   color: #2F2414;
   padding-left: 5%;
+  opacity: 1;
 }
 
+
 .audio {
   position: relative;
-  margin: 4% 6%;
+  margin: 2% 8%;
 }
 
 .audio .audio-img {
-  width: 40rpx;
-  height: 40rpx;
+  width:9%;
+  height:4vh;
   display:inline-block;
 }
 
@@ -33,10 +38,11 @@
 
 .audio .free-MusicProgress .before-progress {
   width: 100%;
-  height: 6rpx;
+  height: 0.4vh;
   position: absolute;
   top: 50%;
-  background: #707070;
+  background: #2F2414;
+  opacity: 0.5;
 }
 
 .audio .free-MusicProgress .progress {
@@ -47,8 +53,11 @@
 .list .durationTime {
   position: absolute;
   top: 20%;
-  right: -3%;
-  display: inline-block;
-  font-size: 20rpx;
+  right: -4%;
+  display: inline;
+  font-size: 10px;
+  font-family: Microsoft YaHei;
+  font-weight: 400;
   color: #2F2414;
+  opacity: 0.67;
 }

+ 1 - 1
macaoApplets/components/list/list.wxml

@@ -3,7 +3,7 @@
   <view class="column" wx:for='{{audioList}}' wx:key="id">
     <view class="title">
       <text class="txt">{{item.title}}</text>
-      <image class="jiantou" src="{{cdn_url}}/project/icon-bottom.png"></image>
+      <image class="title-img" src="{{cdn_url}}/project/icon-bottom.png"></image>
     </view>
     <view class="con-list">
       <list-audio wx:for='{{item.list}}' wx:key="id" audio="{{item}}"></list-audio>

+ 27 - 17
macaoApplets/components/list/list.wxss

@@ -1,37 +1,47 @@
 /* components/list/list.wxss */
 .content {
   width: 100%;
-  height: 80%;
+  height: 962rpx;
   background: #FFFFFF;
   box-shadow: 0rpx 6rpx 12rpx rgba(0, 0, 0, 0.65);
+  opacity: 1;
   border-radius: 0 0 10rpx;
-  overflow: auto;
+  margin: 0 auto;
+  overflow: scroll;
 }
 
+.content {
+  box-sizing: border-box;
+}
+
+.content .main {
+  box-sizing: border-box;
+  width: 100%;
+}
 
 .content .column {
-  background: linear-gradient(180deg, #D4D4D4 0%, rgba(212, 212, 212, 0) 40%);
-  width: calc(100% - 40rpx);
-  padding: 0 20rpx;
+  width: 100%;
 }
 
 .content .column .title {
   width: 100%;
-  font-size: 24rpx;
-  color: #38A2D7;
+  height: 100%;
   padding: 30rpx 0;
-  display: flex;
-  align-items: center;
+  font-size: 13px;
+  font-family: Microsoft YaHei;
+  font-weight: 400;
+  color: #38A2D7;
+  background: linear-gradient(180deg, #D4D4D4 0%, rgba(212, 212, 212, 0) 100%);
+  padding: 5% 4%;
+  box-sizing: border-box;
 }
-
-
-.content .column .title .jiantou {
-  display: inline-block;
-  width: 30rpx;
-  height: 24rpx;
-  margin-left:12rpx;
+.content .column .title .title-img {
+  width:5%;
+  height:2vh;
+  margin-left:2%;
 }
 
 .content .column .con-list {
-  border-top: 1rpx solid rgba(112, 112, 112, 0.5);
+  margin: 0 4%;
+  border-top: 1px solid #707070;
 }

+ 300 - 188
macaoApplets/components/map-sense/map-sense.js

@@ -1,34 +1,58 @@
 // components/map-sense.js
 
-let innerAudioContext = wx.createInnerAudioContext();
-innerAudioContext.autoplay = true;
-innerAudioContext.loop = true;
-
-import http from "../../utils/http";
-import { promisify, BeaconUtils } from "../../utils/util";
-let openBluetoothAdapter = promisify(wx.openBluetoothAdapter);
-let startBeaconDiscovery = promisify(wx.startBeaconDiscovery);
-
-import {
-  CDN_URL,
-  CONNECT_STATUS,
-  STATUS_TEXT,
-  API_BASE_URL,
-} from "../../config/index";
+const innerAudioContext = wx.createInnerAudioContext();
+import http from '../../utils/http';
+import {promisify,BeaconUtils} from '../../utils/util';
+let openBluetoothAdapter = promisify(wx.openBluetoothAdapter)
+let startBeaconDiscovery = promisify(wx.startBeaconDiscovery)
+
+import { CDN_URL, CONNECT_STATUS, STATUS_TEXT, API_BASE_URL } from '../../config/index';
 const STATUS_PIC = {
-  0: "default",
-  1: "loading",
-  2: "success",
-  3: "fail",
+  '0': 'default',
+  '1': 'loading',
+  '2': 'success',
+  '3': 'fail'
 };
 
-let AveLength = 4;
+// 选择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({
   /**
    * 组件的属性列表
    */
-  properties: {},
+  properties: {
+  },
 
   /**
    * 组件的初始数据
@@ -44,7 +68,8 @@ Component({
     api_base_url: API_BASE_URL,
     // 是否是扫码播放
     isScanPlay: false,
-    cdn_url: CDN_URL,
+    cdn_url:CDN_URL,
+    classfiy:{}
   },
 
   /**
@@ -52,196 +77,283 @@ Component({
    */
   methods: {
     openBluetooth(cb) {
-      openBluetoothAdapter().then(
-        (res) => {
-          cb(res);
-        },
-        () => {
-          wx.showToast({
-            title: "请打开蓝牙",
-            icon: "error",
-            duration: 2000,
-          });
-        }
-      );
+      openBluetoothAdapter().then(res=>{
+        cb(res)
+      },()=>{
+        wx.showToast({
+          title: '请打开蓝牙',
+          icon: 'error',
+          duration: 2000
+        })
+      })
     },
     toHandle() {
-      switch (this.data.status) {
-        case "0":
-          this.openLink();
-          break;
-        case "1":
-          this.stopBeaconDiscovery();
-          break;
-        case "2":
-          this.stopBeaconDiscovery();
-          break;
-        case "3":
-          this.startBeaconDiscovery();
-          break;
-        default:
-          break;
-      }
-    },
+      let aveArr = []
+      
+      this.openBluetooth(()=>{
+        startBeaconDiscovery({uuids: ['FDA50693-A4E2-4FB1-AFCF-C6EB07647825']}).then((res)=>{
+          
+          wx.onBeaconUpdate(data=>{
+            // 需要收集十组数据,索引号最大的组是最旧的
+            if (aveArr.length > AveLength) {
+              //当超过十组时,应该将索引号大的组淘汰掉
+              aveArr.pop()
+            }
+            aveArr.unshift(data.beacons)   //在队列前面插入
 
-    playMusic(url) {
-      innerAudioContext.src =encodeURI(url);
-      innerAudioContext.play();
-    },
-
-    openLink() {
-      let aveArr = [];
-      wx.showLoading({
-        mask: true,
-        title: "正在连接,请稍等",
-      });
-      this.openBluetooth(() => {
-        startBeaconDiscovery({
-          uuids: ["FDA50693-A4E2-4FB1-AFCF-C6EB07647825"],
-        })
-          .then(() => {
-            wx.hideLoading();
-            wx.showToast({
-              title: "连接成功",
-              icon: "success",
+            let all = []
+            aveArr.forEach(item => {
+                all = all.concat(item)
             });
-            this.setData({
-              status: "2",
-            });
-            wx.onBeaconUpdate((data) => {
-              if (aveArr.length == AveLength) {
-                aveArr[0] = data.beacons;
-              } else {
-                aveArr.push(data.beacons);
+            // classfiy = {10003:[{},{},···],10002:[{},{},···],10001:[{},{},···]}
+            let classfiy = BeaconUtils.classification(all,'major')
+            let accuracyList = {}         // 存放处理后的accuary
+            Object.keys(classfiy).forEach(key=>{
+              //每个major的AveLength个元素数组,元素为rssi
+              let arr = classfiy[key].map(item=>{
+                return item.rssi
+              })
+
+              //每个major的rssi平均值
+              let ave = BeaconUtils.arrayAverage(arr)
+
+              //计算方差
+              let meanDeviation = BeaconUtils.getVariance(arr,ave);  
+
+              //计算各rssi的高斯模糊权重
+              let guassionArr = [];           //存放权重数组
+              for(let i = 0; i < arr.length; ++i){
+                guassionArr.push(BeaconUtils.getOneGuassionArray(arr.length,i,meanDeviation));
               }
-              let all = [];
-              aveArr.forEach((item) => {
-                all = all.concat(item);
-              });
-
-              let classfiy = BeaconUtils.classification(all, "major");
-              let aveAccuracy = {};
-
-              let min = {
-                id: "10001",
-                val: 10000000,
-              }; //取最小值
-              Object.keys(classfiy).forEach((key) => {
-                //每个major的AveLength个元素数组
-                let arr = classfiy[key].filter((item) => {
-                  return item.accuracy > 0;
-                });
-                if (arr.length <= 0) {
-                  return;
+
+              //计算高斯模糊后的rssi值
+              let rssiArr = [];                  //模糊后的rssi数组
+              for(let i = 0; i < arr.length; ++i){
+                let sum = 0;
+                for(let j = 0; j <arr.length; ++j){
+                  if(guassionArr[i].length == 0){
+                    sum = arr[j]
+                    break;
+                  }
+                  sum += guassionArr[i][j] * arr[j]
                 }
+                rssiArr.push(sum);
+              }
 
-                //每个major的平均值
-                let ave = BeaconUtils.arrayAverage(
-                  arr.map((sub) => sub.accuracy)
-                );
-                classfiy[key].forEach((item) => {
-                  item.accuracy = ave;
-                });
-                aveAccuracy[key] = ave;
-                min = ave < min.val ? { id: key, val: ave } : min;
-              });
-
-              this.setData({
-                classfiy,
-                targetObj: {
-                  major: min.id,
-                },
-              });
-
-              this.data.audio_address[min.id] &&
-                this.playMusic(this.data.audio_address[min.id]);
-            });
+              //时间加权后求rssi平均值
+              let aveOnTime = BeaconUtils.arrayAverage(rssiArr.slice(0,Math.floor(rssiArr.length / 3)).concat(rssiArr));
+
+              //测距,根据时间加权后的rssi计算距离
+              classfiy[key].forEach(item=>{
+                  item.accuracy = BeaconUtils.calculateAccuracy(TXPOWER,aveOnTime,N)
+                  if(!accuracyList[key]){
+                    //如果还没有对应的“信标号”
+                    accuracyList[key] = [item.accuracy]
+                  }
+                  accuracyList[key].push(item.accuracy)
+              })
+            })
+
+            // 筛选器,筛选出配对的一组信标
+            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;
+                // }
+                for(let i = 0;i<group.length;i++){
+                  if(group[i].includes(key)){
+                    signSelect[i] += accuracyList[key].length;
+                  }
+                }
+              }
+            })
+            // console.log(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();
+            }
+
+            
+
+            innerAudioContext.stop();
+            innerAudioContext.destroy();
+            
+            innerAudioContext.autoplay = true;
+            innerAudioContext.src = AudioAddress[result]
+            innerAudioContext.play();
+            
+            this.setData({
+              classfiy,
+              result,
+              status:'2'
+            })
           })
-          .catch(() => {
-            wx.hideLoading();
-            wx.showToast({
-              title: "连接失败",
-              icon: "error",
-            });
-          });
-      });
+        }).catch(()=>{
+          wx.showToast({
+            title: '连接失败',
+            icon: 'error',
+            duration: 500
+          })
+        })
+      })
     },
-
+    
     stopBeaconDiscovery() {
-      wx.showLoading({
-        mask: true,
-        title: "正在取消连接,请稍等",
-      });
-      wx.stopBeaconDiscovery({
-        success: () => {
-          wx.hideLoading();
-          wx.showToast({
-            title: "取消连接成功",
-            icon: "success",
-          });
-          innerAudioContext.stop();
-          this.setData({
-            status: "0",
-            targetObj: {},
-          });
-        },
-        fail: () => {},
-        complete: () => {},
-      });
+      var that = this;
+      console.log('这是取消连接')
+      wx.showToast({
+        title: '取消连接成功',
+        icon: 'error',
+        duration: 1000
+      })
+      wx.stopBeaconDiscovery({})
+      // 取消连接 停止播放音乐 目标对象置为{} 设置为第一次进入
+      innerAudioContext.stop();
+      that.setData({
+        status: '0',
+        targetObj: {}
+      })
     },
     // 扫一扫
     toScanCode() {
-      this.setData({
-        isScanPlay: true,
-      });
+      var that = this;
+      that.setData({
+        isScanPlay: true
+      })
       wx.scanCode({
-        onlyFromCamera: true,
-        success: (res) => {
-          this.setData({ targetObj: {} });
-          setTimeout(() => {
-            this.playMusic(res["result"])
-          }, 800);
-        },
-        fail: () => {
-          wx.showToast({
-            title: "二维码识别失败",
-            icon: "error",
-          });
+        success(res) {
+          console.log('success', res)
+          console.log('result', res['result'])
+          console.log('innerAudioContext', innerAudioContext)
+          that.setData({ targetObj: {} })
+          innerAudioContext.autoplay = true;
+          innerAudioContext.src = res['result']
+          innerAudioContext.loop = true;
+          innerAudioContext.play();
         },
-        complete: () => {
-          this.setData({
-            isScanPlay: false,
-          });
+        fail: function (res) {
+          console.log('fail innerAudioContext', innerAudioContext)
+          that.setData({
+            isScanPlay: false
+          })
+          innerAudioContext.play();
+          return;
         },
-      });
+        complete(){
+          // console.log()
+          that.setData({
+            isScanPlay: false
+          })
+        }
+      })
     },
 
     getAudios() {
-      http.get("/api/web/getAudioIndex").then((res) => {
-        let { data } = res,
-          target = {};
-        data.forEach((item) => {
-          target[
-            "1000" + item.type
-          ] = `${this.data.api_base_url}/data/${item.audio}`;
-        });
-        this.setData({
-          audio_address: target,
-        });
-      });
-    },
+      http.get('/api/web/getAudioIndex')
+        .then(res => {
+          console.log(res);
+          let { data } = res,target = {};
+          data.forEach(item => {
+            switch (item.type) {
+              case 1:
+                target['10001'] = `${this.data.api_base_url}/data/${item.audio}`;
+                break;
+              case 2:
+                target['10002'] = `${this.data.api_base_url}/data/${item.audio}`;
+                break;
+              case 3:
+                target['10003'] = `${this.data.api_base_url}/data/${item.audio}`;
+                break;
+              default:
+                break
+            }
+          })
+          this.setData({
+            audio_address: target,
+          })
+        })
+    }
   },
-  lifetimes: {
+  lifetimes:{
     attached: function () {
       innerAudioContext.stop();
       //获取语音
-      this.getAudios();
+      // this.getAudios();
+
+      var that = this;
+      // wx.onAccelerometerChange(function (e) {
+      //   console.log('手机咚咚咚给')
+      //   if (Math.abs(e.x) > 1.1 && Math.abs(e.y) > 1.1) {
+      //     //         wx.showToast({ title: "摇一摇" })
+      //   } else if (Math.abs(e.x) > 0.07 && Math.abs(e.y) > 0.02 && that.data.status === '2') {
+      //     // 扫一扫播放的话 移动无效
+      //     if (that.data.isScanPlay) return;
+          
+      //     that.startBeaconDiscovery()
+      //   } else {
+      //     //         wx.showToast({ title: "静止" })
+      //   }
+      // }),
+        innerAudioContext.onEnded(() => {
+          console.log('播放结束了')
+          if (this.data.isScanPlay) {
+            innerAudioContext.stop()
+            this.setData({ isScanPlay: false })
+            this.targetObj = {}
+            console.log('innerAudioContext', innerAudioContext)
+            if (this.data.status == 2) {
+              console.log(2222222222222222)
+              this.startBeaconDiscovery()
+            }
+          }
+        })
     },
     detached: function () {
       innerAudioContext.stop();
       innerAudioContext.destroy();
-      wx.stopBeaconDiscovery({});
-      this.setData({ status: "0" });
-    },
-  },
-});
+      wx.stopBeaconDiscovery({})
+      this.setData({status:"0"})
+    }
+  }
+})

+ 6 - 6
macaoApplets/components/map-sense/map-sense.wxml

@@ -2,23 +2,23 @@
 <view class="content">
   <view class="top">
     <view class="top-bottom">
-      <image class="top-bottom-img" src="{{cdn_url}}/project/big-bg-{{targetObj.major == 10001? 'brown':'blue'}}.png">
+      <image class="top-bottom-img" src="{{cdn_url}}/project/big-bg-{{targetObj.major === 10001? 'brown':'blue'}}.png">
       </image>
-      <view class="{{targetObj.major == 10001 ?'light-sound':'small-sound'}}">
+      <view class="{{targetObj.major === 10001 ?'light-sound':'small-sound'}}">
         <image class="sound-img" src="{{cdn_url}}/project/sound.png"></image>
       </view>
     </view>
     <view class="right-bottom">
-      <image class="right-bottom-img" src="{{cdn_url}}/project/right-{{targetObj.major == 10002? 'brown':'blue'}}.png">
+      <image class="right-bottom-img" src="{{cdn_url}}/project/right-{{targetObj.major === 10002? 'brown':'blue'}}.png">
       </image>
-      <view class="{{targetObj.major == 10002 ?'light-sound':'small-sound'}}">
+      <view class="{{targetObj.major === 10002 ?'light-sound':'small-sound'}}">
         <image class="sound-img" src="{{cdn_url}}/project/sound.png"></image>
       </view>
     </view>
     <view class="center-bottom">
-      <image class="center-bottom-img" src="{{cdn_url}}/project/xt-{{targetObj.major == 10003? 'brown':'blue'}}.png">
+      <image class="center-bottom-img" src="{{cdn_url}}/project/xt-{{targetObj.major === 10003? 'brown':'blue'}}.png">
       </image>
-      <view class="{{targetObj.major == 10003 ?'light-sound':'small-sound'}}">
+      <view class="{{targetObj.major === 10003 ?'light-sound':'small-sound'}}">
         <image class="sound-img" src="{{cdn_url}}/project/sound.png"></image>
       </view>
       <view class="txt">序厅</view>

+ 15 - 12
macaoApplets/components/map-sense/map-sense.wxss

@@ -1,17 +1,20 @@
 /* components/map-sense.wxss */
 .content {
   width: 100%;
-  height: 80%;
+  height: 962rpx;
   background: #FFFFFF;
   box-shadow: 0rpx 6rpx 12rpx rgba(0, 0, 0, 0.65);
-  border-radius: 0 0 10rpx;
-  overflow: auto;
-  position: relative;
+  opacity: 1;
+  border-radius: 0 0 10rpx 10rpx;
+  margin: 0 auto;
+  overflow: scroll;
+}
+
+.content {
   box-sizing: border-box;
   padding: 24rpx 22rpx;
 }
 
-
 .content .top {
   width: 100%;
   height: 342rpx;
@@ -79,7 +82,7 @@
   border-radius: 50%;
   opacity: 1;
   position: absolute;
-  top: 20%;
+  top: 35%;
   right: 35%;
   text-align: center;
 }
@@ -87,10 +90,6 @@
 .content .top .light-sound .sound-img {
   width: 28rpx;
   height: 26rpx;
-  position: absolute;
-  top: 50%;
-  left: 50%;
-  transform: translate(-50%,-50%);
   display: inline-block;
 }
 
@@ -130,8 +129,9 @@
 
 .content .center .promptText {
   text-align: center;
-  font-size: 36rpx;
+  font-size: 19px;
   font-weight: 300;
+  line-height: 25px;
   color: rgba(47, 36, 20, 0.8);
 }
 
@@ -152,7 +152,8 @@
   height: 76rpx;
   background: #FFFFFF;
   border: 2rpx solid #38A2D7;
-  border-radius: 36rpx;
+  opacity: 1;
+  border-radius: 19px;
   text-align: center;
   display: inline;
   padding: 2% 10%;
@@ -167,6 +168,8 @@
   font-weight: 300;
   line-height: 76rpx;
   color: #38A2D7;
+  opacity: 1;
+
 }
 
 .content .top .small-sound {

+ 4 - 3
macaoApplets/pages/index/index.wxss

@@ -7,7 +7,7 @@
 
 .con{
   width: 80%;
-  height: 98%;
+  height: 100%;
   position: absolute;
   top: 50%;
   left: 50%;
@@ -27,12 +27,13 @@
 }
 
 .line{
-  width: 2rpx;
+  width: 1rpx;
   height: 100%;
   background: #1C2E4C;
-  opacity: 0.5;
 }
 
+
+
 .list,
 .bigPic,
 .mail {

+ 14 - 4
macaoApplets/project.config.json

@@ -8,6 +8,7 @@
     "es6": true,
     "enhance": false,
     "postcss": true,
+    "preloadBackgroundData": false,
     "minified": true,
     "newFeature": false,
     "coverView": true,
@@ -19,18 +20,27 @@
     "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",
-  "appid": "wxa4cf7d8be0fbb02a",
+  "appid": "wx88c73e2a2de3c87c",
   "projectname": "macaoApplets",
   "debugOptions": {
     "hidedInDevtools": []

+ 0 - 0
macaoApplets/readme.md


+ 68 - 12
macaoApplets/utils/util.js

@@ -36,7 +36,8 @@ arrayAverage:function (arr) {
    return tmp
 },
 
-//数组分类
+//数组分类:按照关键词key
+//data = {1003:[{},{},···],1002:[{},{},···],1001:[{},{},···]}
 classification:function (list,key) {
   let data = {}
   for(var i = 0; i < list.length; i++) {
@@ -54,24 +55,79 @@ classification:function (list,key) {
 
 //求一维队列某点的高斯模糊权重 @param(队列长度,目标位置, 平均差)
 getOneGuassionArray: function(size, kerR, sigma) {
-    if (size % 2 > 0) {
-      size -= 1
-    }
-    if (!size) {
-      return []
-    }
-    if (kerR > size-1){
-      return []
-    }
+    // if (size % 2 > 0) {
+    //   size -= 1
+    // }
+    // if (!size) {
+    //   return []
+    // }
+    // if (kerR > size-1){
+    //   return []
+    // }
     let sum = 0;
     let arr = new Array(size);
-
+    //进来的列表的元素可能是一样的,防止平均差为0的情况
+    if(sigma == 0){
+      let weight = 1 / size;
+      return arr.fill(weight)
+    }
     for (let i = 0; i < size; i++) {
-      arr[i] = Math.exp(-((i - kerR) * (i - kerR)) / (2 * sigma * sigma));
+      arr[i] = Math.exp(-((i - kerR) * (i - kerR)) / (2 * sigma * sigma))
       sum += arr[i];
     }
 
     return arr.map(e => e / sum);
+  },
+
+  //计算数组平均差
+  //list:rssi数组
+  //average:rssi平均值
+  getMeanDeviation: function(list,average){
+    let length = list.length;
+    //数组的每一个数都要减去一个平均数,结果取绝对值
+    let arr = list.map(num=>Math.abs(num-average))
+    return arr.reduce((prev,curr)=>prev+curr) / length;
+  },
+
+  //计算数组方差
+  // list:待计算数组
+  // average:数组元素平均值
+  getVariance:function(list,average){
+    let sum = 0;
+    for(let element of list){
+      sum += Math.pow((element - average),2)
+    }
+    return sum / list.length
+  },
+
+  //js实现字符串重复的repeat函数
+  repeat:function(src, n) {
+    return (new Array(n + 1)).join(src);
+  },
+
+  //计算椭圆长度
+  //R是预设的有效范围半径
+  //L是椭圆长度
+  getLR:function(R,L){
+    let d = L - R 
+    let r = (R - d) / 2
+    let h = r + d
+    return 2*Math.pow((R*R - h*h),0.5)
+  },
+
+  //返回数组中最大值的下标
+  maxIndex:function(arr){
+    let index = -1,max = arr[0];
+    for(let i = 0;i < arr.length; i++){
+      if(arr[i] >= max){
+        index = i;
+        max = arr[i];
+      }
+    }
+    if(arr[index] == 0){
+      return null;
+    }
+    return index;
   }
 }