|
@@ -501,7 +501,8 @@ export default {
|
|
|
$this.countdownInterval();
|
|
|
},
|
|
|
countdownInterval(){
|
|
|
- clearInterval($timeout)
|
|
|
+ clearInterval($timeout);
|
|
|
+ let count = 0;
|
|
|
$timeout = setInterval(() => {
|
|
|
//判断是否游戏中
|
|
|
let game_status = game_store.getters.getGameStatus()*1;
|
|
@@ -511,12 +512,29 @@ export default {
|
|
|
game_store.setters.setPlayedTime($this.total_time-$this.play_time);
|
|
|
$this.countdown_text = formatPlaySeconds($this.play_time);
|
|
|
console.log("%c游戏倒计时", "color:red;", $this.countdown_text);
|
|
|
+ count += 1;
|
|
|
+ if( count % 10 === 0) {
|
|
|
+ // 每10秒获取手机蓝牙状态
|
|
|
+ $this.getBleAdapterState();
|
|
|
+ }
|
|
|
} else {
|
|
|
clearInterval($timeout);
|
|
|
$this.endTheGame();
|
|
|
}
|
|
|
}, 1000);
|
|
|
},
|
|
|
+ getBleAdapterState(){
|
|
|
+ // 获取本机蓝牙适配器状态
|
|
|
+ wx.getBluetoothAdapterState({
|
|
|
+ complete: function (res) {
|
|
|
+ LOG_DEBUG("游戏中,获取手机蓝牙状态:", JSON.stringify(res));
|
|
|
+ if (!res.available) {
|
|
|
+ clearInterval($timeout);
|
|
|
+ $this.endTheGame();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
/**
|
|
|
* 点击结束游戏按钮
|
|
|
*/
|
|
@@ -560,15 +578,15 @@ export default {
|
|
|
*/
|
|
|
postGameData() {
|
|
|
let post_data = [];
|
|
|
- for (let i = 0; i < this.save_index.length; i++) {
|
|
|
- post_data[this.save_index[i]] = this.game_data[this.save_index[i]].join(',');
|
|
|
+ for (let i = 0; i < $this.save_index.length; i++) {
|
|
|
+ post_data[$this.save_index[i]] = $this.game_data[$this.save_index[i]]?$this.game_data[$this.save_index[i]].join(','):"";
|
|
|
}
|
|
|
//判断数据长度大于理想状态 需要对数组进行切割 逐个提交数据
|
|
|
let $dataParams = {
|
|
|
game_record_id: game_store.getters.getGameRecordId(),
|
|
|
//数据段长度小于65 单个提交
|
|
|
- line: this.game_data['att'].join(','),
|
|
|
- line_med: this.game_data['med'].join(','),
|
|
|
+ line: $this.game_data['att']?$this.game_data['att'].join(','):"",
|
|
|
+ line_med: $this.game_data['med']?$this.game_data['med'].join(','):"",
|
|
|
...post_data,
|
|
|
sn: ble_store.getters.getDeviceSn()
|
|
|
};
|