Fury před 3 roky
rodič
revize
8043aeb224

+ 57 - 65
src/components/device/device.vue

@@ -23,10 +23,7 @@
         </div>
 
         <!-- 已链接 -->
-        <div
-          class="connected_box"
-          v-if="connect_show"
-        >
+        <div class="connected_box" v-if="connect_show">
           <device_connected
             @open_choose_toy="open_choose_toy"
             @change_brain_status="change_device_status"
@@ -74,10 +71,7 @@
       </div>
       <!-- 内容 -->
       <div class="padding toy_list">
-        <van-row
-          gutter="14"
-          class="toy_list_content"
-        >
+        <van-row gutter="14" class="toy_list_content">
           <van-col
             v-for="(toy, index) in toy_list"
             :key="index"
@@ -92,11 +86,7 @@
                   : 'toy_item_normal_bg'
               "
             >
-              <img
-                :src="toy.img"
-                alt=""
-                class="toy_img"
-              />
+              <img :src="toy.img" alt="" class="toy_img" />
               <text class="toy_text padding-top">{{ toy.name }}</text>
             </div>
           </van-col>
@@ -104,7 +94,8 @@
       </div>
       <!-- 结尾 -->
       <div class="toy_actions padding text-center">
-        <view class="text-gray toy_action_text padding">选择你最感兴趣的项目,点击“选好了”以后将会自动连接
+        <view class="text-gray toy_action_text padding"
+          >选择你最感兴趣的项目,点击“选好了”以后将会自动连接
         </view>
         <button
           class="cu-btn lg cu-btn-primary text-white text-center padding"
@@ -114,9 +105,8 @@
         </button>
       </div>
     </van-popup>
-    <van-toast id="van-toast"/>
-    <van-dialog id="van-dialog"/>
-
+    <van-toast id="van-toast" />
+    <van-dialog id="van-dialog" />
   </div>
 </template>
 
@@ -133,9 +123,9 @@ import toy_connecting from "@/components/device/toy/connecting";
 import gameIng from "@/pages/start/index";
 //获取个人信息
 import Toast from "../../../static/vant/toast/toast";
-import {game_devices, getDeviceBySn} from "../../requests/game";
+import { game_devices, getDeviceBySn } from "../../requests/game";
 import game_store from "@/store/game";
-import {getNowDate} from "../../utils";
+import { getNowDate } from "../../utils";
 
 let $this;
 export default {
@@ -236,12 +226,12 @@ export default {
     scan_to_bluetooth() {
       wx.scanCode({
         onlyFromCamera: true,
-        scanType: ['barCode', 'qrCode'],
+        scanType: ["barCode", "qrCode"],
         success: (res) => {
           let $data = res;
           if ($data.result) {
             let url = decodeURIComponent($data.result);
-            let $code = ""
+            let $code = "";
 
             //二维码
             if (res.scanType == "QR_CODE") {
@@ -255,21 +245,21 @@ export default {
             }
 
             // 判断新的标识值
-            $this.code = $code
+            $this.code = $code;
             //判断是新还是旧
-            game_store.setters.setIsNew($code.indexOf('AI') != -1)
+            game_store.setters.setIsNew($code.indexOf("AI") != -1);
 
             console.log("头环码", $code);
-            game_store.setters.setDeviceSn($this.code)
+            game_store.setters.setDeviceSn($this.code);
             //设备信息
             $this.device_data.product_qrcode = url;
-            $this.device_data.sn = $this.code
+            $this.device_data.sn = $this.code;
             //产品名称、制造工厂
             $this.device_data.product_name = "水母智脑环";
-            $this.device_data.manufacturing_plan = "深圳水母智脑科技有限公司"
+            $this.device_data.manufacturing_plan = "深圳水母智脑科技有限公司";
             // 设备类型
-            $this.device_data.type = 1
-            $this.device_data.production_date = getNowDate()
+            $this.device_data.type = 1;
+            $this.device_data.production_date = getNowDate();
 
             //打开蓝牙设备
             wx.getSystemInfo({
@@ -292,9 +282,10 @@ export default {
                             }
                           },
                           fail(err) {
-                            let $msg = $this.$bluetooth.GetopenBluetoothAdapterError(
-                              err["errCode"]
-                            );
+                            let $msg =
+                              $this.$bluetooth.GetopenBluetoothAdapterError(
+                                err["errCode"]
+                              );
                             setTimeout(() => {
                               Toast.fail({
                                 message: $msg,
@@ -342,8 +333,8 @@ export default {
           }
         },
         fail(res) {
-          console.log(res)
-        }
+          console.log(res);
+        },
       });
     },
     //关闭窗口的方法
@@ -358,7 +349,7 @@ export default {
     open_choose_toy() {
       // $this.choose_toy_window.show = false;
       $this.choose_toy_window.show = true;
-      $this.toy_connected = false
+      $this.toy_connected = false;
       $this.$bluetooth.SendOrder("09");
     },
     // 选好玩具
@@ -374,7 +365,10 @@ export default {
         }
       });
       $this.toy_id = $toy.id;
-      let $hex = $this.toy_hex = $toy["hex"].substr($toy["hex"].length - 2, 2);
+      let $hex = ($this.toy_hex = $toy["hex"].substr(
+        $toy["hex"].length - 2,
+        2
+      ));
       //连接玩具
       $this.current_hex = `03 00 ${$hex} 00 0a`;
 
@@ -385,7 +379,7 @@ export default {
         if ($this.toy_connected == false) {
           $this.change_toy_connect_status(3);
         }
-      }, 10000)
+      }, 10000);
     },
     //修改玩具连接状态
     change_toy_connect_status($status = 0) {
@@ -408,7 +402,7 @@ export default {
         $this.connect_show = false;
         $this.device_bg = false;
 
-        $this.$bluetooth.SendOrder("09")
+        $this.$bluetooth.SendOrder("09");
         let deviceId = game_store.getters.getDeviceId();
         $this.change_toy_connect_status(0);
         //断开蓝牙连接
@@ -422,13 +416,13 @@ export default {
             wx.closeBluetoothAdapter();
           },
           fail(res) {
-            console.log("断开连接error:", res)
+            console.log("断开连接error:", res);
           },
           complete(res) {
-            $this.device = {}
+            $this.device = {};
             $this.toy_UUID = "";
             $this.$forceUpdate();
-          }
+          },
         });
       } else if ($status == 2) {
         $this.connect_show = true;
@@ -443,7 +437,7 @@ export default {
           //2021年10月21日15:07:57  通过sn 返回deviceId
           getDeviceBySn($this.code).then((res) => {
             let $data = res.data;
-            console.log($data.code)
+            console.log($data.code);
             $this.change_device_status(1);
             $data = $data.data;
             wx.getSystemInfo({
@@ -453,19 +447,18 @@ export default {
                   $this.onBluetoothDeviceFound();
                 } else {
                   if ($data.device_id) {
-                    console.log("finded")
-                    $this.device_finded = true
-                    $this.createBLEConnection($data.device_id)
+                    console.log("finded");
+                    $this.device_finded = true;
+                    $this.createBLEConnection($data.device_id);
                   } else {
-                    $this.device_finded = false
-                    console.log('unfinded')
+                    $this.device_finded = false;
+                    console.log("unfinded");
                     $this.onBluetoothDeviceFound();
                   }
                 }
-              }
+              },
             });
-          })
-
+          });
         },
         fail(err) {
           $this.change_device_status(3);
@@ -498,7 +491,7 @@ export default {
             }
             if (device["name"].toUpperCase() == $this.code) {
               $this.stopBluetoothDevicesDiscovery();
-              console.log("搜索设备", device)
+              console.log("搜索设备", device);
               $this.createBLEConnection(device.deviceId);
             }
           });
@@ -517,30 +510,29 @@ export default {
         deviceId: deviceId,
         success: (res) => {
           console.log("成功连接");
-          $this.$bluetooth.current_device_sn = $this.code
+          $this.$bluetooth.current_device_sn = $this.code;
           game_store.setters.setDeviceId(deviceId);
 
           //成功连接脑环蓝牙
           $this.change_device_status(2);
 
-          $this.$bluetooth.getBLEDeviceServices(deviceId)
+          $this.$bluetooth.getBLEDeviceServices(deviceId);
           let $checkServices = setInterval(() => {
             let $serviceId = game_store.getters.getServiceId();
             if ($serviceId) {
-              clearInterval($checkServices)
-              $this.$bluetooth.openNotify($this)
-              $this.$bluetooth.watchingDevice($this)
+              clearInterval($checkServices);
+              $this.$bluetooth.openNotify($this);
+              $this.$bluetooth.watchingDevice($this);
               $this.$bluetooth.watch_bluetooth_status($this);
               //录入库
               //读取信息逐个写入
               if (!$this.device_finded) {
                 setTimeout(() => {
-                  $this.$bluetooth.SendOrder("02")
-                }, 3000)
+                  $this.$bluetooth.SendOrder("02");
+                }, 3000);
               }
             }
-          }, 1500)
-
+          }, 1500);
         },
         fail(err) {
           console.log(err);
@@ -588,17 +580,18 @@ export default {
     // 游戏过程中关闭脑环状态
     let $game_close_status = game_store.getters.getGameCloseStatus();
     console.log("返回时:" + $game_status, $game_close_status);
+    let $ble_status = wx.getStorageSync("ble_link_status");
+    if ($ble_status == false) {
+      //断开蓝牙连接
+      $this.change_device_status(0);
+    }
     if ($game_status == 3) {
       //不在游戏状态
       $this.connect_toy = 0;
       $this.connect_show = true;
       $this.$bluetooth.watchingDevice($this);
       $this.$bluetooth.watch_bluetooth_status($this);
-      // let $ble_status = ble_store.getters.getBluetoothLinkStatus();
-      // if ($ble_status == false) {
-      //   //断开蓝牙连接
-      //   $this.change_device_status(0);
-      // }
+
       $this.toy_UUID = "";
       $this.$forceUpdate();
       // 状态为1的时候重置为1 小乌龟
@@ -612,7 +605,6 @@ export default {
         $this.$forceUpdate();
         // 清空链接的设备
         game_store.setters.clearDeviceToy();
-
       }
     }
   },

+ 56 - 99
src/components/device/toy/connecting.vue

@@ -7,53 +7,46 @@
             src="https://img.shuimuai.com/web/phone.png"
             alt=""
             class="device_phone"
-          >
+          />
           <text class="text-gray device_text"> 我的手机</text>
         </div>
       </van-col>
-      <van-col
-        span="3"
-        offset="1"
-      >
+      <van-col span="3" offset="1">
         <div class="dot_container flex align-center">
           <div class="dot_wait">
             <img
               src="https://img.shuimuai.com/m_sign_gou%402x.png"
               alt=""
               class="moving_dot"
-            >
+            />
           </div>
         </div>
       </van-col>
-      <van-col
-        span="5"
-        offset="0"
-      >
+      <van-col span="5" offset="0">
         <div class="device_bg flex flex-direction align-center justify-center">
           <img
             src="https://img.shuimuai.com/web/sign_green.png"
             alt=""
             class="sign_green"
             v-if="device_bg == true"
-          >
+          />
           <img
             src="https://img.shuimuai.com/web/sign_red.png"
             class="sign_green"
             alt=""
             v-else
-          >
+          />
           <img
             src="https://img.shuimuai.com/web/brain.png"
             alt=""
             class="device_brain"
+          />
+          <text class="text-gray device_text second_device_text">
+            已连接({{ device_power }}%)</text
           >
-          <text class="text-gray device_text second_device_text"> 已连接({{device_power}}%)</text>
         </div>
       </van-col>
-      <van-col
-        span="3"
-        offset="1"
-      >
+      <van-col span="3" offset="1">
         <div class="dot_container flex align-center">
           <div class="dot_wait">
             <img
@@ -61,37 +54,29 @@
               src="https://img.shuimuai.com/web/dot.png"
               alt=""
               class="moving_dot"
-              :class="{moving:connect_toy==1}"
+              :class="{ moving: connect_toy == 1 }"
             />
             <img
               v-if="connect_toy == 2"
               src="https://img.shuimuai.com/m_sign_gou%402x.png"
               alt=""
               class="moving_dot"
-            >
+            />
             <img
               v-if="connect_toy == 3"
               src="https://img.shuimuai.com/fail.png"
               alt=""
               class="moving_dot"
-            >
-
+            />
           </div>
         </div>
       </van-col>
-      <van-col
-        span="5"
-        offset="0"
-      >
+      <van-col span="5" offset="0">
         <div class="device_bg flex flex-direction align-center justify-center">
-          <img
-            :src="toy['img']"
-            alt=""
-            class="uav_toy"
-          >
+          <img :src="toy['img']" alt="" class="uav_toy" />
           <text class="text-gray device_text">
             <template v-if="connect_toy == 1 || connect_toy == 3">
-              {{ toy['name'] }}
+              {{ toy["name"] }}
             </template>
             <template v-if="connect_toy == 2 || connect_toy == 4">
               {{ toy_sn }}
@@ -103,28 +88,19 @@
     <!--        按钮组合-->
     <van-row gutter="6">
       <van-col span="8">
-        <button
-          class="cu-btn bg-red lg text-white"
-          @click="change_status"
-        >
+        <button class="cu-btn bg-red lg text-white" @click="change_status">
           <img
             src="https://img.shuimuai.com/m_duankainaohuan.png"
             class="cut_brain_icon"
             alt=""
-          >
-          <text class=" cut_text">断开脑环</text>
+          />
+          <text class="cut_text">断开脑环</text>
         </button>
       </van-col>
 
-      <van-col
-        span="12"
-        offset="1"
-        v-if="connect_toy == 1"
-      >
+      <van-col span="12" offset="1" v-if="connect_toy == 1">
         <van-row class="text-center">
-          <text class="text-gray text-lg">
-            连接中...
-          </text>
+          <text class="text-gray text-lg"> 连接中... </text>
         </van-row>
       </van-col>
 
@@ -139,8 +115,8 @@
               src="https://img.shuimuai.com/m_xuanzewanju.png"
               alt=""
               class="cut_brain_icon"
-            >
-            <text class=" cut_text">选择玩具</text>
+            />
+            <text class="cut_text">选择玩具</text>
           </button>
         </van-col>
 
@@ -148,19 +124,16 @@
           <button
             class="cu-btn bg-red lg cu-btn-primary"
             @click="choose_pay_window"
+            :disabled="is_started"
           >
             <img
               src="https://img.shuimuai.com/web/start_game_icon.png"
               alt=""
               class="cut_start_game_icon"
-            >
-            <text
-              class=" cut_text"
-              style="padding: 0px;"
-            >开始训练</text>
+            />
+            <text class="cut_text" style="padding: 0px">开始训练</text>
           </button>
         </van-col>
-
       </div>
 
       <!--      玩具连接失败-->
@@ -174,19 +147,16 @@
               src="https://img.shuimuai.com/m_xuanzewanju.png"
               alt=""
               class="cut_brain_icon"
-            >
-            <text class=" cut_text">选择玩具</text>
+            />
+            <text class="cut_text">选择玩具</text>
           </button>
         </van-col>
 
         <van-col span="8">
           <van-row class="text-center">
-            <text class="text-gray text-lg">
-              连接失败
-            </text>
+            <text class="text-gray text-lg"> 连接失败 </text>
           </van-row>
         </van-col>
-
       </div>
 
       <!--      玩具连接中-->
@@ -200,7 +170,7 @@
 
         <van-col span="16">
           <button
-            class="cu-btn bg-green lg "
+            class="cu-btn bg-green lg"
             @click="to_playing"
             style="width: 100%"
           >
@@ -208,36 +178,30 @@
               src="https://img.shuimuai.com/web/start_game_icon.png"
               alt=""
               class="cut_start_game_icon"
-            >
-            <text
-              class=" cut_text"
-              style="padding: 0px;"
-            >游戏中</text>
+            />
+            <text class="cut_text" style="padding: 0px">游戏中</text>
           </button>
         </van-col>
-
       </div>
     </van-row>
 
     <!--  选择消费方式的窗口  -->
 
-    <van-overlay
-      :show="pay_window"
-      @click="onClickHide"
-      z-index="5"
-    >
+    <van-overlay :show="pay_window" @click="onClickHide" z-index="5">
       <div class="pay_type_window">
         <div class="pay_type_title padding">
           <text class="text-bold pay_type_title_text">选择消费方式</text>
         </div>
 
         <van-row gutter="11">
-          <van-col
-            span="11"
-            offset="1"
-          >
+          <van-col span="11" offset="1">
             <div
-              class="pay_type_item flex flex-direction justify-center align-center"
+              class="
+                pay_type_item
+                flex flex-direction
+                justify-center
+                align-center
+              "
               @click.prevent="choose_pay(2)"
             >
               <view class="text-xl padding">
@@ -247,7 +211,12 @@
           </van-col>
           <van-col span="11">
             <div
-              class="pay_type_item  flex flex-direction justify-center align-center"
+              class="
+                pay_type_item
+                flex flex-direction
+                justify-center
+                align-center
+              "
               @click.prevent="choose_pay(1)"
             >
               <view class="text-xl padding">
@@ -264,7 +233,7 @@
         src="https://img.shuimuai.com/web/boy2.png"
         alt=""
         class="connected_boy2"
-      >
+      />
     </van-overlay>
     <van-toast id="van-toast" />
 
@@ -280,7 +249,7 @@
     </van-popup>
 
     <!-- 防止多次开始 -->
-    <cover-view class="started_bg" v-show="is_started"></cover-view>
+    <!-- <cover-view class="started_bg" v-show="is_started"></cover-view> -->
   </div>
 </template>
 
@@ -324,9 +293,9 @@ export default {
         return false;
       }
 
-      if(wx.getStorageSync("userinfo").level == 11){
-        $this.choose_pay(2)
-      }else{
+      if (wx.getStorageSync("userinfo").level == 11) {
+        $this.choose_pay(2);
+      } else {
         $this.pay_window = true;
       }
     },
@@ -337,7 +306,7 @@ export default {
         return false;
       }
 
-      $this.is_started = true
+      $this.is_started = true;
 
       $this.pay_type = $event;
       let $params = {
@@ -352,11 +321,9 @@ export default {
           let $data = res.data;
           let $res = $data.data;
           if ($data.code == 0) {
-            // 设置游戏中
             // 设置游戏模式
             game_store.setters.setMode($event);
             // 设置游戏状态为游戏中
-            // game_store.setters.setGameStatus(1);
             // 设置游戏记录id
             game_store.setters.setGameRecordId($res["game_record_id"]);
 
@@ -366,23 +333,13 @@ export default {
             Toast.success($data.errmsg);
             game_store.setters.setPlayTime($res["play_time"]);
             game_store.setters.setOverPlayTime($res["play_time"]);
-            // setTimeout(() => {
-            //   mpvue.navigateTo({
-            //     url: "/pages/start/main",
-            //     success() {
-            //       // 记录消费方式 选择时间卡还是次卡
-                  
-            //       $this.$emit("gameStart", true);
-            //     },
-            //   });
-            // }, 800);
           } else {
-            $this.is_started = false
+            $this.is_started = false;
             Toast.fail($data.errmsg);
           }
         },
         (err) => {
-          $this.is_started = false
+          $this.is_started = false;
           console.log(err);
         }
       );
@@ -406,8 +363,8 @@ export default {
       $this.$emit("change_status", 0);
     },
   },
-  onShow(){
-    $this.is_started = false
+  onShow() {
+    $this.is_started = false;
   },
   created() {
     $this = this;

+ 1 - 1
src/pages/index/index.vue

@@ -201,7 +201,7 @@ export default {
   },
   onLoad($option) {
     if (process.env.NODE_ENV == "development") {
-      // wx.setStorageSync("token", "ogsti72oUSkbPl4OL7gl9woLTxR6fk4V");
+      wx.setStorageSync("token", "ogsti72oUSkbPl4OL7gl9woLTxR6fk4V");
     }
 
     if (game_store.getters.getGameStatus() == 1) {

+ 0 - 49
src/pages/report/index.vue

@@ -848,15 +848,6 @@ export default {
                 $this.record.line_med,
                 $this.record.amp
               );
-              // 处理 alpha beta
-              // $this.get_game_ab(
-              //   $this.record.low_alpha,
-              //   $this.record.high_alpha,
-              //   $this.record.low_beta,
-              //   $this.record.high_beta
-              // );
-              // // 处理 delta theta
-              // $this.get_game_dt($this.record.delta, $this.record.theta);
             }
 
             // 干扰值数据传输
@@ -887,21 +878,6 @@ export default {
       );
       att_charts.setOption($option);
     },
-    // get_game_ab($line_alphaL, $line_alphaH, $line_betaL, $line_betaH) {
-    //   let $option = {};
-    //   $option = util.getABOption(
-    //     $line_alphaL,
-    //     $line_alphaH,
-    //     $line_betaL,
-    //     $line_betaH
-    //   );
-    //   alpha_beta_charts.setOption($option);
-    // },
-    // get_game_dt($line_delta, $line_theta) {
-    //   let $option = {};
-    //   $option = util.getDTOption($line_delta, $line_theta);
-    //   delta_theta_charts.setOption($option);
-    // },
     to_game_records() {
       mpvue.navigateTo({
         url: "/pages/game_record/main",
@@ -919,31 +895,6 @@ export default {
       let $amp_data = $this.record.amp.slice($start, $end);
       $this.get_game_line($line_data, $med_data, $amp_data);
     },
-    //  切换时间查看线 数据
-    // changeABMin($e) {
-    //   let $index = $e.mp.detail.name;
-    //   // 0-2  2-4  4-6
-    //   // 0    1    2
-    //   let $start = $index * 120;
-    //   let $end = ($index + 1) * 120;
-    //   console.log($start, $end);
-    //   let low_alpha = $this.record.low_alpha.slice($start, $end);
-    //   let high_alpha = $this.record.high_alpha.slice($start, $end);
-    //   let low_beta = $this.record.low_beta.slice($start, $end);
-    //   let high_beta = $this.record.high_beta.slice($start, $end);
-    //   $this.get_game_ab(low_alpha, high_alpha, low_beta, high_beta);
-    // },
-    // //  切换时间查看线 数据
-    // changeDTMin($e) {
-    //   let $index = $e.mp.detail.name;
-    //   // 0-2  2-4  4-6
-    //   // 0    1    2
-    //   let $start = $index * 120;
-    //   let $end = ($index + 1) * 120;
-    //   let delta = $this.record.delta.slice($start, $end);
-    //   let theta = $this.record.theta.slice($start, $end);
-    //   $this.get_game_dt(delta, theta);
-    // },
     // 关闭雷达解释
     closeRadarExplain() {
       $this.is_explainShow = false