|
@@ -81,7 +81,9 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <mycharts ref="att" :canvasId="'demo'" :category="true" v-if="game_status == 1"></mycharts>
|
|
|
+ <view class="chart">
|
|
|
+ <mpvue-echarts :echarts="echarts" :onInit="attCharts" canvasId="canvasId-demo1"/>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
|
|
|
<view class="chart_view_second margin-tb-xl">
|
|
@@ -110,8 +112,9 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
-
|
|
|
- <mycharts ref="med" :canvasId="'demo1'" :category="false" v-if="game_status == 1"></mycharts>
|
|
|
+ <view class="chart">
|
|
|
+ <mpvue-echarts :echarts="echarts" :onInit="medCharts" canvasId="canvasId-demo2"/>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
|
|
|
</div>
|
|
@@ -128,18 +131,52 @@ import game_store from "@/store/game";
|
|
|
import Toast from '../../../static/vant/toast/toast';
|
|
|
import Dialog from '../../../static/vant/dialog/dialog';
|
|
|
import {gameAddLine, gameEnd} from "../../requests/game";
|
|
|
-import mycharts from "../../components/mycharts/mycharts";
|
|
|
+import mpvueEcharts from 'mpvue-echarts'
|
|
|
+import echarts from '../../../static/echarts.min';
|
|
|
|
|
|
+var att_charts,
|
|
|
+ med_charts,
|
|
|
+ $this
|
|
|
|
|
|
-var $this
|
|
|
+// 大脑图表初始化
|
|
|
+function initAttChart(canvas, width, height) {
|
|
|
+ att_charts = echarts.init(canvas, null, {
|
|
|
+ width: width,
|
|
|
+ height: height
|
|
|
+ });
|
|
|
+ canvas.setChart(att_charts);
|
|
|
+
|
|
|
+ let option = {}; // ECharts 配置项
|
|
|
+
|
|
|
+ att_charts.setOption(option);
|
|
|
+ return att_charts; // 返回 chart 后可以自动绑定触摸操作
|
|
|
+}
|
|
|
+
|
|
|
+// 我的设备图表初始化
|
|
|
+function initMedChart(canvas, width, height) {
|
|
|
+ med_charts = echarts.init(canvas, null, {
|
|
|
+ width: width,
|
|
|
+ height: height
|
|
|
+ });
|
|
|
+ canvas.setChart(med_charts);
|
|
|
+
|
|
|
+ let option = {}; // ECharts 配置项
|
|
|
+
|
|
|
+ med_charts.setOption(option);
|
|
|
+ return med_charts; // 返回 chart 后可以自动绑定触摸操作
|
|
|
+}
|
|
|
|
|
|
export default {
|
|
|
name: "index_container",
|
|
|
components: {
|
|
|
- mycharts
|
|
|
+ mpvueEcharts
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ // 折线图
|
|
|
+ echarts,
|
|
|
+ attCharts: initAttChart,
|
|
|
+ medCharts: initMedChart,
|
|
|
// 使用类型 1次数 2时间 0未选择
|
|
|
mode: 0,
|
|
|
|
|
@@ -187,7 +224,7 @@ export default {
|
|
|
methods: {
|
|
|
//游戏结束方法
|
|
|
game_finished() {
|
|
|
- bluetooth.shutdownSendControl($this._deviceId, $this._serviceId, $this._characteristicId)
|
|
|
+ bluetooth.sendEnd($this._deviceId, $this._serviceId, $this._characteristicId)
|
|
|
$this.$emit('closePop', true)
|
|
|
//取消监听低功耗蓝牙设备
|
|
|
wx.offBLECharacteristicValueChange()
|
|
@@ -195,6 +232,8 @@ export default {
|
|
|
game_store.setters.setGameStatus(3)
|
|
|
//游戏结束重置游戏时间
|
|
|
wx.removeStorageSync('play_time')
|
|
|
+ //删除游戏专注数据
|
|
|
+ game_store.remover.rmGameAttMedDatas()
|
|
|
//游戏结束重置游戏模式
|
|
|
game_store.setters.setMode(0)
|
|
|
//删除游戏得id
|
|
@@ -208,6 +247,9 @@ export default {
|
|
|
mask: true,
|
|
|
message: "正在生成报告...",
|
|
|
duration: 0,
|
|
|
+ onClose() {
|
|
|
+ bluetooth.shutdownSendControl($this._deviceId, $this._serviceId, $this._characteristicId)
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
to_report() {
|
|
@@ -224,6 +266,26 @@ export default {
|
|
|
wx.setKeepScreenOn({
|
|
|
keepScreenOn: true
|
|
|
})
|
|
|
+ //打开内存警告
|
|
|
+ // wx.onMemoryWarning(() => {
|
|
|
+ // console.log('内存告急警告')
|
|
|
+ // game_store.setGameAttMedDatas({
|
|
|
+ // att: $this.attList,
|
|
|
+ // med: $this.medList
|
|
|
+ // })
|
|
|
+ // })
|
|
|
+
|
|
|
+ // //初始化数据
|
|
|
+ // $this.played_time = null
|
|
|
+ // //设置未结束游戏
|
|
|
+ // $this.is_end = false
|
|
|
+ // $this.att_list = []
|
|
|
+ // $this.med_list = []
|
|
|
+ // $this.delta_list = []
|
|
|
+ // $this.alpha_list = []
|
|
|
+ // $this.theta_list = []
|
|
|
+ // $this.beta_list = []
|
|
|
+
|
|
|
bluetooth.watchingDevice($this)
|
|
|
bluetooth.sendControl($this._deviceId, $this._serviceId, $this._characteristicId)
|
|
|
},
|
|
@@ -303,7 +365,6 @@ export default {
|
|
|
type: $this.mode,
|
|
|
play_time: $this.play_time - Math.abs($this.played_time)
|
|
|
}
|
|
|
- console.log("结束游戏参数", $params)
|
|
|
//
|
|
|
gameEnd($params).then((res) => {
|
|
|
let $data = res.data
|
|
@@ -319,7 +380,7 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
// 处理游戏中数据的方法
|
|
|
- do_datas($data) {
|
|
|
+ do_datas: function ($data) {
|
|
|
$this.att_list.push($data['att'])
|
|
|
$this.med_list.push($data['med'])
|
|
|
$this.delta_list.push(Math.round($data['delta'] / 10000))
|
|
@@ -339,16 +400,21 @@ export default {
|
|
|
$this.attList.push($data['att'])
|
|
|
$this.medList.push($data['med'])
|
|
|
|
|
|
+ game_store.setters.setGameAttMedDatas({
|
|
|
+ attList: $this.attList,
|
|
|
+ medList: $this.medList
|
|
|
+ })
|
|
|
+
|
|
|
//判断是否隐藏 隐藏则不绘画
|
|
|
let $hide_status = game_store.getters.getHideStatus()
|
|
|
if (!$hide_status) {
|
|
|
//通过专注放松度 画图
|
|
|
let $option = util.getLineOption($this.att_list, $this.med_list)
|
|
|
- $this.$refs['att'].setAttOption($option)
|
|
|
+ att_charts.setOption($option)
|
|
|
|
|
|
//通过基本脑波发送数据
|
|
|
let $base_option = util.getBaseOption($this.delta_list, $this.theta_list, $this.alpha_list, $this.beta_list)
|
|
|
- $this.$refs['med'].setMedOption($base_option)
|
|
|
+ med_charts.setOption($base_option)
|
|
|
}
|
|
|
},
|
|
|
//计算游玩时间
|
|
@@ -442,7 +508,6 @@ export default {
|
|
|
console.log('小程序被销毁')
|
|
|
if (!$this.is_end) {
|
|
|
//停止传输数据
|
|
|
- bluetooth.sendPause($this._deviceId, $this._serviceId, $this._characteristicId)
|
|
|
bluetooth.sendEnd($this._deviceId, $this._serviceId, $this._characteristicId)
|
|
|
wx.offBLECharacteristicValueChange()
|
|
|
//存储时间
|
|
@@ -638,4 +703,12 @@ export default {
|
|
|
color: #fff;
|
|
|
line-height: 28px;
|
|
|
}
|
|
|
+
|
|
|
+.chart {
|
|
|
+ width: 360px;
|
|
|
+ height: 193px;
|
|
|
+ background: #302D43;
|
|
|
+ opacity: 0.6;
|
|
|
+ border-radius: 10px;
|
|
|
+}
|
|
|
</style>
|