homeAPI.dart 2.1KB

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