index.vue 25 KB

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