order.dart 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import 'index.dart';
  2. import '../utils/index.dart';
  3. import '../models/index.dart';
  4. extension OrderAPI on Network {
  5. // confirm order
  6. Future<ConfirmInfo> confirmOrder(dynamic cartId) async {
  7. var resp = await Request.post('order/confirm', params: {"cartId": cartId});
  8. return ConfirmInfo.fromJson(resp);
  9. }
  10. // compute order info
  11. Future<ComputeInfo> computedOrder(String id, { int addressId, int couponId = 0,
  12. int shopType = 1, String payType, double useIntegral }) async {
  13. var data = {
  14. "addressId": addressId,
  15. "couponId": couponId,
  16. "payType": payType,
  17. "shipping_type": shopType,
  18. "useIntegral": useIntegral
  19. };
  20. var resp = await Request.post("order/computed/$id", params: data);
  21. return ComputeInfo.fromJson(resp);
  22. }
  23. // get order detail info
  24. Future orderDetail() async {
  25. var resp = await Request.post("order/detail/");
  26. }
  27. // pay order from id
  28. Future<OrderInfo> payOrder({String payType, String orderId}) async {
  29. var data = {
  30. "from": "app",
  31. "payType": payType,
  32. "uni": orderId
  33. };
  34. var resp = await Request.post("order/pay", params: data);
  35. return OrderInfo.fromJson(resp);
  36. }
  37. // create order
  38. Future<OrderInfo> createOrder({String orderKey, String payType, int integral = 0, int address}) async {
  39. var data = {
  40. "addressId": address,
  41. "bargainId": 0,
  42. "combinationId": 0,
  43. "couponId": 0,
  44. "from": "app",
  45. "mark": "",
  46. "payType": payType,
  47. "phone": "",
  48. "pinkId": 0,
  49. "real_name": "",
  50. "seckill_id": 0,
  51. "shipping_type": 1,
  52. "useIntegral": integral,
  53. };
  54. var resp = await Request.post('order/create/$orderKey', params: data);
  55. return OrderInfo.fromJson(resp);
  56. }
  57. Future getOrderList({int page = 1, int limit=20, int type = 0}) async {
  58. var resp = await Request.get("order/list?page=$page&limit=$limit&type=$type");
  59. }
  60. }