game.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. const setters = {
  2. clearDeviceToy() {
  3. wx.removeStorageSync('deviceId')
  4. wx.removeStorageSync('deviceSn')
  5. wx.removeStorageSync('serviceId')
  6. wx.removeStorageSync('is_new')
  7. // wx.removeStorageSync('characteristicId')
  8. },
  9. //setter模块
  10. // 游戏状态: 0未开始 1游戏中 3游戏结束
  11. setGameStatus(status) {
  12. wx.setStorageSync('game_status', status)
  13. },
  14. setToyItem(toy_item) {
  15. wx.setStorageSync('toy_item', toy_item)
  16. },
  17. setToySn(toy_sn) {
  18. wx.setStorageSync('toy_sn', toy_sn)
  19. },
  20. removeToyHex() {
  21. wx.removeStorageSync('toy_hex')
  22. },
  23. // 游戏模式: 1次数 2时间
  24. setMode(mode) {
  25. wx.setStorageSync('mode', mode)
  26. },
  27. setGameRecordId(param) {
  28. wx.setStorageSync('game_record_id', param)
  29. },
  30. // 游玩类型的时间30分钟或10分钟
  31. setOverPlayTime(param) {
  32. wx.setStorageSync('over_play_time', param)
  33. },
  34. setPlayTime(param) {
  35. wx.setStorageSync('play_time', param)
  36. },
  37. setPlayedTime(param) {
  38. wx.setStorageSync('played_time', param)
  39. },
  40. // 记录推到后台得时间
  41. setHideStatus($param) {
  42. wx.setStorageSync('hide_status', $param)
  43. },
  44. // 记录推到后台得时间
  45. setHideTime($param) {
  46. wx.setStorageSync('hide_time', $param)
  47. },
  48. //记录游戏数据
  49. setGameAttMedDatas($param) {
  50. wx.setStorageSync('game_data', $param)
  51. },
  52. // setIsNew($param) {
  53. // wx.setStorageSync('is_new', $param)
  54. // },
  55. // 脑机LED灯
  56. setLED(bool) {
  57. wx.setStorageSync('led_status', bool)
  58. },
  59. setGameCloseStatus(status) {
  60. wx.setStorageSync('game_close_status', status)
  61. },
  62. }
  63. const getters = {
  64. getGameStatus() {
  65. return wx.getStorageSync('game_status')
  66. },
  67. getToyItem() {
  68. return wx.getStorageSync('toy_item')
  69. },
  70. getToySn() {
  71. return wx.getStorageSync('toy_sn')
  72. },
  73. getMode() {
  74. return wx.getStorageSync('mode')
  75. },
  76. getGameRecordId() {
  77. return wx.getStorageSync('game_record_id')
  78. },
  79. // 游玩类型的时间30分钟或10分钟
  80. getOverPlayTime() {
  81. return wx.getStorageSync('over_play_time')
  82. },
  83. //该局游戏剩余可以游玩的时间
  84. getPlayTime() {
  85. return wx.getStorageSync('play_time')
  86. },
  87. //完了多长时间
  88. getPlayedTime() {
  89. return wx.getStorageSync('played_time')
  90. },
  91. // 获取一开始隐藏的时间
  92. getHideStatus() {
  93. return wx.getStorageSync('hide_status')
  94. },
  95. // 获取一开始隐藏的时间
  96. getHideTime() {
  97. return wx.getStorageSync('hide_time')
  98. },
  99. //记录游戏数据
  100. getGameAttMedDatas() {
  101. return wx.getStorageSync('game_data')
  102. },
  103. // //记录游戏数据
  104. // getIsNew() {
  105. // return wx.getStorageSync('is_new')
  106. // },
  107. // 脑机LED灯
  108. getLED() {
  109. return wx.getStorageSync('led_status')
  110. },
  111. getGameCloseStatus() {
  112. return wx.getStorageSync('game_close_status')
  113. },
  114. }
  115. const remover = {
  116. rmGameAttMedDatas() {
  117. wx.removeStorageSync('game_data')
  118. },
  119. rmHideTime() {
  120. wx.removeStorageSync('hide_time')
  121. },
  122. rmHideStatus() {
  123. wx.removeStorageSync('hide_status')
  124. }
  125. }
  126. export default {
  127. setters, getters, remover
  128. }