"use strict";

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

// 点餐页的请求

//获取地区列表
const getStore = (data, urldata, message, success, fail) => {
  network.requestLoadingno(
    baseUrl.waimaiUrl + "/client/store/chinese",
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
//获取门店列表
const getShop = (url, urldata, data, message, success, fail) => {
  network.requestLoadingno(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
//获取常去门店列表
const getHistoryshop = (url, urldata, data, message, success, fail) => {
  network.requestLoadingno(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
//获取最近门店列表
const getLate = (url, urldata, data, message, success, fail) => {
  network.requestLoadingno(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
//获取banner列表
const getBanner = (url, urldata, data, message, success, fail, unHideLoad) => {
  network.requestLoadingno(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    },
    unHideLoad
  );
};
//获取商品列表
const getCommodity = (url, urldata, data, message, success, fail) => {
  network.requestLoadingno(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};

// 获得商品推介
const getEnterprise = (url, urldata, data, message, success, fail) => {
  network.requestLoadingno(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
// 获得门店信息的推介
const getMessage = (url, urldata, data, message, success, fail) => {
  network.requestLoadingno(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
// 获得搜索信息
const getSearch = (url, urldata, data, message, success, fail) => {
  network.requestLoadingno(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
// 获得商品sku
const getSku = (url, urldata, data, message, success, fail) => {
  network.requestLoadingno(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
// 获得满减列表
const getReduction = (
  url,
  urldata,
  data,
  message,
  success,
  fail,
  unHideLoad
) => {
  network.requestLoadingno(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    },
    unHideLoad
  );
};
//登录手机接口
const takePhone = (url, urldata, data, message, success, fail) => {
  network.requestLoadingno(
    url,
    urldata,
    {
      ...data,
    },
    Method.POST,
    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.requestLoadingno(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
//根据菜品模板获得相应的门店菜品
const takeMappingfood = (url, urldata, data, message, success, fail) => {
  network.requestLoadingno(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
//菜品模板详情
const takeFoodtemplate = (url, urldata, data, message, success, fail) => {
  network.requestLoadingno(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
//菜品模板详情
const takeV2food = (url, urldata, data, message, success, fail) => {
  network.requestLoadingno(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
//折扣菜品详情
const takeDiscountfoods = (url, urldata, data, message, success, fail) => {
  network.requestLoadingno(
    url,
    urldata,
    {
      ...data,
    },
    Method.GET,
    message,
    function (res) {
      typeof success == "function" && success(res);
    },
    function (ex) {
      // 失败执行的方法
      typeof fail == "function" && fail(ex);
    }
  );
};
module.exports = {
  getStore: getStore,
  getShop: getShop,
  getLate: getLate,
  getCommodity: getCommodity,
  getEnterprise: getEnterprise,
  getMessage: getMessage,
  getSearch: getSearch,
  getSku: getSku,
  getReduction: getReduction,
  getBanner: getBanner,
  takePhone: takePhone,
  getHistoryshop: getHistoryshop,
  takeLuckycoupon: takeLuckycoupon,
  takeMappingfood: takeMappingfood,
  takeFoodtemplate: takeFoodtemplate,
  takeV2food: takeV2food,
  takeDiscountfoods: takeDiscountfoods,
};
