import request, {
  Method
} from '@/plugins/request.js';

// 查询会员订单列表
export function getOrderList (params) {
  return request({
    url: `/buyer/orders`,
    method: Method.GET,
    needToken: true,
    params
  });
}

/**
 * 订单明细
 * @param {orderSn} 订单编号
 */
export function orderDetail (orderSn) {
  return request({
    url: `/buyer/orders/${orderSn}`,
    method: Method.GET,
    needToken: true
  });
}

/**
 * 取消订单
 * @param {orderSn} 订单编号
 * @param reason 取消订单原因
 */
export function cancelOrder (params) {
  return request({
    url: `/buyer/orders/${params.orderSn}/cancel`,
    method: Method.POST,
    needToken: true,
    params
  });
}

/**
 * 删除订单
 * @param {orderSn} 订单编号
 */
export function delOrder (orderSn) {
  return request({
    url: `/buyer/orders/${orderSn}`,
    method: Method.DELETE,
    needToken: true
  });
}

/**
 * 确认收货
 * @param {orderSn} 订单编号
 */
export function sureReceived (orderSn) {
  return request({
    url: `/buyer/orders/${orderSn}/receiving`,
    method: Method.POST,
    needToken: true
  });
}

/**
 * 查询物流
 * @param {orderSn} 订单编号
 */
export function getTraces (orderSn) {
  return request({
    url: `/buyer/orders/getTraces/${orderSn}`,
    method: Method.POST,
    needToken: true
  });
}

/**
 * 评价列表
 *
 */
export function evolutionList (params) {
  return request({
    url: `/buyer/memberEvaluation`,
    method: Method.GET,
    needToken: true,
    params
  });
}

// 添加交易投诉对话
export function communication (params) {
  return request({
    url: `/buyer/complain/communication`,
    method: Method.POST,
    needToken: true,
    params
  });
}
