index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937
  1. <template>
  2. <div id="playing_container">
  3. <!-- 计费面板模块-->
  4. <div class="game_panel padding-top-sm">
  5. <van-row gutter="16">
  6. <van-col span="8" offset="2">
  7. <view class="text-sm">
  8. <text class="title">本次游玩时间</text>
  9. </view>
  10. <view class="text-lg padding-top">
  11. <text class="count_down_text">{{ countdown_text }}</text>
  12. </view>
  13. </van-col>
  14. <van-col span="10" offset="4">
  15. <view class="text-sm">
  16. <text class="title">计费模式</text>
  17. <text v-if="mode===1" class="type padding-left-sm">次卡(10分钟)</text>
  18. <text v-else-if="mode===2" class="type padding-left-sm">会员时间消费</text>
  19. <text v-else class="type padding-left-sm">未选择</text>
  20. </view>
  21. <button class="cu-btn bg-red text-white margin-top-sm" @click="clickToEnd()" :disabled="end_loading">
  22. <img src="https://img.shuimuai.com/m_duankainaohuan.png" class="cut_brain_icon" alt=""/>
  23. <text class="padding-lr cut_text text-sm">结束训练</text>
  24. </button>
  25. </van-col>
  26. </van-row>
  27. </div>
  28. <!-- 设备状态-->
  29. <div class="game_status padding-tb">
  30. <van-row>
  31. <van-col span="8">
  32. <div class="flex flex-direction align-center justify-center" v-if="device_bg">
  33. <img src="https://img.shuimuai.com/web/touhuanzhuangtai_2.png" alt="" class="device_img"/>
  34. <text class="text-default">已经正确佩戴</text>
  35. </div>
  36. <div class="flex flex-direction align-center justify-center" v-else>
  37. <img src="https://img.shuimuai.com/web/touhuanzhuangtai_3.png" alt="" class="device_img"/>
  38. <text class="text-default">未正确佩戴</text>
  39. </div>
  40. </van-col>
  41. <van-col span="8">
  42. <div class="flex flex-direction align-center justify-center">
  43. <!-- <view class="elc_power_container">-->
  44. <!-- <img src="https://img.shuimuai.com/web/dianchi_3.png" alt="" :style="{ width: device_power + '%' }"-->
  45. <!-- class="device_elc"/>-->
  46. <!-- </view>-->
  47. <view class="elc_power_container">
  48. <view class="device_power" :style="{'background-size': device_power + '% 100%'}">
  49. <text v-if="is_dev" v-text="device_power+'%'"></text>
  50. </view>
  51. </view>
  52. <text class="text-default">脑机电量</text>
  53. </div>
  54. </van-col>
  55. <van-col span="8">
  56. <div class="flex flex-direction align-center justify-center">
  57. <!-- <view class="elc_power_container">-->
  58. <!-- <img src="https://img.shuimuai.com/web/dianchi_3.png" alt="" :style="{ width: toy_power + '%' }"-->
  59. <!-- class="device_elc"/>-->
  60. <!-- </view>-->
  61. <view class="elc_power_container">
  62. <view class="device_power" :style="{'background-size': toy_power + '% 100%'}">
  63. <text v-if="is_dev" v-text="toy_power+'%'"></text>
  64. </view>
  65. </view>
  66. <text class="text-default">教具电量</text>
  67. </div>
  68. </van-col>
  69. <van-col span="8">
  70. <div class="flex flex-direction align-center justify-center">
  71. <text style="color:white;">{{ RSSI }}dBm</text>
  72. <text class="text-default">脑机信号值</text>
  73. </div>
  74. </van-col>
  75. </van-row>
  76. </div>
  77. <!-- 环形实时数据 -->
  78. <div class="circle_container">
  79. <van-circle :value="online_att" layer-color="#49465E" color="#FFB400" stroke-width="7" :speed="0">
  80. <view class="circle_text">
  81. <text class="online_att_txt">{{ online_att }}</text>
  82. <view class="online_desc">{{ online_att_desc }}</view>
  83. </view>
  84. </van-circle>
  85. <van-circle :value="online_med" layer-color="#49465E" color="#40FF31" stroke-width="7" :speed="0">
  86. <view class="circle_text">
  87. <text class="online_med_txt">{{ online_med }}</text>
  88. <view class="online_desc">{{ online_med_desc }}</view>
  89. </view>
  90. </van-circle>
  91. </div>
  92. <!-- 图标模块-->
  93. <div class="ec_container">
  94. <view class="chart_view_first margin-tb-xl">
  95. <view class="bar">
  96. <view>
  97. <view class="line"></view>
  98. <view class="title">大脑状态</view>
  99. </view>
  100. <view class="label">
  101. <view>
  102. <view class="dot dot-orange"></view>
  103. <view class="name">Att(专注度)</view>
  104. </view>
  105. <view>
  106. <view class="dot dot-med"></view>
  107. <view class="name">Med(放松度)</view>
  108. </view>
  109. <view>
  110. <view class="dot dot-amp"></view>
  111. <view class="name">Amp (和谐度)</view>
  112. </view>
  113. </view>
  114. </view>
  115. <view class="chart">
  116. <mpvue-echarts
  117. :echarts="echarts"
  118. :onInit="attCharts"
  119. canvasId="canvasId-demo1"
  120. />
  121. </view>
  122. </view>
  123. <view class="chart_view_second margin-tb-xl">
  124. <view class="bar">
  125. <view>
  126. <view class="line"></view>
  127. <view class="title">基本脑波</view>
  128. </view>
  129. <view class="label">
  130. <van-row>
  131. <van-col span="8">
  132. <view>
  133. <view class="dot dot-delta"></view>
  134. <view class="name">Delta</view>
  135. </view>
  136. </van-col>
  137. <van-col span="8">
  138. <view>
  139. <view class="dot dot-theta"></view>
  140. <view class="name">Theta</view>
  141. </view>
  142. </van-col>
  143. <van-col span="8">
  144. <view>
  145. <view class="dot dot-low-beta"></view>
  146. <view class="name">Low_Beta</view>
  147. </view>
  148. </van-col>
  149. <van-col span="8">
  150. <view>
  151. <view class="dot dot-high-beta"></view>
  152. <view class="name">High_Beta</view>
  153. </view>
  154. </van-col>
  155. <van-col span="8">
  156. <view>
  157. <view class="dot dot-low-alpha"></view>
  158. <view class="name">Low_Alpha</view>
  159. </view>
  160. </van-col>
  161. <van-col span="8">
  162. <view>
  163. <view class="dot dot-high-alpah"></view>
  164. <view class="name">High_Alpha</view>
  165. </view>
  166. </van-col>
  167. </van-row>
  168. </view>
  169. </view>
  170. <view class="chart">
  171. <mpvue-echarts
  172. :echarts="echarts"
  173. :onInit="medCharts"
  174. canvasId="canvasId-demo2"
  175. />
  176. </view>
  177. </view>
  178. </div>
  179. <van-dialog id="van-dialog"/>
  180. <van-toast id="van-toast"/>
  181. <van-notify id="van-notify"/>
  182. </div>
  183. </template>
  184. <script>
  185. import ble_store from "@/store/bluetooth";
  186. import util from "../../../utils";
  187. import game_store from "@/store/game";
  188. import Toast from "../../../../static/vant/toast/toast";
  189. import {gameAddLine, gameEnd} from "../../../requests/game";
  190. import mpvueEcharts from "mpvue-echarts";
  191. import echarts from "../../../../static/echarts.min";
  192. import {formatPlaySeconds, get_big_data} from "../../../utils/game";
  193. import {LOG_DEBUG, LOG_WECHAT} from "../../../utils/log";
  194. let att_charts, med_charts, $this, $timeout;
  195. // 大脑图表初始化
  196. function initAttChart(canvas, width, height) {
  197. att_charts = echarts.init(canvas, null, {
  198. width: width,
  199. height: height,
  200. });
  201. canvas.setChart(att_charts);
  202. let option = {}; // ECharts 配置项
  203. att_charts.setOption(option);
  204. return att_charts; // 返回 chart 后可以自动绑定触摸操作
  205. }
  206. // 我的设备图表初始化
  207. function initMedChart(canvas, width, height) {
  208. med_charts = echarts.init(canvas, null, {
  209. width: width,
  210. height: height,
  211. });
  212. canvas.setChart(med_charts);
  213. let option = {}; // ECharts 配置项
  214. med_charts.setOption(option);
  215. return med_charts; // 返回 chart 后可以自动绑定触摸操作
  216. }
  217. export default {
  218. name: "StartGames",
  219. components: {
  220. mpvueEcharts,
  221. },
  222. created() {
  223. $this = this;
  224. },
  225. data() {
  226. return {
  227. // 折线图
  228. echarts,
  229. attCharts: initAttChart,
  230. medCharts: initMedChart,
  231. // 检测佩戴是否正确
  232. device_bg: true,
  233. // 脑机电量
  234. device_power: 0,
  235. // 教具电量
  236. toy_power: 0,
  237. // 蓝牙信号强度
  238. RSSI: 0,
  239. // 监听到的蓝牙数据
  240. hexStr: "",
  241. //实时的专注值和放松度
  242. online_att: 0,
  243. online_att_desc: "",
  244. online_med: 0,
  245. online_med_desc: "",
  246. //图标数据集合
  247. att_list: [],
  248. med_list: [],
  249. //和谐度
  250. amp_list: [],
  251. delta_list: [],
  252. theta_list: [],
  253. low_alphas: [],
  254. high_alphas: [],
  255. low_betas: [],
  256. high_betas: [],
  257. //保存的数据集合
  258. game_data: [],
  259. save_index: [
  260. "att",
  261. "med",
  262. "delta",
  263. "theta",
  264. "low_alpha",
  265. "high_alpha",
  266. "low_beta",
  267. "high_beta",
  268. "low_gamma",
  269. "middle_gamma",
  270. "delta_basic",
  271. "theta_basic",
  272. "low_alpha_basic",
  273. "high_alpha_basic",
  274. "low_beta_basic",
  275. "high_beta_basic",
  276. "low_gamma_basic",
  277. "middle_gamma_basic"
  278. ],
  279. // 计费模式: 1:次数 2:时间 0:未选择
  280. mode: 0,
  281. // 结束游戏loading
  282. end_loading: false,
  283. // 判断是否已经结束游戏
  284. is_end: false,
  285. // 该局总时间:30分钟或10分钟
  286. total_time: 0,
  287. // 该局游戏剩余可以游玩的时间
  288. play_time: 0,
  289. // 本次游玩时间倒计时
  290. countdown_text: "--:--",
  291. // 是否开发环境
  292. is_dev: false,
  293. };
  294. },
  295. onLoad(options) {
  296. if (options.end === 1) {
  297. $this.is_end = true;
  298. $this.executed = true
  299. }
  300. },
  301. mounted() {
  302. this.is_dev = process.env.NODE_ENV === "development";
  303. let game_status = game_store.getters.getGameStatus()*1;
  304. if (game_status === 1) {
  305. $this.is_end = false;
  306. $this.end_loading = false;
  307. $this.total_time = game_store.getters.getOverPlayTime();
  308. // 筛选模式
  309. $this.mode = game_store.getters.getMode() * 1;
  310. // 可玩时间 (剩余时长)
  311. $this.play_time = game_store.getters.getPlayTime();
  312. // 开始游戏
  313. $this.startTheGame();
  314. // 打开蓝牙监听
  315. $this.$connection.watchBLEstatus($this);
  316. }
  317. if (game_status === 3) {
  318. $this.endTheGame();
  319. }
  320. },
  321. // 加载完成后、后台切到前台或重新进入页面时触发
  322. onShow() {
  323. game_store.setters.setHideStatus(false);
  324. $this.countdown_text = "--:--";
  325. let game_status = game_store.getters.getGameStatus()*1;
  326. if (game_status === 2) {
  327. // 获取 拉到后台得时间
  328. let $hide_time = game_store.getters.getHideTime()*1;
  329. if ($hide_time) {
  330. let store_time = game_store.getters.getPlayedTime()*1;
  331. // 获取当前时间差
  332. let $now = Math.round(new Date() / 1000) - $hide_time;
  333. // 实际游玩时间
  334. let played_time = store_time + $now;
  335. if (played_time >= $this.total_time) {
  336. $this.endTheGame();
  337. } else {
  338. //重新设置游玩时间
  339. game_store.setters.setPlayedTime(played_time);
  340. // 可玩时间 (剩余时长)
  341. $this.play_time = $this.total_time - played_time;
  342. // 重新倒计时
  343. $this.countdownInterval($this.play_time);
  344. }
  345. }
  346. }
  347. },
  348. // // 页面从前台切换到后台或者去别的页面时候触发的
  349. // onHide() {
  350. // game_store.setters.setHideStatus(true);
  351. // let game_status = game_store.getters.getGameStatus()*1;
  352. // if (game_status === 2) {
  353. // // 存储时间
  354. // game_store.setters.setPlayedTime($this.total_time - $this.play_time);
  355. // // 四舍五入取整
  356. // game_store.setters.setHideTime(Math.round(new Date() / 1000));
  357. // clearInterval($timeout);
  358. // }
  359. // },
  360. // 页面卸载时候触发的生命周期
  361. onUnload() {
  362. LOG_DEBUG("训练页面被卸载!is_end:", $this.is_end, ",end_loading", $this.end_loading);
  363. if (!$this.is_end) {
  364. // 存储时间
  365. game_store.setters.setPlayedTime($this.total_time - $this.play_time);
  366. // 设置未结束游戏
  367. $this.is_end = false;
  368. $this.end_loading = false;
  369. }
  370. game_store.setters.setHideStatus(true);
  371. let game_status = game_store.getters.getGameStatus()*1;
  372. if (game_status === 2) {
  373. // 存储时间
  374. game_store.setters.setPlayedTime($this.total_time - $this.play_time);
  375. // 四舍五入取整
  376. game_store.setters.setHideTime(Math.round(new Date() / 1000));
  377. }
  378. // clearInterval($timeout);
  379. },
  380. methods: {
  381. /**
  382. * 实时分析游戏数据
  383. */
  384. analysisGameData: function (hexStr) {
  385. let $data = get_big_data(hexStr);
  386. this.onlineAttMed($data);
  387. this.doChartsData($data);
  388. },
  389. /**
  390. * 实时的专注值和放松度
  391. */
  392. onlineAttMed: function ($data) {
  393. $this.online_att = $data["att"];
  394. if ($this.online_att >= 1 && $this.online_att < 40) {
  395. $this.online_att_desc = "专注力不足";
  396. } else if ($this.online_att < 60) {
  397. $this.online_att_desc = "一般专注";
  398. } else if ($this.online_att < 80) {
  399. $this.online_att_desc = "高度专注";
  400. } else if ($this.online_att <= 100) {
  401. $this.online_att_desc = "深度专注";
  402. }
  403. $this.online_med = $data["med"];
  404. if ($this.online_med >= 1 && $this.online_med < 40) {
  405. $this.online_med_desc = "放松度不足";
  406. } else if ($this.online_med < 60) {
  407. $this.online_med_desc = "一般放松";
  408. } else if ($this.online_med < 80) {
  409. $this.online_med_desc = "高度放松";
  410. } else if ($this.online_med <= 100) {
  411. $this.online_med_desc = "深度放松";
  412. }
  413. },
  414. /**
  415. * 大脑状态数据 与 基本脑波数据
  416. */
  417. doChartsData: function ($data) {
  418. // 显示的数据
  419. $this.att_list.push($data["att"]);
  420. $this.med_list.push($data["med"]);
  421. $this.amp_list.push(100 - Math.abs($data["att"] - $data["med"]));
  422. $this.delta_list.push($data['delta']);
  423. $this.theta_list.push($data['theta']);
  424. $this.low_alphas.push($data['low_alpha']);
  425. $this.high_alphas.push($data['high_alpha']);
  426. $this.low_betas.push($data['low_beta']);
  427. $this.high_betas.push($data['high_beta']);
  428. game_store.setters.setGameDataLength($this.att_list.length);
  429. if ($this.att_list.length > 15) {
  430. // 图表显示数据过长时从第一个开始删除
  431. $this.att_list.shift();
  432. $this.med_list.shift();
  433. $this.amp_list.shift();
  434. $this.delta_list.shift();
  435. $this.theta_list.shift();
  436. $this.low_alphas.shift();
  437. $this.high_alphas.shift();
  438. $this.low_betas.shift();
  439. $this.high_betas.shift();
  440. }
  441. //判断是否隐藏 隐藏则不绘画
  442. let $hide_status = game_store.getters.getHideStatus();
  443. if (!$hide_status) {
  444. if (att_charts) {
  445. // 通过专注放松度 画图
  446. let $option = util.getLineOption($this.att_list, $this.med_list, $this.amp_list);
  447. att_charts.setOption($option);
  448. }
  449. if (med_charts) {
  450. // 通过基本脑波发送数据
  451. let $base_option = util.getBaseOption($this.delta_list, $this.theta_list, $this.low_alphas, $this.high_alphas, $this.low_betas, $this.high_betas);
  452. med_charts.setOption($base_option);
  453. }
  454. }
  455. // 保存的数据
  456. for (let i = 0; i < $this.save_index.length; i++) {
  457. if ($this.game_data[$this.save_index[i]] === undefined) {
  458. $this.game_data[$this.save_index[i]] = [];
  459. }
  460. $this.game_data[$this.save_index[i]].push($data[$this.save_index[i]])
  461. }
  462. },
  463. /**
  464. * 开始游戏
  465. */
  466. startTheGame() {
  467. LOG_DEBUG("开始游戏");
  468. game_store.setters.setGameStatus(2);
  469. game_store.setters.setGameDataLength(0);
  470. wx.setKeepScreenOn({
  471. keepScreenOn: true,
  472. });
  473. // 打开重连功能,自动发送RF重连教具
  474. $this.$connection.sendAutoConnectRf(true, Math.round($this.total_time / 60));
  475. $this.$connection.notifyDatas($this);
  476. setTimeout(() => {
  477. // 获取LED灯状态并设置
  478. let led_status = game_store.getters.getLED();
  479. LOG_DEBUG("开始游戏获取LED灯状态", led_status)
  480. if (led_status) {
  481. $this.$connection.SendLedOrder("01");
  482. } else {
  483. $this.$connection.SendLedOrder("00");
  484. }
  485. }, 500);
  486. setTimeout(() => {
  487. let $toy_sn = ble_store.getters.getToySn().toUpperCase();
  488. // 获取教具类型 发送陀螺仪开关指令
  489. if ($toy_sn.includes("SW") || $toy_sn.includes("KL") || $toy_sn.includes("SC")) {
  490. // 设置教具为无运动状态 AA CC 03 00 00 00 34 CKS
  491. $this.$connection.SendMotionOrder("01");
  492. } else {
  493. $this.$connection.SendMotionOrder("00");
  494. }
  495. }, 1000);
  496. // 开始倒计时
  497. $this.countdownInterval();
  498. },
  499. countdownInterval(){
  500. clearInterval($timeout);
  501. let count = 0;
  502. $timeout = setInterval(() => {
  503. //判断是否游戏中
  504. let game_status = game_store.getters.getGameStatus()*1;
  505. if (game_status === 2 && $this.play_time > 0) {
  506. // 自定义定时器
  507. $this.play_time -= 1;
  508. game_store.setters.setPlayedTime($this.total_time-$this.play_time);
  509. $this.countdown_text = formatPlaySeconds($this.play_time);
  510. console.log("%c游戏倒计时", "color:red;", $this.countdown_text);
  511. count += 1;
  512. if( count % 10 === 0) {
  513. // 每10秒获取手机蓝牙状态
  514. $this.getBleAdapterState();
  515. }
  516. } else {
  517. clearInterval($timeout);
  518. $this.endTheGame();
  519. }
  520. }, 1000);
  521. },
  522. getBleAdapterState(){
  523. // 获取本机蓝牙适配器状态
  524. wx.getBluetoothAdapterState({
  525. complete: function (res) {
  526. LOG_DEBUG("游戏中,获取手机蓝牙状态:", JSON.stringify(res));
  527. if (!res.available) {
  528. clearInterval($timeout);
  529. $this.endTheGame();
  530. }
  531. }
  532. });
  533. },
  534. /**
  535. * 点击结束游戏按钮
  536. */
  537. clickToEnd() {
  538. if (!$this.end_loading && !$this.is_end) {
  539. $this.endTheGame();
  540. }
  541. },
  542. /**
  543. * 游戏结束
  544. */
  545. endTheGame() {
  546. if($this.end_loading || $this.is_end){
  547. return;
  548. }
  549. $this.end_loading = true;
  550. $this.is_end = true;
  551. clearInterval($timeout);
  552. game_store.setters.setGameStatus(3);
  553. LOG_DEBUG("正在结束游戏->endTheGame()");
  554. // 关闭脑控
  555. $this.$connection.sendControlClose();
  556. // 结束游戏提交数据
  557. $this.postGameData();
  558. let $code = ble_store.getters.getDeviceSn();
  559. LOG_WECHAT($code, "结束训练record_id:", game_store.getters.getGameRecordId());
  560. },
  561. /**
  562. * 往后端推送一次数据
  563. */
  564. postGameData() {
  565. let post_data = [];
  566. for (let i = 0; i < $this.save_index.length; i++) {
  567. post_data[$this.save_index[i]] = $this.game_data[$this.save_index[i]]?$this.game_data[$this.save_index[i]].join(','):"";
  568. }
  569. //判断数据长度大于理想状态 需要对数组进行切割 逐个提交数据
  570. let $dataParams = {
  571. game_record_id: game_store.getters.getGameRecordId(),
  572. //数据段长度小于65 单个提交
  573. line: $this.game_data['att']?$this.game_data['att'].join(','):"",
  574. line_med: $this.game_data['med']?$this.game_data['med'].join(','):"",
  575. ...post_data,
  576. sn: ble_store.getters.getDeviceSn()
  577. };
  578. if ($dataParams.line) {
  579. gameAddLine($dataParams).then((res) => {
  580. let $data = res.data;
  581. if ($data.code*1 === 0) {
  582. $this.game_data = [];
  583. }
  584. });
  585. }
  586. let $params = {
  587. game_record_id: game_store.getters.getGameRecordId(),
  588. type: $this.mode,
  589. play_time: $this.total_time - Math.abs($this.play_time),
  590. };
  591. gameEnd($params).then(() => {
  592. $this.resetGameData();
  593. });
  594. // 跳转到报告页
  595. $this.toReportPage();
  596. },
  597. /**
  598. * 重置游戏数据
  599. */
  600. resetGameData(){
  601. //游戏结束重置游戏时间
  602. wx.removeStorageSync("play_time");
  603. //删除隐藏时间
  604. game_store.remover.rmHideTime();
  605. //游戏结束重置游戏模式
  606. game_store.setters.setMode(0);
  607. //设置游戏状态为 停止游戏
  608. let game_status = game_store.getters.getGameStatus() * 1;
  609. if (game_status === 1 || game_status === 2) {
  610. game_store.setters.setGameStatus(3);
  611. }
  612. // 重置状态
  613. $this.is_end = false;
  614. $this.end_loading = false;
  615. $this.att_list = [];
  616. $this.med_list = [];
  617. $this.amp_list = [];
  618. $this.delta_list = [];
  619. $this.theta_list = [];
  620. $this.low_alphas = [];
  621. $this.high_alphas = [];
  622. $this.low_betas = [];
  623. $this.high_betas = [];
  624. //游戏结束重置游戏卡卷类型时间和卡卷类型
  625. $this.play_time = game_store.getters.getPlayTime();
  626. game_store.setters.setPlayedTime(0);
  627. game_store.setters.setOverPlayTime(0);
  628. game_store.setters.setMode(0);
  629. $this.countdown_text = "--:--";
  630. },
  631. /**
  632. * 跳转到报告页
  633. */
  634. toReportPage() {
  635. let report_url = "/pages/games/report/main?id=" + game_store.getters.getGameRecordId() + "&size=" + game_store.getters.getGameDataLength();
  636. console.log(report_url);
  637. Toast.loading({
  638. forbidClick: true,
  639. mask: true,
  640. message: "正在生成报告...",
  641. duration: 2000,
  642. onClose() {
  643. mpvue.redirectTo({
  644. url: report_url,
  645. success() {
  646. $this.attList = [];
  647. $this.medList = [];
  648. $this.ampList = [];
  649. LOG_DEBUG("生成报告成功")
  650. },
  651. });
  652. $this.end_loading = false;
  653. }
  654. });
  655. },
  656. },
  657. };
  658. </script>
  659. <style scoped>
  660. #playing_container {
  661. width: 100%;
  662. background: #46425e linear-gradient(
  663. 0deg,
  664. rgba(40, 157, 206, 0.51),
  665. rgba(135, 145, 226, 0.26)
  666. );
  667. padding: 5px;
  668. height: 850px;
  669. }
  670. .game_panel {
  671. width: 100%;
  672. height: 76px;
  673. background: #46425e;
  674. box-shadow: 0px 3px 4px 0px #302d43;
  675. border-radius: 11px;
  676. margin: 0px auto;
  677. }
  678. .game_panel .title {
  679. color: #9a96b7;
  680. }
  681. .game_panel .type {
  682. color: #ffffff;
  683. }
  684. .cut_brain_icon {
  685. width: 11px;
  686. height: 11px;
  687. }
  688. .device_img {
  689. width: 36px;
  690. height: 36px;
  691. }
  692. .text-default {
  693. color: #9a95b7;
  694. font-size: 10px;
  695. }
  696. /*电量显示*/
  697. .elc_power_container {
  698. width: 28px;
  699. border: #9a95b7 3px solid;
  700. border-radius: 5px;
  701. height: 22px;
  702. }
  703. .device_power{
  704. width: 100%;
  705. height: 100%;
  706. background-image: url(https://img.shuimuai.com/web/dianchi_3.png);
  707. background-repeat: no-repeat;
  708. background-size: 0 100%;
  709. text-align: center;
  710. font-size: 12px;
  711. color: #fff;
  712. }
  713. .device_elc {
  714. height: 18px;
  715. }
  716. /* 节标题 */
  717. .bar {
  718. width: 100%;
  719. height: 15px;
  720. display: flex;
  721. align-items: center;
  722. justify-content: space-between;
  723. padding: 0 7px;
  724. box-sizing: border-box;
  725. margin: 11px 0;
  726. }
  727. .bar view {
  728. display: flex;
  729. align-items: center;
  730. justify-content: start;
  731. }
  732. .bar .line {
  733. width: 4px;
  734. height: 15px;
  735. background-color: #ffb400;
  736. margin-right: 7px;
  737. }
  738. .bar .title {
  739. color: #fff;
  740. font-size: 15px;
  741. }
  742. .label {
  743. width: 250px;
  744. color: #9a95b7;
  745. font-size: 10px;
  746. }
  747. /*点图*/
  748. .dot {
  749. width: 8px;
  750. height: 8px;
  751. border-radius: 50%;
  752. margin-right: 4px;
  753. margin-left: 15px;
  754. }
  755. .dot-orange {
  756. background: #ffb400;
  757. }
  758. .dot-pink {
  759. background: #d4327a;
  760. }
  761. .dot-blue {
  762. background: #00ccff;
  763. }
  764. .dot-green {
  765. background: #0cda2e;
  766. }
  767. .dot-yellow {
  768. background: #d1d310;
  769. }
  770. .dot-orange-yellow {
  771. background: #f8a117;
  772. }
  773. /* 图表 */
  774. #mychart-dom-multi-line {
  775. width: 100%;
  776. height: 175px;
  777. }
  778. #mychart-dom-multi-line-med {
  779. width: 100%;
  780. height: 100px;
  781. }
  782. /*弹窗模块*/
  783. .err_container {
  784. width: 260px;
  785. height: 300px;
  786. border-radius: 5px;
  787. }
  788. /*标题*/
  789. .err_container .title {
  790. font-size: 20px;
  791. font-weight: bold;
  792. color: #4c4c4c;
  793. line-height: 24px;
  794. }
  795. /*子标题*/
  796. .err_container .sub-title {
  797. font-size: 12px;
  798. font-family: Microsoft YaHei;
  799. font-weight: 400;
  800. color: #4b4b4b;
  801. line-height: 24px;
  802. }
  803. .err_img {
  804. width: 73px;
  805. height: 83px;
  806. }
  807. .chart_view_first {
  808. position: relative;
  809. bottom: 10px;
  810. }
  811. .chart_view_second {
  812. position: relative;
  813. bottom: 5px;
  814. }
  815. /*倒计时样式*/
  816. .count_down_text {
  817. font-size: 35px;
  818. font-family: PingFang SC;
  819. font-weight: 400;
  820. color: #fff;
  821. line-height: 28px;
  822. }
  823. .chart {
  824. width: 360px;
  825. height: 193px;
  826. background: #302d43;
  827. opacity: 0.6;
  828. border-radius: 10px;
  829. }
  830. /* 提高dialog提示的层级 */
  831. #van-dialog {
  832. z-index: 10000001 !important;
  833. }
  834. .dot-amp {
  835. background: #D4327A;
  836. }
  837. .dot-med {
  838. background: #40FF31;
  839. }
  840. .circle_container {
  841. width: 100%;
  842. height: 150px;
  843. background: #302D43;
  844. opacity: 0.6;
  845. border-radius: 20px;
  846. display: flex;
  847. justify-content: space-around;
  848. align-items: center;
  849. }
  850. .circle_text {
  851. width: 100%;
  852. }
  853. .online_att_txt {
  854. font-size: 40px;
  855. font-family: Arial, serif;
  856. font-weight: bold;
  857. color: #FAB615;
  858. }
  859. .online_med_txt {
  860. font-size: 40px;
  861. font-family: Arial, serif;
  862. font-weight: bold;
  863. color: #40FF31;
  864. }
  865. .online_desc {
  866. font-size: 12px;
  867. font-weight: 400;
  868. color: #FFFFFF;
  869. }
  870. .dot-delta {
  871. background-color: #FF77B3;
  872. }
  873. .dot-theta {
  874. background-color: #FFE838;
  875. }
  876. .dot-low-beta {
  877. background-color: #0060F1;
  878. }
  879. .dot-high-beta {
  880. background-color: #00CCFF;
  881. }
  882. .dot-low-alpha {
  883. background-color: #38FF49;
  884. }
  885. .dot-high-alpah {
  886. background-color: #00AD0E;
  887. }
  888. </style>