Преглед на файлове

解决了大数据量导致无法结束游戏的bug

yerong преди 4 години
родител
ревизия
946cd5fb90
променени са 4 файла, в които са добавени 29 реда и са изтрити 33 реда
  1. 1 1
      src/components/device/device.vue
  2. 22 29
      src/pages/start/index.vue
  3. 3 1
      src/utils/bluetooth.js
  4. 3 2
      src/utils/index.js

+ 1 - 1
src/components/device/device.vue

@@ -443,9 +443,9 @@ export default {
       //不在游戏状态
       $this.change_toy_connect_status(0);
       $this.connect_show = true;
-      let $ble_status = ble_store.getters.getBluetoothLinkStatus();
       bluetooth.watchingDevice($this);
       bluetooth.watch_bluetooth_status($this);
+      let $ble_status = ble_store.getters.getBluetoothLinkStatus();
       if ($ble_status == false) {
         //断开蓝牙连接
         $this.change_device_status(0);

+ 22 - 29
src/pages/start/index.vue

@@ -236,23 +236,17 @@ export default {
       game_store.setters.setMode(0)
       //删除游戏得id
       game_store.setters.removeToyHex()
-      const $proce = new Promise((resolve, reject) => {
-        let cost_time = $this.post_data()
-        console.log('提交数据使用了:', cost_time)
-        resolve(cost_time)
-      }).then((value) => {
-        Toast.loading({
-          forbidClick: true,
-          mask: true,
-          message: "正在生成报告...",
-          duration: value,
-          onClose() {
-            $this.game_over()
-            $this.to_report()
-          }
-        })
+
+      Toast.loading({
+        forbidClick: true,
+        mask: true,
+        message: "正在生成报告...",
+        duration: 0,
       })
+      // 结束游戏在提交报告函数里
+      $this.post_data()
     },
+
     // 时间到
     time_out() {
       console.log('游戏结束')
@@ -287,9 +281,9 @@ export default {
     // 往后端推送一次定时数据
     post_data() {
       //判断数据长度大于理想状态 需要对数组进行切割 逐个提交数据
-      let $len = 60
-      if ($this.attList.length > 65) {
-        let $count = Math.ceil($this.attList.length / 60)
+      let $len = 300
+      if ($this.attList.length > $len) {
+        let $count = Math.ceil($this.attList.length / $len)
 
         let index = 0
         let inter = setInterval(() => {
@@ -313,9 +307,11 @@ export default {
           index++
           if (index == $count) {
             clearInterval(inter)
+            $this.game_over()
+            $this.to_report()
           }
-        }, 800)
-        return $count * 800
+        }, 200)
+        return $count * 500
       } else {
         let $params = {
           game_record_id: game_store.getters.getGameRecordId(),
@@ -334,6 +330,10 @@ export default {
             $this.medList = []
           }
         })
+        setTimeout(() => {
+          $this.game_over()
+          $this.to_report()
+        }, 800)
         return 800
       }
     },
@@ -409,19 +409,12 @@ export default {
       let $play_time = $this.play_time = game_store.getters.getPlayTime()
 
       //已经完了多长时间
-      // $this.played_time = game_store.getters.getPlayedTime() ? game_store.getters.getPlayedTime() : 0
       $this.played_time = game_store.getters.getPlayTime()
 
-      //判断可玩时长超出了时间 就直接结束游戏
-      // if ($played_time >= ($play_time * 1000)) {
-      //   $this.game_finished()
-      // }
-
       $this.mode_item = {}
       $this.mode_item = mode_list[$this.mode - 1]
-      // let $origin_time = $play_time * 1000
-      // $this.mode_item['time'] = $origin_time - ($played_time * 1000)
-      $this.mode_item['time'] = $play_time * 1000
+      // $this.mode_item['time'] = $play_time * 1000
+      $this.mode_item['time'] = 50 * 1000
     }
   }
   ,

+ 3 - 1
src/utils/bluetooth.js

@@ -667,10 +667,12 @@ export default {
       if (result.length == 1) {
         result = '0' + result
       }
-      if (parseInt(minuteTime).toString().length == 1){
+      if (parseInt(minuteTime).toString().length == 1) {
         minuteTime = '0' + parseInt(minuteTime)
       }
       result = "" + minuteTime + ":" + result;
+    } else {
+      result = "00:" + result;
     }
     return result;
   }

+ 3 - 2
src/utils/index.js

@@ -106,7 +106,8 @@ function getLineOption(lineData_att, lineData_med) {
       bottom: 16,
       top: 16,
       // show:true,
-      containLabel: true
+      containLabel: true,
+      zlevel: 1
     },
     tooltip: {
       show: true,
@@ -307,7 +308,7 @@ export function formatSeconds(value) {
 
 //获取等级名称
 function get_level_name($level_id) {
-  let $level = ['普通用户', '体验会员', '黄金会员', '白金会员', '钻石会员', '创客代理', '区域代理', '合伙人', '店员', '店长','老师']
+  let $level = ['普通用户', '体验会员', '黄金会员', '白金会员', '钻石会员', '创客代理', '区域代理', '合伙人', '店员', '店长', '老师']
   return $level[$level_id]
 }