123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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',
  23. options: Options(method: 'GET'), queryParameters: params)
  24. .catchError((error) => {
  25. Fluttertoast.showToast(msg: error.error['message']),
  26. });
  27. }
  28. /**
  29. * 农机列表搜索
  30. * @param {*} data
  31. * @returns
  32. */
  33. Future searchMachinery(params) async {
  34. return request('/machinery',
  35. options: Options(method: 'GET'),
  36. queryParameters: params,
  37. data: params)
  38. .catchError((error) => {
  39. Fluttertoast.showToast(msg: error.error['message']),
  40. });
  41. }
  42. /**
  43. * 农机分类
  44. * @param {*} data
  45. * @returns
  46. */
  47. Future typeMachinery(
  48. String location,
  49. String typeId,
  50. ) async {
  51. return request('/machinery',
  52. options: Options(method: 'GET'),
  53. queryParameters: {
  54. 'location': location,
  55. 'typeId': typeId,
  56. },
  57. data: {
  58. 'typeId': typeId,
  59. 'location': location
  60. }).catchError((error) => {
  61. Fluttertoast.showToast(msg: error.error['message']),
  62. });
  63. }
  64. /**
  65. * 农机详情
  66. * @param {*} data
  67. * @returns
  68. */
  69. Future getMachineryInfo(String id, String location, bool attached) async {
  70. return request('/machinery-summary/$id',
  71. options: Options(method: 'GET'),
  72. queryParameters: {'location': location, 'attached': attached});
  73. }
  74. /**
  75. * 农机分类Tab列查询
  76. * @param {*} data
  77. * @returns
  78. */
  79. Future getMachineryType(params) async {
  80. return request('/machinery-type',
  81. options: Options(method: 'GET'), queryParameters: params);
  82. }