Explorar el Código

异常训练报告处理

chaooo hace 1 año
padre
commit
a0e9ed6be7
Se han modificado 2 ficheros con 30 adiciones y 28 borrados
  1. 29 27
      src/pages/games/play/index.vue
  2. 1 1
      src/pages/games/report/index.vue

+ 29 - 27
src/pages/games/play/index.vue

@@ -471,6 +471,7 @@ export default {
     startTheGame() {
       LOG_DEBUG("开始游戏");
       game_store.setters.setGameStatus(2);
+      game_store.setters.setGameDataLength(0);
       wx.setKeepScreenOn({
         keepScreenOn: true,
       });
@@ -559,17 +560,6 @@ export default {
       $this.$connection.sendControlClose();
       // 结束游戏提交数据
       $this.postGameData();
-      // 跳转到报告页
-      Toast.loading({
-        forbidClick: true,
-        mask: true,
-        message: "正在生成报告...",
-        duration: 2000,
-        onClose() {
-          $this.toReportPage();
-          $this.end_loading = false;
-        }
-      });
       let $code = ble_store.getters.getDeviceSn();
       LOG_WECHAT($code, "结束训练record_id:", game_store.getters.getGameRecordId());
     },
@@ -590,15 +580,14 @@ export default {
         ...post_data,
         sn: ble_store.getters.getDeviceSn()
       };
-      if (!$dataParams.line) {
-        return false;
+      if ($dataParams.line) {
+        gameAddLine($dataParams).then((res) => {
+          let $data = res.data;
+          if ($data.code*1 === 0) {
+            $this.game_data = [];
+          }
+        });
       }
-      gameAddLine($dataParams).then((res) => {
-        let $data = res.data;
-        if ($data.code*1 === 0) {
-          $this.game_data = [];
-        }
-      });
       let $params = {
         game_record_id: game_store.getters.getGameRecordId(),
         type: $this.mode,
@@ -607,6 +596,8 @@ export default {
       gameEnd($params).then(() => {
         $this.resetGameData();
       });
+      // 跳转到报告页
+      $this.toReportPage();
     },
     /**
      * 重置游戏数据
@@ -646,14 +637,25 @@ export default {
      * 跳转到报告页
      */
     toReportPage() {
-      mpvue.redirectTo({
-        url: "/pages/games/report/main?id=" + game_store.getters.getGameRecordId() + "&size=" + game_store.getters.getGameDataLength(),
-        success() {
-          $this.attList = [];
-          $this.medList = [];
-          $this.ampList = [];
-          LOG_DEBUG("生成报告成功")
-        },
+      let report_url = "/pages/games/report/main?id=" + game_store.getters.getGameRecordId() + "&size=" + game_store.getters.getGameDataLength();
+      console.log(report_url);
+      Toast.loading({
+        forbidClick: true,
+        mask: true,
+        message: "正在生成报告...",
+        duration: 2000,
+        onClose() {
+          mpvue.redirectTo({
+            url: report_url,
+            success() {
+              $this.attList = [];
+              $this.medList = [];
+              $this.ampList = [];
+              LOG_DEBUG("生成报告成功")
+            },
+          });
+          $this.end_loading = false;
+        }
       });
     },
   },

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

@@ -21,7 +21,7 @@ export default {
   data() {
     return {
       report_id: 0,
-      data_length: 15,
+      data_length: 0,
       webUrl: ""
     }
   },