game.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import fly from "./main";
  2. // 设备列表
  3. export function game_devices($params = {}) {
  4. $params["access_token"] = wx.getStorageSync("token");
  5. return fly.post("game/device-list", $params);
  6. }
  7. // 开始游戏
  8. export function gameStart($params) {
  9. return fly.post("game/game-start", $params);
  10. }
  11. //结束游戏
  12. export function gameEnd($params) {
  13. $params["access_token"] = wx.getStorageSync("token");
  14. return fly.post("game/game-over", $params);
  15. }
  16. //游戏记录详情
  17. export function gameDetail($record_id) {
  18. let $params = {};
  19. $params["game_record_id"] = $record_id;
  20. // $params["game_record_id"] = "9389";
  21. $params["access_token"] = wx.getStorageSync("token");
  22. return fly.post("game/game-detail", $params);
  23. }
  24. //折线图图表
  25. export function gameLineChart($params) {
  26. $params["access_token"] = wx.getStorageSync("token");
  27. return fly.post("game/line", $params);
  28. }
  29. // 添加折线图的点
  30. export function gameAddLine($params) {
  31. $params["access_token"] = wx.getStorageSync("token");
  32. return fly.post("game/add-line", $params);
  33. }
  34. //获取游戏记录
  35. export function gameList($params = {}) {
  36. $params["access_token"] = wx.getStorageSync("token");
  37. return fly.post("game/game-list", $params);
  38. }
  39. //2021年10月21日15:08:57
  40. //获取设备
  41. export function getDeviceBySn($sn) {
  42. let $params = {
  43. "access_token": wx.getStorageSync("token"),
  44. "sn": $sn
  45. }
  46. return fly.post("equipment/equipment-search", $params)
  47. }
  48. //2021年10月22日11:11:03
  49. // 写入设备
  50. export function setDeviceInDb($this, $deviceId) {
  51. let $params = $this.device_data;
  52. $params["access_token"] = wx.getStorageSync("token")
  53. wx.getSystemInfo({
  54. success(res) {
  55. switch (res.platform) {
  56. case "android":
  57. default:
  58. $params['is_android'] = 0;
  59. break;
  60. case "ios":
  61. $params['is_android'] = 2;
  62. break;
  63. }
  64. if (res.platform == "ios") {
  65. $params['ios_device_id'] = $deviceId
  66. } else {
  67. $params['device_id'] = $deviceId;
  68. }
  69. }
  70. })
  71. return fly.post("https://testadmin.shuimuai.com/equipment/factory", $params)
  72. }