|
@@ -8,7 +8,10 @@
|
|
|
<text class="title">已游玩时间</text>
|
|
|
</view>
|
|
|
<view class="text-lg padding-top">
|
|
|
- <van-count-down :time="mode_item.time" format="mm:ss" auto-start @finish="time_out"></van-count-down>
|
|
|
+ <van-count-down :time="mode_item.time" format="mm:ss" use-slot auto-start @finish="time_out"
|
|
|
+ @change="watch_time">
|
|
|
+ <text>{{ timeData.minutes }}:{{ timeData.seconds }}</text>
|
|
|
+ </van-count-down>
|
|
|
</view>
|
|
|
</van-col>
|
|
|
<van-col span="10" offset="4">
|
|
@@ -116,6 +119,8 @@
|
|
|
<button class="cu-btn lg bg-primary text-white" @click="game_finished">查看报告</button>
|
|
|
</div>
|
|
|
</van-popup>
|
|
|
+ <van-toast id="van-toast"/>
|
|
|
+
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -125,6 +130,8 @@ import echarts from '../../../static/echarts.min';
|
|
|
import util from '../../utils/index'
|
|
|
import bluetooth from "../../utils/bluetooth";
|
|
|
import game_store from "@/store/game";
|
|
|
+import Toast from '../../../static/vant/toast/toast';
|
|
|
+import {game_devices, gameAddLine} from "../../requests/game";
|
|
|
|
|
|
var att_charts,
|
|
|
med_charts,
|
|
@@ -183,6 +190,7 @@ export default {
|
|
|
err_title: "您的会员消费时间已用完",
|
|
|
}
|
|
|
],
|
|
|
+ timeData: {},
|
|
|
mode_item: {},
|
|
|
pop_show: false,
|
|
|
elc_power: 100,
|
|
@@ -195,6 +203,8 @@ export default {
|
|
|
_serviceId: "",
|
|
|
_characteristicId: "",
|
|
|
toy_index: 0,
|
|
|
+ toy_id: 0,
|
|
|
+ toy: {},
|
|
|
att_list: [],
|
|
|
med_list: [],
|
|
|
delta_list: [],
|
|
@@ -209,23 +219,24 @@ export default {
|
|
|
let $deviceId = game_store.getters.getDeviceId
|
|
|
let $serviceId = game_store.getters.getServiceId
|
|
|
let $charatorId = game_store.getters.getCharacterId
|
|
|
- console.log('delta_list',$this.delta_list)
|
|
|
- console.log('alpha_list',$this.alpha_list)
|
|
|
- console.log('beta_list',$this.beta_list)
|
|
|
- console.log('theta_list',$this.theta_list)
|
|
|
+ console.log('delta_list', $this.delta_list)
|
|
|
+ console.log('alpha_list', $this.alpha_list)
|
|
|
+ console.log('beta_list', $this.beta_list)
|
|
|
+ console.log('theta_list', $this.theta_list)
|
|
|
//停止控制游戏
|
|
|
bluetooth.sendEnd($deviceId, $serviceId, $charatorId)
|
|
|
//关闭脑环
|
|
|
- wx.closeBLEConnection({
|
|
|
- deviceId: $deviceId,
|
|
|
- success(res) {
|
|
|
- Toast.success('已成功断开')
|
|
|
- //设置游戏状态为 停止游戏
|
|
|
- game_store.commit('setGameStatus', 0)
|
|
|
- $this.to_report()
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
+ // wx.closeBLEConnection({
|
|
|
+ // deviceId: $deviceId,
|
|
|
+ // success(res) {
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ const countDown = $this.$mp.page.selectComponent('.control-count-down');
|
|
|
+ countDown.pause();
|
|
|
+ Toast.success('已成功断开')
|
|
|
+ //设置游戏状态为 停止游戏
|
|
|
+ game_store.commit('setGameStatus', 0)
|
|
|
+ $this.to_report()
|
|
|
},
|
|
|
// 关闭弹窗
|
|
|
close_pop() {
|
|
@@ -234,6 +245,7 @@ export default {
|
|
|
// 时间到
|
|
|
time_out() {
|
|
|
$this.pop_show = true
|
|
|
+ $this.game_finished()
|
|
|
},
|
|
|
to_report() {
|
|
|
mpvue.navigateTo({
|
|
@@ -279,7 +291,7 @@ export default {
|
|
|
game_store.commit('setServiceId', serviceId)
|
|
|
game_store.commit('setCid', item.uuid)
|
|
|
bluetooth.sendPause(deviceId, serviceId, item.uuid)
|
|
|
- bluetooth.sendConnect($this.toy_index, deviceId, serviceId, item.uuid)
|
|
|
+ bluetooth.sendConnect($this.toy, deviceId, serviceId, item.uuid)
|
|
|
}
|
|
|
|
|
|
if (item.properties.notify || item.properties.indicate) {
|
|
@@ -305,9 +317,9 @@ export default {
|
|
|
$this.att_list.push($data['att'])
|
|
|
$this.med_list.push($data['med'])
|
|
|
$this.delta_list.push(Math.round($data['delta'] / 10000))
|
|
|
- $this.alpha_list.push(Math.round($data['alpha'] / 10000))
|
|
|
+ $this.alpha_list.push(Math.round($data['alpha'] / 1000000))
|
|
|
$this.theta_list.push(Math.round($data['theta'] / 10000))
|
|
|
- $this.beta_list.push(Math.round($data['beta']) / 10000)
|
|
|
+ $this.beta_list.push(Math.round($data['beta']) / 1000000)
|
|
|
|
|
|
//通过专注放松度 画图
|
|
|
let $option = util.getLineOption($this.att_list, $this.med_list)
|
|
@@ -340,6 +352,30 @@ export default {
|
|
|
}
|
|
|
)
|
|
|
return hexArr.join('');
|
|
|
+ },
|
|
|
+
|
|
|
+ // 监听时间发生变动
|
|
|
+ watch_time(e) {
|
|
|
+ let $datetime = e.mp.detail
|
|
|
+ $this.timeData = $datetime
|
|
|
+ if ($datetime.seconds == '00') {
|
|
|
+ console.log('满一分钟')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 往后端推送一次定时数据
|
|
|
+ post_data() {
|
|
|
+ let $params = {
|
|
|
+ "game_record_id": 1,
|
|
|
+ "line": $this.att_list
|
|
|
+ }
|
|
|
+ gameAddLine($params).then((res) => {
|
|
|
+ let $data = res.data
|
|
|
+ if ($data.code == 0) {
|
|
|
+ console.log('推送数据成功')
|
|
|
+ } else {
|
|
|
+ console.log('推送数据失败')
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
,
|
|
@@ -352,19 +388,31 @@ export default {
|
|
|
$this = this;
|
|
|
},
|
|
|
onLoad($option) {
|
|
|
+ //获取用户游玩时间
|
|
|
$this.userinfo = wx.getStorageSync('userinfo')
|
|
|
$this.mode_list.forEach(($val, $index) => {
|
|
|
if ($val['id'] == 2) {
|
|
|
$val['time'] = parseInt($this.userinfo['play_time']) * 60 * 1000
|
|
|
}
|
|
|
})
|
|
|
- console.log($this.mode_list)
|
|
|
+ //筛选模式
|
|
|
$this.mode = $option.mode
|
|
|
$this.mode_list.forEach(($val, $index) => {
|
|
|
if ($option.mode == $val['id']) {
|
|
|
$this.mode_item = $val
|
|
|
}
|
|
|
})
|
|
|
+ // 筛选 玩具id
|
|
|
+ $this.toy_id = $option.toy_id
|
|
|
+ game_devices().then((res) => {
|
|
|
+ let $data = res.data
|
|
|
+ let $toylist = $data.data
|
|
|
+ $toylist.forEach(($val, $index) => {
|
|
|
+ if ($val['device_id'] == $this.toy_id) {
|
|
|
+ $this.toy = $val
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
</script>
|