

import 'package:dio/dio.dart';
import 'package:farmer_client/utils/Request.dart';
import 'package:fluttertoast/fluttertoast.dart';


/**
 * 订单列表
 * @param {*} data
 * @returns
 */
Future getOrderList(bool mine)async{
  return request('/order',options: Options(method: 'GET'),queryParameters: { 'mine': mine}).catchError((error) =>
  { Fluttertoast.showToast(
      msg: error.error['message']
  ),});

}


/**
 * 订单详情
 * @param {*} data
 * @returns
 */
Future orderInfo(String id)async{
  return request('/order/$id',options: Options(method: 'GET'),).catchError((error) =>
  { Fluttertoast.showToast(
      msg: error.error['message']
  ),});

}


/**
 * 生成订单
 * @param {*} data
 * @returns
 */

Future generateOrder(item)async{
  return request('/order',options: Options(method: 'POST'),data: item).catchError((error) =>
  { Fluttertoast.showToast(
      msg: error.error['message']
  ),});

}



/**
 * 删除订单
 * @param {*} data
 * @returns
 */
Future orderDelete(String id)async{
  return request('/order/$id',options: Options(method: 'DELETE')).catchError((error) =>
  { Fluttertoast.showToast(
      msg: error.error['message']
  ),});
}


/**
 * --------------订单退款-----------------
 * @param {*} data
 * @returns
 */
Future orderRefund (String id)async{
  return request('/order/$id/refund',options: Options(method: 'PUT')).catchError((error) =>
  { Fluttertoast.showToast(
      msg: error.error['message']
  ),});
}




/**
 * 评价订单
 * @param {*} data
 * @returns
 */

Future orderEvaluation (String orderId,num score,String content)async{
  return request('/evaluation',options: Options(method: 'POST'),data: {'orderId':orderId,'score':score,'content':content}).catchError((error) =>
  { Fluttertoast.showToast(
      msg: error.error['message']
  ),});
}

