|
@@ -229,6 +229,7 @@ export default {
|
|
|
game_store.setters.setGameStatus(3)
|
|
|
//游戏结束重置游戏时间
|
|
|
wx.removeStorageSync('play_time')
|
|
|
+ wx.removeStorageSync('hide_time')
|
|
|
//游戏结束重置游戏模式
|
|
|
game_store.setters.setMode(0)
|
|
|
//删除游戏得id
|
|
@@ -243,13 +244,12 @@ export default {
|
|
|
Toast.loading({
|
|
|
forbidClick: true,
|
|
|
message: "正在生成报告...",
|
|
|
- duration: 0
|
|
|
+ duration: 800,
|
|
|
+ onClose() {
|
|
|
+ $this.game_over()
|
|
|
+ $this.to_report()
|
|
|
+ }
|
|
|
})
|
|
|
- setTimeout(() => {
|
|
|
- Toast.clear()
|
|
|
- $this.game_over()
|
|
|
- $this.to_report()
|
|
|
- }, 800)
|
|
|
} catch (e) {
|
|
|
console.log('error', e)
|
|
|
}
|
|
@@ -263,7 +263,10 @@ export default {
|
|
|
},
|
|
|
to_report() {
|
|
|
mpvue.reLaunch({
|
|
|
- url: "/pages/report/main"
|
|
|
+ url: "/pages/report/main",
|
|
|
+ success(){
|
|
|
+ $this.timeData = {}
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
start_game() {
|
|
@@ -412,27 +415,12 @@ export default {
|
|
|
$this.attList.push($data['att'])
|
|
|
$this.medList.push($data['med'])
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
- ,
|
|
|
- mounted() {
|
|
|
-
|
|
|
- let $deviceId = $this._deviceId = game_store.getters.getDeviceId()
|
|
|
- let $serviceId = $this._serviceId = game_store.getters.getServiceId()
|
|
|
- let $cId = $this._characteristicId = game_store.getters.getCharacterId()
|
|
|
- console.log("游戏开始:", $deviceId, $serviceId, $cId)
|
|
|
-
|
|
|
- //判断是否结束游戏
|
|
|
- if ($this.is_end == true) {
|
|
|
- $this.game_finished()
|
|
|
- } else {
|
|
|
- // 筛选 玩具id
|
|
|
- $this.toy_hex = game_store.getters.getToyHex()
|
|
|
-
|
|
|
+ },
|
|
|
+ //计算游玩时间
|
|
|
+ calThePlayedTime() {
|
|
|
//筛选模式
|
|
|
$this.mode = game_store.getters.getMode()
|
|
|
|
|
|
-
|
|
|
let mode_list = [
|
|
|
{
|
|
|
id: 1,
|
|
@@ -451,13 +439,31 @@ export default {
|
|
|
|
|
|
//可玩时间
|
|
|
let $play_time = $this.play_time = game_store.getters.getPlayTime()
|
|
|
+
|
|
|
//已经完了多长时间
|
|
|
let $played_time = $this.played_time = game_store.getters.getPlayedTime() ? game_store.getters.getPlayedTime() : 0
|
|
|
+
|
|
|
$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)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ,
|
|
|
+ mounted() {
|
|
|
+
|
|
|
+ let $deviceId = $this._deviceId = game_store.getters.getDeviceId()
|
|
|
+ let $serviceId = $this._serviceId = game_store.getters.getServiceId()
|
|
|
+ let $cId = $this._characteristicId = game_store.getters.getCharacterId()
|
|
|
+ console.log("游戏开始:", $deviceId, $serviceId, $cId)
|
|
|
|
|
|
+ //判断是否结束游戏
|
|
|
+ if ($this.is_end == true) {
|
|
|
+ $this.game_finished()
|
|
|
+ } else {
|
|
|
+ // 筛选 玩具id
|
|
|
+ $this.toy_hex = game_store.getters.getToyHex()
|
|
|
+ $this.calThePlayedTime()
|
|
|
$this.start_game()
|
|
|
|
|
|
//打开蓝牙监听
|
|
@@ -469,10 +475,27 @@ export default {
|
|
|
$this = this;
|
|
|
},
|
|
|
onShow() {
|
|
|
- if ($this.timeData.minutes == '00' && $this.timeData.seconds == '00'){
|
|
|
- $this.game_finished()
|
|
|
+ if ($this.timeData.minutes == '00' && $this.timeData.seconds == '00') {
|
|
|
+ $this.time_out()
|
|
|
+ } else {
|
|
|
+ //获取 拉到后台得时间
|
|
|
+ let $hide_time = game_store.getters.getHideTime()
|
|
|
+ if ($hide_time) {
|
|
|
+ //获取当前时间
|
|
|
+ let $now = Math.round(new Date() / 1000)
|
|
|
+ //获得后台到当前时间差
|
|
|
+ let $residue = $now - $hide_time
|
|
|
+ //将原来的游玩时间+上 时间差
|
|
|
+ let $played_time = $this.played_time * 1 + $residue * 1
|
|
|
+ //重新设置游玩时间
|
|
|
+ game_store.setters.setPlayedTime($played_time)
|
|
|
+ $this.calThePlayedTime()
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
+ onHide() {
|
|
|
+ game_store.setters.setHideTime(Math.round(new Date() / 1000))
|
|
|
+ },
|
|
|
onLoad(options) {
|
|
|
if (options.end == 1) {
|
|
|
$this.is_end = true
|