"use strict";

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

//获取附近商家
const getNear = (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);
    }
  );
};
// 热门搜索
const getSearchHotKeywords = (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 getCats = (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 getRecommends = (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 getCategory = (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 getSingleRecommends = (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);
    }
  );
};
// 查询商家的门店id
const getMerchantid = (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 getFoods = (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 getFeedbackstore = (
  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 getMapping = (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 getStoredetails = (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 getLikestatus = (
  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 getFollowstore = (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);
    }
  );
};
// 关注门店删除接口
const getDetelestore = (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 takeMessage = (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 takeFeebackfood = (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 takeCouponact = (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 obtainCoupon = (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);
    }
  );
};
//门店banner图的菜品
const obtainBannerfood = (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 getSign = (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 putCoupon = (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);
    },
    true
  );
};
// 获取用户所有优惠券
const getCouponall = (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 getSearchfood = (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 getLikestore = (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 getCommentlist = (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 getCheckaddress = (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 getSource = (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);
    }
  );
};

module.exports = {
  getNear: getNear,
  getSearch: getSearch,
  getBanner: getBanner,
  getCats: getCats,
  getSearchHotKeywords: getSearchHotKeywords,
  getRecommends: getRecommends,
  getCategory: getCategory,
  getSingleRecommends: getSingleRecommends,
  getMerchantid: getMerchantid,
  getFoods: getFoods,
  getFeedbackstore: getFeedbackstore,
  getMapping: getMapping,
  getStoredetails: getStoredetails,
  getLikestore: getLikestore,
  getFollowstore: getFollowstore,
  getDetelestore: getDetelestore,
  takeMessage: takeMessage,
  takeFeebackfood: takeFeebackfood,
  takeCouponact: takeCouponact,
  obtainCoupon: obtainCoupon,
  obtainBannerfood: obtainBannerfood,
  getSign: getSign,
  putCoupon: putCoupon,
  getCouponall: getCouponall,
  getSearchfood: getSearchfood,
  getLikestatus: getLikestatus,
  getCommentlist: getCommentlist,
  getCheckaddress: getCheckaddress,
  getSource: getSource,
};
