"use strict";

const Method = require("./method.js").Method;
var network = require("../utils/network.js");
const baseUrl = require("./index.js").config;
var app = getApp();

// 新增地址请求接口
const getAddress = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.POST,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
// 地址列表请求接口
const getRequire = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
// 地址列表删除接口
const getDetele = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.DELETE,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
// 根据饭盒生成订单
const getOrder = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.POST,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    },
    true
  );
};
//提交外卖订单
const takeOrder = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.POST,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    },
    true
  );
};
//提交自提订单
const takeZitiorder = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.POST,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    },
    true
  );
};
//支付
const takePayment = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.PUT,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};

//获得当前订单
const takeCurrent = (
  url,
  urldata,
  data,
  message,
  success,
  fail,
  unload = false
) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    },
    unload
  );
};

//获得外卖订单详情
const takeCurrentdetail = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    },
    true
  );
};
//历史订单
const takeHistory = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
//获得自提订单详情
const takeSelfdetail = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
//取消订单
const takeCancel = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.PUT,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
//退款订单
const takeRefund = (url, urldata, data, message, success, fail, unHideLoad) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.POST,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    },
    unHideLoad
  );
};
//退款订单列表
const takeRefundlist = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
//再来一单
const takeAgain = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.POST,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
//登录手机接口
const takePhone = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.POST,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
//设置默认地址
const takeDefault = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.PUT,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
// //催单
const getReminder = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.PUT,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
// 获取单个收货地址
const getRditAddress = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};

// 获取单个收货地址
const putRditAddress = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.PUT,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};

// 获取反馈
const gettFeedback = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};

// 反馈
const putFeedback = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.POST,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
// 我的反馈列表
const getRetroaction = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
// 我的反向经纬搜索
const getPosition = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
// 搜索城市
const getCitylist = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
const getAliOssSign = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
//自提柜
const getMention = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
//支付红包优惠劵id的获取
const takeLuckycoupon = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
//领取支付红包的优惠劵
const drawCoupon = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.POST,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
//支付成功
const takeSuccesss = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.POST,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
//获得分享图片
const takeActivity = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    },
    true
  );
};
// 预订单appointmentTime
const takeappointmentTime = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    },
    true
  );
};
// 配送减免
const takeReductiondelivery = (
  url,
  urldata,
  data,
  message,
  success,
  fail,
  unHideLoad
) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    },
    unHideLoad
  );
};
// 支付前检查
const takePrepay = (url, urldata, data, message, success, fail) => {
  network.requestLoading(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
module.exports = {
  getAddress: getAddress,
  getRequire: getRequire,
  getDetele: getDetele,
  getOrder: getOrder,
  takeOrder: takeOrder,
  takePayment: takePayment,
  takeCurrent: takeCurrent,
  takeCurrentdetail: takeCurrentdetail,
  takeHistory: takeHistory,
  takeSelfdetail: takeSelfdetail,
  takeCancel: takeCancel,
  takeZitiorder: takeZitiorder,
  takeRefund: takeRefund,
  takeRefundlist: takeRefundlist,
  takeAgain: takeAgain,
  takePhone: takePhone,
  takeDefault: takeDefault,
  getReminder: getReminder,
  getRditAddress: getRditAddress,
  putRditAddress: putRditAddress,
  gettFeedback: gettFeedback,
  putFeedback: putFeedback,
  getRetroaction: getRetroaction,
  getPosition: getPosition,
  getCitylist: getCitylist,
  getAliOssSign: getAliOssSign,
  getMention: getMention,
  takeLuckycoupon: takeLuckycoupon,
  drawCoupon: drawCoupon,
  takeSuccesss: takeSuccesss,
  takeActivity: takeActivity,
  takeappointmentTime: takeappointmentTime,
  takeReductiondelivery: takeReductiondelivery,
  takePrepay: takePrepay,
};
