|
@@ -1,34 +1,58 @@
|
|
// components/map-sense.js
|
|
// 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 = {
|
|
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({
|
|
Component({
|
|
/**
|
|
/**
|
|
* 组件的属性列表
|
|
* 组件的属性列表
|
|
*/
|
|
*/
|
|
- properties: {},
|
|
|
|
|
|
+ properties: {
|
|
|
|
+ },
|
|
|
|
|
|
/**
|
|
/**
|
|
* 组件的初始数据
|
|
* 组件的初始数据
|
|
@@ -44,7 +68,8 @@ Component({
|
|
api_base_url: API_BASE_URL,
|
|
api_base_url: API_BASE_URL,
|
|
// 是否是扫码播放
|
|
// 是否是扫码播放
|
|
isScanPlay: false,
|
|
isScanPlay: false,
|
|
- cdn_url: CDN_URL,
|
|
|
|
|
|
+ cdn_url:CDN_URL,
|
|
|
|
+ classfiy:{}
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -52,196 +77,283 @@ Component({
|
|
*/
|
|
*/
|
|
methods: {
|
|
methods: {
|
|
openBluetooth(cb) {
|
|
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() {
|
|
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() {
|
|
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() {
|
|
toScanCode() {
|
|
- this.setData({
|
|
|
|
- isScanPlay: true,
|
|
|
|
- });
|
|
|
|
|
|
+ var that = this;
|
|
|
|
+ that.setData({
|
|
|
|
+ isScanPlay: true
|
|
|
|
+ })
|
|
wx.scanCode({
|
|
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() {
|
|
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 () {
|
|
attached: function () {
|
|
innerAudioContext.stop();
|
|
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 () {
|
|
detached: function () {
|
|
innerAudioContext.stop();
|
|
innerAudioContext.stop();
|
|
innerAudioContext.destroy();
|
|
innerAudioContext.destroy();
|
|
- wx.stopBeaconDiscovery({});
|
|
|
|
- this.setData({ status: "0" });
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
-});
|
|
|
|
|
|
+ wx.stopBeaconDiscovery({})
|
|
|
|
+ this.setData({status:"0"})
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+})
|