orderAPI.dart 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import 'package:dio/dio.dart';
  2. import 'package:farmer_client/utils/Request.dart';
  3. import 'package:fluttertoast/fluttertoast.dart';
  4. /**
  5. * 订单列表
  6. * @param {*} data
  7. * @returns
  8. */
  9. Future getOrderList(params) async {
  10. return request('/order',
  11. options: Options(method: 'GET'), queryParameters: params)
  12. .catchError((error) => {
  13. Fluttertoast.showToast(msg: error.error['message']),
  14. });
  15. }
  16. /**
  17. * 订单详情
  18. * @param {*} data
  19. * @returns
  20. */
  21. Future orderInfo(String id) async {
  22. return request(
  23. '/order/$id',
  24. options: Options(method: 'GET'),
  25. ).catchError((error) => {
  26. Fluttertoast.showToast(msg: error.error['message']),
  27. });
  28. }
  29. /**
  30. * 生成订单
  31. * @param {*} data
  32. * @returns
  33. */
  34. Future generateOrder(item) async {
  35. return request('/order', options: Options(method: 'POST'), data: item)
  36. .catchError((error) => {
  37. Fluttertoast.showToast(msg: error.error['message']),
  38. });
  39. }
  40. /**
  41. * 删除订单
  42. * @param {*} data
  43. * @returns
  44. */
  45. Future orderDelete(String id) async {
  46. return request('/order/$id', options: Options(method: 'DELETE'))
  47. .catchError((error) => {
  48. Fluttertoast.showToast(msg: error.error['message']),
  49. });
  50. }
  51. /**
  52. * --------------订单退款-----------------
  53. * @param {*} data
  54. * @returns
  55. */
  56. Future orderRefund(String id) async {
  57. return request('/order/$id/refund', options: Options(method: 'PUT'))
  58. .catchError((error) => {
  59. Fluttertoast.showToast(msg: error.error['message']),
  60. });
  61. }
  62. /**
  63. * 评价订单
  64. * @param {*} data
  65. * @returns
  66. */
  67. Future orderEvaluation(String orderId, num score, String content) async {
  68. return request('/evaluation',
  69. options: Options(method: 'POST'),
  70. data: {'orderId': orderId, 'score': score, 'content': content})
  71. .catchError((error) => {
  72. Fluttertoast.showToast(msg: error.error['message']),
  73. });
  74. }