|
@@ -11,8 +11,7 @@
|
|
|
<van-count-down :time="mode_item.time" format="mm:ss" use-slot auto-start @finish="time_out"
|
|
|
@change="watch_time" class="control-count-down"
|
|
|
>
|
|
|
- <text v-if="mode == 1">{{ timeData.minutes }}:{{ timeData.seconds }}</text>
|
|
|
- <text v-if="mode == 2">{{ played_time_text }}</text>
|
|
|
+ <text>{{ timeData.minutes }}:{{ timeData.seconds }}</text>
|
|
|
</van-count-down>
|
|
|
</view>
|
|
|
</van-col>
|
|
@@ -55,53 +54,61 @@
|
|
|
|
|
|
<!-- 图标模块-->
|
|
|
<div class="ec_container">
|
|
|
- <view class="bar">
|
|
|
- <view>
|
|
|
- <view class="line"></view>
|
|
|
- <view class="title">大脑状态</view>
|
|
|
- </view>
|
|
|
- <view class="label">
|
|
|
+ <view class="chart_view_first margin-tb-xl">
|
|
|
+
|
|
|
+ <view class="bar">
|
|
|
<view>
|
|
|
- <view class="dot dot-orange"></view>
|
|
|
- <view class="name">Att(专注度)</view>
|
|
|
+ <view class="line"></view>
|
|
|
+ <view class="title">大脑状态</view>
|
|
|
</view>
|
|
|
- <view>
|
|
|
- <view class="dot dot-pink"></view>
|
|
|
- <view class="name">Att(放松度)</view>
|
|
|
+ <view class="label">
|
|
|
+ <view>
|
|
|
+ <view class="dot dot-orange"></view>
|
|
|
+ <view class="name">Att(专注度)</view>
|
|
|
+ </view>
|
|
|
+ <view>
|
|
|
+ <view class="dot dot-pink"></view>
|
|
|
+ <view class="name">Med(放松度)</view>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</view>
|
|
|
+ <view class="chart">
|
|
|
+ <mpvue-echarts :echarts="echarts" :onInit="attCharts" canvasId="demo-canvas"/>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
- <view class="chart">
|
|
|
- <mpvue-echarts :echarts="echarts" :onInit="attCharts" canvasId="demo-canvas"/>
|
|
|
|
|
|
- </view>
|
|
|
- <view class="bar">
|
|
|
- <view>
|
|
|
- <view class="line"></view>
|
|
|
- <view class="title">基本脑波</view>
|
|
|
- </view>
|
|
|
- <view class="label">
|
|
|
- <view>
|
|
|
- <view class="dot dot-blue"></view>
|
|
|
- <view class="name">Delta</view>
|
|
|
- </view>
|
|
|
+ <view class="chart_view_second margin-tb-xl">
|
|
|
+
|
|
|
+ <view class="bar">
|
|
|
<view>
|
|
|
- <view class="dot dot-green"></view>
|
|
|
- <view class="name">Theta</view>
|
|
|
+ <view class="line"></view>
|
|
|
+ <view class="title">基本脑波</view>
|
|
|
</view>
|
|
|
- <view>
|
|
|
- <view class="dot dot-yellow"></view>
|
|
|
- <view class="name">Beta</view>
|
|
|
- </view>
|
|
|
- <view>
|
|
|
- <view class="dot dot-orange-yellow"></view>
|
|
|
- <view class="name">Alpha</view>
|
|
|
+ <view class="label">
|
|
|
+ <view>
|
|
|
+ <view class="dot dot-blue"></view>
|
|
|
+ <view class="name">Delta</view>
|
|
|
+ </view>
|
|
|
+ <view>
|
|
|
+ <view class="dot dot-green"></view>
|
|
|
+ <view class="name">Theta</view>
|
|
|
+ </view>
|
|
|
+ <view>
|
|
|
+ <view class="dot dot-yellow"></view>
|
|
|
+ <view class="name">Beta</view>
|
|
|
+ </view>
|
|
|
+ <view>
|
|
|
+ <view class="dot dot-orange-yellow"></view>
|
|
|
+ <view class="name">Alpha</view>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</view>
|
|
|
+
|
|
|
+ <view class="chart">
|
|
|
+ <mpvue-echarts :echarts="echarts" :onInit="medCharts" canvasId="demo-canvas-1"/>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
- <view class="chart">
|
|
|
- <mpvue-echarts :echarts="echarts" :onInit="medCharts" canvasId="demo-canvas-1"/>
|
|
|
- </view>
|
|
|
+
|
|
|
</div>
|
|
|
|
|
|
<!-- 窗口弹出-->
|
|
@@ -184,7 +191,7 @@ export default {
|
|
|
{
|
|
|
id: 2,
|
|
|
name: "会员时间消费",
|
|
|
- time: 20 * 60 * 1000,
|
|
|
+ time: 30 * 60 * 1000,
|
|
|
err_title: "本次游玩时间已用完"
|
|
|
},
|
|
|
{
|
|
@@ -244,9 +251,11 @@ export default {
|
|
|
wx.offBLECharacteristicValueChange()
|
|
|
Toast.success('已成功断开')
|
|
|
//设置游戏状态为 停止游戏
|
|
|
- game_store.commit('setGameStatus', 3)
|
|
|
+ game_store.setters.setGameStatus(3)
|
|
|
//游戏结束重置游戏时间
|
|
|
- game_store.commit('setPlayTime', 0)
|
|
|
+ game_store.setters.setPlayTime(0)
|
|
|
+ //游戏结束重置游戏模式
|
|
|
+ game_store.setters.setMode(0)
|
|
|
//游戏结束传送一下数据
|
|
|
$this.post_data()
|
|
|
$this.game_over()
|
|
@@ -266,73 +275,6 @@ export default {
|
|
|
url: "/pages/report/main"
|
|
|
})
|
|
|
},
|
|
|
- //获取蓝牙设备服务
|
|
|
- getBLEDeviceServices(deviceId) {
|
|
|
- console.log('获取蓝牙设备服务', deviceId)
|
|
|
- wx.getBLEDeviceServices({
|
|
|
- deviceId,
|
|
|
- success: (res) => {
|
|
|
- console.log('获取蓝牙设备服务成功')
|
|
|
- for (let i = 0; i < res.services.length; i++) {
|
|
|
- if (res.services[i].isPrimary) {
|
|
|
- this.getBLEDeviceCharacteristics(deviceId, res.services[i].uuid)
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- fail(res) {
|
|
|
-
|
|
|
- console.log('获取蓝牙设备失败', res)
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- //获取蓝牙设备某个服务中所有特征值
|
|
|
- getBLEDeviceCharacteristics(deviceId, serviceId) {
|
|
|
- console.log('获取蓝牙设备某个服务中所有特征值')
|
|
|
- wx.getBLEDeviceCharacteristics({
|
|
|
- deviceId,
|
|
|
- serviceId,
|
|
|
- success: (res) => {
|
|
|
- console.log('getBLEDeviceCharacteristics success', res.characteristics)
|
|
|
- for (let i = 0; i < res.characteristics.length; i++) {
|
|
|
- let item = res.characteristics[i]
|
|
|
- if (item.properties.read) {
|
|
|
- wx.readBLECharacteristicValue({
|
|
|
- deviceId,
|
|
|
- serviceId,
|
|
|
- characteristicId: item.uuid,
|
|
|
- })
|
|
|
- }
|
|
|
- if (item.properties.write) {
|
|
|
- $this._deviceId = deviceId
|
|
|
- $this._serviceId = serviceId
|
|
|
- $this._characteristicId = item.uuid
|
|
|
- game_store.commit('setDeviceId', deviceId)
|
|
|
- game_store.commit('setServiceId', serviceId)
|
|
|
- game_store.commit('setCid', item.uuid)
|
|
|
- bluetooth.sendPause(deviceId, serviceId, item.uuid)
|
|
|
- //获取玩具的值
|
|
|
- // bluetooth.sendConnect($this.toy_hex, deviceId, serviceId, item.uuid, Toast)
|
|
|
- }
|
|
|
-
|
|
|
- if (item.properties.notify || item.properties.indicate) {
|
|
|
- wx.notifyBLECharacteristicValueChange({
|
|
|
- deviceId,
|
|
|
- serviceId,
|
|
|
- characteristicId: item.uuid,
|
|
|
- state: true,
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- fail(res) {
|
|
|
- console.error('getBLEDeviceCharacteristics', res)
|
|
|
- }
|
|
|
- })
|
|
|
- // 操作之前先监听,保证第一时间获取数据
|
|
|
- $this.start_game()
|
|
|
- },
|
|
|
-
|
|
|
start_game() {
|
|
|
wx.onBLECharacteristicValueChange((characteristic) => {
|
|
|
console.log('监听蓝牙时间获取数据')
|
|
@@ -362,7 +304,6 @@ export default {
|
|
|
$this.elc_power = $power
|
|
|
}
|
|
|
bluetooth.sendControl($this._deviceId, $this._serviceId, $this._characteristicId)
|
|
|
-
|
|
|
})
|
|
|
|
|
|
},
|
|
@@ -381,6 +322,9 @@ export default {
|
|
|
// 监听时间发生变动
|
|
|
watch_time(e) {
|
|
|
let $datetime = e.mp.detail
|
|
|
+ if ($datetime.seconds.length == 1) {
|
|
|
+ $datetime.seconds = '0' + $datetime.seconds
|
|
|
+ }
|
|
|
$this.timeData = $datetime
|
|
|
$this.played_time += 1
|
|
|
console.log("玩了:" + $this.played_time + "秒")
|
|
@@ -395,7 +339,7 @@ export default {
|
|
|
// 往后端推送一次定时数据
|
|
|
post_data() {
|
|
|
let $params = {
|
|
|
- game_record_id: game_store.getters.getGameRecordId,
|
|
|
+ game_record_id: game_store.getters.getGameRecordId(),
|
|
|
line: $this.att_list,
|
|
|
line_med: $this.med_list
|
|
|
}
|
|
@@ -426,7 +370,7 @@ export default {
|
|
|
// $play_time = $userinfo['play_time'] * 60 - $current_time
|
|
|
// }
|
|
|
let $params = {
|
|
|
- game_record_id: game_store.getters.getGameRecordId,
|
|
|
+ game_record_id: game_store.getters.getGameRecordId(),
|
|
|
type: $this.mode,
|
|
|
play_time: $this.played_time
|
|
|
}
|
|
@@ -442,26 +386,29 @@ export default {
|
|
|
}
|
|
|
,
|
|
|
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()
|
|
|
+ console.log("游戏开始:", $deviceId, $serviceId, $cId)
|
|
|
+
|
|
|
//判断是否结束游戏
|
|
|
if ($this.is_end == true) {
|
|
|
$this.game_finished()
|
|
|
} else {
|
|
|
- $this._deviceId = game_store.getters.getDeviceId
|
|
|
- console.log("游戏开始:当前device_id", $this._deviceId)
|
|
|
- $this.getBLEDeviceServices($this._deviceId)
|
|
|
-
|
|
|
+ $this.start_game()
|
|
|
// 筛选 玩具id
|
|
|
- $this.toy_hex = game_store.getters.getToyHex
|
|
|
+ $this.toy_hex = game_store.getters.getToyHex()
|
|
|
// bluetooth.sendConnect($this.toy_hex, $this._deviceId, $this._serviceId, $this._characteristicId)
|
|
|
|
|
|
//筛选模式
|
|
|
- $this.mode = game_store.getters.getMode
|
|
|
+ $this.mode = game_store.getters.getMode()
|
|
|
|
|
|
//获取用户游玩时间
|
|
|
- let $play_time = $this.play_time = game_store.getters.getPlayTime
|
|
|
+ let $play_time = $this.play_time = game_store.getters.getPlayTime()
|
|
|
$this.mode_list.forEach(($val, $index) => {
|
|
|
$val['time'] = $play_time * 1000
|
|
|
- if ($val['id'] == $this.mode) {
|
|
|
+ if ($val['id'] == $this.mode && $val['id'] == 1) {
|
|
|
$this.mode_item = $val
|
|
|
}
|
|
|
})
|
|
@@ -489,7 +436,7 @@ export default {
|
|
|
wx.offBLECharacteristicValueChange()
|
|
|
//存储时间
|
|
|
let $play_time = $this.timeData.minutes * 60 + $this.timeData.seconds
|
|
|
- game_store.commit('setPlayTime', $play_time)
|
|
|
+ game_store.setters.setPlayTime($play_time)
|
|
|
this.pop_show = false
|
|
|
//设置未结束游戏
|
|
|
$this.is_end = false
|
|
@@ -511,6 +458,7 @@ export default {
|
|
|
background: linear-gradient(0deg, rgba(40, 157, 206, 0.51), rgba(135, 145, 226, 0.26));
|
|
|
background-color: #46425E;
|
|
|
padding: 5px;
|
|
|
+ height: 750px;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -679,4 +627,14 @@ export default {
|
|
|
width: 73px;
|
|
|
height: 83px;
|
|
|
}
|
|
|
+
|
|
|
+.chart_view_first {
|
|
|
+ position: relative;
|
|
|
+ bottom: 10px;
|
|
|
+}
|
|
|
+
|
|
|
+.chart_view_second {
|
|
|
+ position: relative;
|
|
|
+ bottom: 5px;
|
|
|
+}
|
|
|
</style>
|