/*
 * @Author: gzd
 * @Date: 2021-04-07 11:06:09
 * @Description:
 */
/**
 * 所有跟商品相关的接口
 */

import { HttpResponse } from '@/@type';
import Axios from './axios';

const commodity = {
  commodityList: '/fighter-library/web/order/getRecommendPackages',
  detailsHead: '/fighter-library/web/order/getRecommendPackageDetail',
  book: '/fighter-library/web/order/queryRecommendPackageBookByPage',
  submit: '/fighter-library/web/order/submitOrder',
};

interface list {
  pageNum: number;
  pageSize: number;
}

interface head {
  packageId: string;
}

interface bookData {
  packageId: string;
  pageNum: number;
  pageSize: number;
}

interface order {
  provinceId: number;
  cityId: number;
  areaId: number;
  discountAmount: number;
  packageId: string;
  realPayAmount: number;
  receiverAddress: string;
  receiverMobile: string;
  receiverName: string;
  totalAmount: number;
  version: string;
  orderRemark?: string;
}

class wares {
  static getList(params: list): Promise<HttpResponse> {
    return Axios(commodity.commodityList, {
      method: 'get',
      params: params,
    });
  }
  static getHeadDet(params: head): Promise<HttpResponse> {
    return Axios(commodity.detailsHead, {
      method: 'get',
      params: params,
    });
  }
  static getAllBook(params: bookData): Promise<HttpResponse> {
    return Axios(commodity.book, {
      method: 'get',
      params: params,
    });
  }
  static submitOrder(params: order): Promise<HttpResponse> {
    return Axios(commodity.submit, {
      method: 'post',
      data: params,
    });
  }
}
export default wares;
