homeAPI.dart 2.0KB

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