|
@@ -32,10 +32,14 @@
|
|
|
<div class="game_status padding-tb">
|
|
|
<van-row>
|
|
|
<van-col span="10" offset="2">
|
|
|
- <div class="flex flex-direction align-center justify-center">
|
|
|
+ <div class="flex flex-direction align-center justify-center" v-if="device_ok == true">
|
|
|
<img src="https://img.shuimuai.com/web/touhuanzhuangtai_2.png" alt="" class="device_img">
|
|
|
<text class="text-default">已经正确佩戴</text>
|
|
|
</div>
|
|
|
+ <div class="flex flex-direction align-center justify-center" v-else>
|
|
|
+ <img src="https://img.shuimuai.com/web/touhuanzhuangtai_3.png" alt="" class="device_img">
|
|
|
+ <text class="text-default">未正确佩戴</text>
|
|
|
+ </div>
|
|
|
</van-col>
|
|
|
<van-col span="10">
|
|
|
<div class="flex flex-direction align-center justify-center">
|
|
@@ -210,17 +214,23 @@ export default {
|
|
|
play_time: 0,
|
|
|
|
|
|
//图标数据集合
|
|
|
- att_list: [0],
|
|
|
- med_list: [0],
|
|
|
+ att_list: [],
|
|
|
+ med_list: [],
|
|
|
delta_list: [],
|
|
|
alpha_list: [],
|
|
|
beta_list: [],
|
|
|
theta_list: [],
|
|
|
+ //临时数据集合
|
|
|
+ attList: [],
|
|
|
+ medList: [],
|
|
|
//判断是否结束游戏
|
|
|
is_end: false,
|
|
|
// 消耗的时间
|
|
|
played_time: 0,
|
|
|
- played_time_text: ""
|
|
|
+ played_time_text: "",
|
|
|
+
|
|
|
+ // 检测佩戴是否正确
|
|
|
+ device_ok: true
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
@@ -247,7 +257,7 @@ export default {
|
|
|
game_store.setters.removeToyHex()
|
|
|
//关闭游戏常亮
|
|
|
wx.setKeepScreenOn({
|
|
|
- keepScreenOn:false
|
|
|
+ keepScreenOn: false
|
|
|
})
|
|
|
//游戏结束传送一下数据
|
|
|
$this.post_data()
|
|
@@ -279,15 +289,25 @@ export default {
|
|
|
start_game() {
|
|
|
//设置屏幕常亮
|
|
|
wx.setKeepScreenOn({
|
|
|
- keepScreenOn:true
|
|
|
+ keepScreenOn: true
|
|
|
})
|
|
|
wx.onBLECharacteristicValueChange((characteristic) => {
|
|
|
console.log('监听蓝牙时间获取数据')
|
|
|
// console.log("收到" + $this.ab2hex(characteristic.value));
|
|
|
let hexStr = $this.ab2hex(characteristic.value)
|
|
|
let $data = bluetooth.get_big_data(hexStr)
|
|
|
+
|
|
|
+ //监听脑环是否带好
|
|
|
+ if (hexStr.substr(0, 6) == '555520') {
|
|
|
+ //当s1为 00时 数据有效
|
|
|
+ let $s1 = hexStr.substr(8, 2)
|
|
|
+ console.log("游戏中监听脑环是否带正:", $s1 == '00')
|
|
|
+ $this.device_ok = ($s1 == '00')
|
|
|
+ }
|
|
|
+
|
|
|
//连接玩具
|
|
|
if ($data) {
|
|
|
+ console.log($data)
|
|
|
$this.att_list.push($data['att'])
|
|
|
$this.med_list.push($data['med'])
|
|
|
$this.delta_list.push(Math.round($data['delta'] / 10000))
|
|
@@ -295,6 +315,20 @@ export default {
|
|
|
$this.theta_list.push(Math.round($data['theta'] / 10000))
|
|
|
$this.beta_list.push(Math.round($data['beta']) / 1000000)
|
|
|
|
|
|
+ if ($this.att_list.length > 50) {
|
|
|
+ $this.att_list.shift()
|
|
|
+ $this.med_list.shift()
|
|
|
+ $this.delta_list.shift()
|
|
|
+ $this.alpha_list.shift()
|
|
|
+ $this.theta_list.shift()
|
|
|
+ $this.beta_list.shift()
|
|
|
+ }
|
|
|
+ console.log("专注度列表:", $this.att_list)
|
|
|
+ console.log("放松度列表:", $this.med_list)
|
|
|
+
|
|
|
+ $this.attList.push($data['att'])
|
|
|
+ $this.medList.push($data['med'])
|
|
|
+
|
|
|
//通过专注放松度 画图
|
|
|
let $option = util.getLineOption($this.att_list, $this.med_list)
|
|
|
att_charts.setOption($option)
|
|
@@ -344,21 +378,18 @@ export default {
|
|
|
post_data() {
|
|
|
let $params = {
|
|
|
game_record_id: game_store.getters.getGameRecordId(),
|
|
|
- line: $this.att_list,
|
|
|
- line_med: $this.med_list
|
|
|
+ line: $this.attList,
|
|
|
+ line_med: $this.medList
|
|
|
}
|
|
|
+ console.log("提交的线图参数", $this.attList, $this.medList)
|
|
|
if (!$params.line && !$params.line_med) {
|
|
|
return false
|
|
|
}
|
|
|
gameAddLine($params).then((res) => {
|
|
|
let $data = res.data
|
|
|
if ($data.code == 0) {
|
|
|
- $this.att_list = []
|
|
|
- $this.med_list = []
|
|
|
- $this.delta_list = []
|
|
|
- $this.alpha_list = []
|
|
|
- $this.theta_list = []
|
|
|
- $this.beta_list = []
|
|
|
+ $this.attList = []
|
|
|
+ $this.medList = []
|
|
|
console.log('推送数据成功')
|
|
|
} else {
|
|
|
console.log('推送数据失败')
|
|
@@ -380,11 +411,15 @@ export default {
|
|
|
//设置未结束游戏
|
|
|
$this.is_end = false
|
|
|
})
|
|
|
+ },
|
|
|
+ // 处理游戏中数据的方法
|
|
|
+ do_datas($data) {
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
,
|
|
|
mounted() {
|
|
|
-
|
|
|
let $deviceId = $this._deviceId = game_store.getters.getDeviceId()
|
|
|
let $serviceId = $this._serviceId = game_store.getters.getServiceId()
|
|
|
let $cId = $this._characteristicId = game_store.getters.getCharacterId()
|