移动储能车V1版本
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // 启停接口
  2. export const control = async (data) => {
  3. try {
  4. const response = await uni.$http.post(`/api/v1/items/rt/${data.id}`,data,{'Content-Type': "application/json;charset=utf-8","Authorization":`JWT ${uni.getStorageSync('token')}` });
  5. console.log(response);
  6. if (response.statusCode != 200||response.data.error=='token过期且未提供刷新令牌') {
  7. // uni.showToast({
  8. // title: '数据请求失败! ',
  9. // duration: 1500,
  10. // icon: 'none',
  11. // });
  12. uni.removeStorageSync('token');
  13. login();
  14. return response.data;
  15. }
  16. return response.data;
  17. } catch (error) {
  18. console.log(error);
  19. // uni.showToast({
  20. // title: '网络请求失败! ',
  21. // duration: 1500,
  22. // icon: 'none',
  23. // });
  24. login();
  25. return response.data;
  26. }
  27. };
  28. // 二级页面信息
  29. export const getuidatas = async (data) => {
  30. try {
  31. const response = await uni.$http.get('/api/v1/uidatas/rt/uis/3224a3eb-2375-4dfc-99ce-b182edd30996',data,{'Content-Type': "application/json;charset=utf-8","Authorization":`JWT ${uni.getStorageSync('token')}` });
  32. console.log(response);
  33. if (response.statusCode != 200||response.data.error=='token过期且未提供刷新令牌') {
  34. // uni.showToast({
  35. // title: '数据请求失败! ',
  36. // duration: 1500,
  37. // icon: 'none',
  38. // });
  39. uni.removeStorageSync('token');
  40. login();
  41. return response.data;
  42. }
  43. return response.data;
  44. } catch (error) {
  45. // console.error('Network request failed:', error);
  46. console.log(error);
  47. // uni.showToast({
  48. // title: '网络请求失败! ',
  49. // duration: 1500,
  50. // icon: 'none',
  51. // });
  52. login();
  53. return response.data;
  54. }
  55. };
  56. // 系统故障列表
  57. export const getfaultsList = async (data) => {
  58. try {
  59. // console.log(uni.getStorageSync('token'));
  60. const response = await uni.$http.get('/api/v1/faults',data,{'Content-Type': "application/json;charset=utf-8","Authorization":`JWT ${uni.getStorageSync('token')}` });
  61. console.log(response.data);
  62. if (response.statusCode != 200||response.data.error=='token过期且未提供刷新令牌') {
  63. // uni.showToast({
  64. // title: '数据请求失败! ',
  65. // duration: 1500,
  66. // icon: 'none',
  67. // });
  68. uni.removeStorageSync('token');
  69. login();
  70. return response.data;
  71. }
  72. return response.data;
  73. } catch (error) {
  74. console.error('Network request failed:', error);
  75. console.log(error);
  76. // uni.showToast({
  77. // title: '网络请求失败! ',
  78. // duration: 1500,
  79. // icon: 'none',
  80. // });
  81. uni.removeStorageSync('token');
  82. login();
  83. return response.data;
  84. }
  85. };
  86. // 登录接口
  87. export const login = async (start,count) => {
  88. try {
  89. console.log('login request');
  90. const response = await uni.$http.post('/api/v1/login',
  91. {name: "dexnui", pwd: "dexn1001"},{'Content-Type': 'application/json;charset=utf-8'});
  92. console.log(response);
  93. if (response.statusCode != 200||response.data.error=='token过期且未提供刷新令牌') {
  94. // uni.showToast({
  95. // title: '数据请求失败! ',
  96. // duration: 1500,
  97. // icon: 'none',
  98. // });
  99. return response.data;
  100. }
  101. console.log(response.data);
  102. uni.setStorageSync('token', response.data.data.token);
  103. return response.data;
  104. } catch (error) {
  105. // console.error('Network request failed:', error);
  106. // uni.showToast({
  107. // title: '网络请求失败! ',
  108. // duration: 1500,
  109. // icon: 'none',
  110. // });
  111. return response.data;
  112. }
  113. };