homeAPI.dart 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import 'package:dio/dio.dart';
  2. import 'package:farmer_client/utils/Request.dart';
  3. import 'package:fluttertoast/fluttertoast.dart';
  4. /**
  5. * banner轮播图
  6. * @param {*} data
  7. * @returns
  8. */
  9. Future getHomeBanner(String position) async {
  10. return request('/banner',
  11. options: Options(method: 'GET'), data: {'position': position})
  12. .catchError((error) => {
  13. Fluttertoast.showToast(msg: error.error['message']),
  14. });
  15. }
  16. /**
  17. * 农机列表
  18. * @param {*} data
  19. * @returns
  20. */
  21. Future getMachinery( params) async {
  22. return request('/machinery', options: Options(method: 'GET'), queryParameters:params).catchError((error) => {
  23. Fluttertoast.showToast(msg: error.error['message']),
  24. });
  25. }
  26. /**
  27. * 农机列表搜索
  28. * @param {*} data
  29. * @returns
  30. */
  31. Future searchMachinery(
  32. String location,
  33. String? q,
  34. ) async {
  35. return request('/machinery',
  36. options: Options(method: 'GET'),
  37. queryParameters: {
  38. 'location': location,
  39. 'q': q,
  40. },
  41. data: {
  42. 'q': q,
  43. 'location': location
  44. }).catchError((error) => {
  45. Fluttertoast.showToast(msg: error.error['message']),
  46. });
  47. }
  48. /**
  49. * 农机分类
  50. * @param {*} data
  51. * @returns
  52. */
  53. Future typeMachinery(
  54. String location,
  55. String typeId,
  56. ) async {
  57. return request('/machinery',
  58. options: Options(method: 'GET'),
  59. queryParameters: {
  60. 'location': location,
  61. 'typeId': typeId,
  62. },
  63. data: {
  64. 'typeId': typeId,
  65. 'location': location
  66. }).catchError((error) => {
  67. Fluttertoast.showToast(msg: error.error['message']),
  68. });
  69. }
  70. /**
  71. * 农机详情
  72. * @param {*} data
  73. * @returns
  74. */
  75. Future getMachineryInfo(String id, String location, bool attached) async {
  76. return request('/machinery-summary/$id',
  77. options: Options(method: 'GET'),
  78. queryParameters: {'location': location, 'attached': attached})
  79. .catchError((error) => {
  80. Fluttertoast.showToast(msg: error.error['message']),
  81. });
  82. }
  83. /**
  84. * 农机分类Tab列查询
  85. * @param {*} data
  86. * @returns
  87. */
  88. Future getMachineryType() async {
  89. return request('/machinery-type', options: Options(method: 'GET'));
  90. }