Browse Source

蓝牙连接状态机训练报告少于15条不显示

chaooo 1 year ago
parent
commit
301a9f68b6

+ 14 - 6
src/components/connection/index.vue

@@ -45,6 +45,13 @@ export default {
   created() {
     $this = this;
   },
+  watch: {
+    'connect_toy': {
+      handler: function($status) {
+        console.log("监听connect_toy状态变化",$status);
+      }, immediate: true
+    }
+  },
   methods: {
     /**
      * 获取设备扫码连接状态
@@ -59,6 +66,8 @@ export default {
      * @param $status 设备状态 0:为未连接,1:连接中,2:已连接 3:连接失败 5:取消连接
      */
     setDeviceStatus($status) {
+      // 重置教具连接状态
+      $this.connect_toy = 0;
       console.log("接收到设备连接状态:", $status);
       if ($status * 1 === 2) {
         $this.device_status = 2;
@@ -79,7 +88,6 @@ export default {
           $this.$connection.closeConnection($this);
         }
         $this.device_status = 0;
-        $this.connect_toy = 0;
       }
     },
     /**
@@ -107,11 +115,11 @@ export default {
         $this.setToyStatus(1);
         $this.$connection.sendToyConnection($this.toy_item);
         //2022-5-25 09:07:59 设置10秒后是否已经连接
-        setTimeout(() => {
-          if ($this.connect_toy !== 2) {
-            $this.setToyStatus(3);
-          }
-        }, 10000);
+        // setTimeout(() => {
+        //   if ($this.connect_toy !== 2) {
+        //     $this.setToyStatus(3);
+        //   }
+        // }, 10000);
       }
     },
     /**

+ 14 - 6
src/components/index/cards.vue

@@ -39,7 +39,12 @@ export default {
     <div :class="{ userinfoYellow: userinfo.isActive, userinfoGrey: userinfo.isntActive}">
       <van-row class="padding">
         <van-col span="3" offset="2">
-          <view class="cu-avatar radius lg" :style="'background-image:url(' + userinfo.portrait + ');'"></view>
+          <template v-if="userinfo.portrait">
+            <view class="cu-avatar radius lg" :style="'background-image:url(' + userinfo.portrait + ');'"></view>
+          </template>
+          <template v-else>
+            <view class="cu-avatar radius lg"></view>
+          </template>
         </van-col>
         <van-col span="12" offset="1">
           <div class="flex flex-direction align-start justify-start">
@@ -47,13 +52,16 @@ export default {
               <text class="text-black text-bold">{{ userinfo.user_name }}</text>
             </div>
             <div class="flex justify-between align-center">
-              <button class="cu-btn sm round"
-                      :class="{ level_btn_yellow: userinfo.isActive, level_btn_grey: userinfo.isntActive }">
+              <button class="cu-btn sm round level_btn_yellow">
                 {{ userinfo.level_name }}
               </button>
-              <view class="text-xs padding-left" v-if="userinfo.level*1 === 11">有效期至
-                {{ userinfo["validity_time_formatted"] }}
-              </view>
+<!--              <button class="cu-btn sm round"-->
+<!--                      :class="{ level_btn_yellow: userinfo.isActive, level_btn_grey: userinfo.isntActive }">-->
+<!--                {{ userinfo.level_name }}-->
+<!--              </button>-->
+<!--              <view class="text-xs padding-left" v-if="userinfo.level*1 === 11">有效期至-->
+<!--                {{ userinfo["validity_time_formatted"] }}-->
+<!--              </view>-->
             </div>
           </div>
         </van-col>

+ 3 - 3
src/pages/games/records/index.vue

@@ -30,7 +30,7 @@
                     :value="item.play_time"
                     v-for="(item,index) in items"
                     :key="index"
-                    @click="to_report(item.game_record_id,item.device_id)"
+                    @click="to_report(item.game_record_id,item.device_id,item.length)"
           />
 
         </div>
@@ -96,13 +96,13 @@ export default {
       let $item = $this.dates[$event.mp.detail.index]
       $this.get_game_list($item)
     },
-    to_report($event, device_id) {
+    to_report(id, device_id, size) {
       let mode = 1
       if (parseInt(device_id) === 0) {
         mode = 2
       }
       mpvue.navigateTo({
-        url: `/pages/games/report/main?id=${$event}&mode=${mode}`
+        url: `/pages/games/report/main?id=${id}&mode=${mode}&size=${size}`
       })
     },
     get_game_list($params = {}) {

+ 18 - 7
src/pages/games/report/index.vue

@@ -1,6 +1,11 @@
 <template>
   <div class="reportContainer">
-    <web-view :src="webUrl" @load="webLoading"></web-view>
+    <div v-if="data_length>=15">
+      <web-view :src="webUrl" @load="webLoading"></web-view>
+    </div>
+    <div v-else style="padding:400rpx 20rpx 0 20rpx;">
+      本次训练有效数据不足,无法分析并生成有效报告,请确保训练时脑机佩戴正确,网络状况良好,且训练时长不能太短。
+    </div>
     <van-toast id="van-toast"/>
   </div>
 </template>
@@ -14,6 +19,7 @@ export default {
   data() {
     return {
       report_id: 0,
+      data_length: 15,
       webUrl: ""
     }
   },
@@ -35,12 +41,17 @@ export default {
     $this.report_id = options.id
       ? options.id
       : game_store.getters.getGameRecordId();
-    let mode = options.mode ? options.mode : wx.getStorageSync('report_mode')
-    console.log($this.report_id);
-    let $userinfo = wx.getStorageSync("userinfo")
-
-    $this.webUrl = `${process.env.REPORT_URI}?mode=${mode}&token=${store.getters.get_token()}&record_id=${options.id}&nickName=${$userinfo.user_name}&mp=1`
-    console.log($this.webUrl);
+    if (options.size && options.size > 0) {
+      $this.data_length = options.size;
+    }
+    if($this.data_length < 15){
+      wx.hideLoading();
+    } else {
+      let mode = options.mode ? options.mode : wx.getStorageSync('report_mode')
+      let $userinfo = wx.getStorageSync("userinfo")
+      $this.webUrl = `${process.env.REPORT_URI}?mode=${mode}&token=${store.getters.get_token()}&record_id=${options.id}&nickName=${$userinfo.user_name}&mp=1`
+      console.log($this.webUrl);
+    }
   },
   onUnload(){
     wx.removeStorageSync("mode")

+ 6 - 10
src/pages/games/start/index.vue

@@ -223,7 +223,9 @@ export default {
       toy_power: 0,
       // 使用类型: 1:次数 2:时间 0:未选择
       mode: 0,
-
+      //  蓝牙信号强度
+      RSSI: 0,
+      game_status: 0,
 
       // 监听到的蓝牙数据
       hexStr:"",
@@ -277,13 +279,6 @@ export default {
       //结束游戏时选择类型的时间
       over_play_time: 0,
 
-
-      //  蓝牙信号强度
-      RSSI: 0,
-      game_status: 0,
-
-
-
       save_index: [
         "att",
         "med",
@@ -360,7 +355,7 @@ export default {
     },
     to_report() {
       mpvue.redirectTo({
-        url: "/pages/games/report/main?id=" + wx.getStorageSync("game_record_id"),
+        url: "/pages/games/report/main?id=" + game_store.getters.getGameRecordId() + "&size=" +game_store.getters.getGameDataLength(),
         success() {
           $this.timeData = {};
           $this.attList = [];
@@ -493,6 +488,7 @@ export default {
     do_datas: function ($data) {
       $this.online_att = $data["att"];
       $this.online_med = $data["med"];
+
       let $att_msg = "";
       if ($data["att"] >= 1 && $data['att'] < 40) {
         $att_msg = "专注力不足";
@@ -527,7 +523,7 @@ export default {
       $this.high_alphas.push($data['high_alpha']);
       $this.low_betas.push($data['low_beta']);
       $this.high_betas.push($data['high_beta']);
-
+      game_store.setters.setGameDataLength($this.att_list.length);
       if ($this.att_list.length > 15) {
         $this.att_list.shift();
         $this.med_list.shift();

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

@@ -69,7 +69,7 @@ export default {
   onShareAppMessage() {
     return {
       title: "欢迎进入水母星球",
-      imageUrl: "http://img.shuimuai.com/sharePahe_one.jpg",
+      imageUrl: "https://img.shuimuai.com/sharePahe_one.jpg",
       path: "/pages/index/main",
     };
   },
@@ -100,10 +100,10 @@ export default {
       <div class="content">
         <van-row>
           <van-col span="12">
-            <img src="https://img.shuimuai.com/web/index_btn_chengjijilu.png" @click="pageTo('games/records')">
+            <img src="https://img.shuimuai.com/web/index_btn_chengjijilu.png" @click="pageTo('games/records')" alt="">
           </van-col>
           <van-col span="12">
-            <img src="https://img.shuimuai.com/web/index_btn_gerenzhongxin.png" @click="pageTo('user')">
+            <img src="https://img.shuimuai.com/web/index_btn_gerenzhongxin.png" @click="pageTo('user')" alt="">
           </van-col>
         </van-row>
       </div>
@@ -123,7 +123,7 @@ export default {
   z-index: 3;
   top: -90px;
   margin: 0px 10px;
-  background-image: url(https://img.shuimuai.com/shuimugongzhu.png);
+  background-image: url("https://img.shuimuai.com/shuimugongzhu.png");
   background-position: center;
   background-size: 100% 100%;
   background-color: rgba(255, 255, 255, 0);

+ 2 - 2
src/pages/user/index.vue

@@ -14,8 +14,8 @@
             <text>
               <text>{{ userinfo.user_name }}</text>
             </text>
-            <text v-if="userinfo.level != 1">{{ userinfo.level_name }}&emsp;有效期至 {{ userinfo.validity_time }}</text>
-            <text v-else>{{ userinfo.level_name }}</text>
+<!--            <text v-if="userinfo.level != 1">{{ userinfo.level_name }}&emsp;有效期至 {{ userinfo.validity_time }}</text>-->
+            <text>{{ userinfo.level_name }}</text>
           </view>
         </view>
         <!--        <view class="right">-->

+ 6 - 0
src/store/game.js

@@ -10,6 +10,9 @@ const setters = {
   setGameRecordId(param) {
     wx.setStorageSync('game_record_id', param)
   },
+  setGameDataLength(param) {
+    wx.setStorageSync('game_data_length', param)
+  },
   // 游玩类型的时间30分钟或10分钟
   setOverPlayTime(param) {
     wx.setStorageSync('over_play_time', param)
@@ -51,6 +54,9 @@ const getters = {
   getGameRecordId() {
     return wx.getStorageSync('game_record_id')
   },
+  getGameDataLength() {
+    return wx.getStorageSync('game_data_length')
+  },
   // 游玩类型的时间30分钟或10分钟
   getOverPlayTime() {
     return wx.getStorageSync('over_play_time')

+ 3 - 0
src/utils/connection.js

@@ -569,6 +569,9 @@ export default {
         complete() {
           //$this.device = {};
           //$this.toy_UUID = "";
+          $this.device_bg = false;
+          $this.connect_toy = 0;
+          $this.device_status = 0;
           $this.$forceUpdate();
         },
       });