import http from "../utils/http";

// 服务器存活检测接口，返回200表示存活，否则表示不存活
export const Ping = {
  get: function () {
    return http.get("/api/alive/ping");
  },
  post: function (data) {
    return http.post("/api/alive/ping", data);
  },
}

// 小程序体量限制1M，图片必须放在外部cdn上
// 七牛云存储，获取token
export const Qiniu = {
  token: function () {
    // TODO: get token from app first, if expired, request new
    return http.post("/qiniu/token");
  },
}

// HomepageApiController
export const HomepageApi = {
  /** 
   * 返回示例：{
    "bannerList": [
      {
        "createUser": "",
        "createTime": "",
        "updateUser": "",
        "updateTime": "",
        "remark": "",
        "params": {
          "": {}
        },
        "bannerId": 0,
        "bannerUrl": "",
        "bannerType": "",
        "prodId": 0,
        "newsId": 0,
        "sort": 0,
        "delFlag": ""
      }
    ]
  }
  */
  getBanners: function (payload) {
    return http.post("/api/store/homepage/banners", {
      ...payload,
    });
  },

  /**
   * 返回示例：{
    "ipInfoList": [
      {
        "createUser": "",
        "createTime": "",
        "updateUser": "",
        "updateTime": "",
        "remark": "",
        "params": {
          "": {}
        },
        "ipId": 0,
        "ipName": "",
        "ipUrl": "",
        "colorNo": "",
        "sort": 0,
        "delFlag": ""
      }
    ]
  }
  */
  getIpInfos: function (payload) {
    return http.post("/api/store/homepage/ipInfos", {
      ...payload,
    });
  },

  /**
   * 返回示例：{
    "titleList": [
      ""
    ]
  }
  */
  getTitles: function (payload) {
    return http.post("/api/store/homepage/titles", {
      ...payload,
    });
  },

  /**
   * 返回示例：{
    "prodList": [
      {
        "id": 0,
        "prodId": 0,
        "sort": 0,
        "prodPicList": [
          {
            "createUser": "",
            "createTime": "",
            "updateUser": "",
            "updateTime": "",
            "remark": "",
            "params": {
              "": {}
            },
            "id": 0,
            "prodId": 0,
            "picUrl": "",
            "sort": 0,
            "delFlag": ""
          }
        ]
      }
    ]
  }
  */
  getLeftProds: function (payload) {
    return http.post("/api/store/homepage/leftProds", {
      ...payload,
    });
  },

  /**
   * 返回示例：{
    "prodList": [
      {
        "id": 0,
        "prodId": 0,
        "sort": 0,
        "prodPicList": [
          {
            "createUser": "",
            "createTime": "",
            "updateUser": "",
            "updateTime": "",
            "remark": "",
            "params": {
              "": {}
            },
            "id": 0,
            "prodId": 0,
            "picUrl": "",
            "sort": 0,
            "delFlag": ""
          }
        ]
      }
    ]
  }
  */
  getMiddleProds: function (payload) {
    return http.post("/api/store/homepage/middleProds", {
      ...payload,
    });
  },

  /**
   * 返回示例：{
    "prodList": [
      {
        "id": 0,
        "prodId": 0,
        "sort": 0,
        "prodPicList": [
          {
            "createUser": "",
            "createTime": "",
            "updateUser": "",
            "updateTime": "",
            "remark": "",
            "params": {
              "": {}
            },
            "id": 0,
            "prodId": 0,
            "picUrl": "",
            "sort": 0,
            "delFlag": ""
          }
        ]
      }
    ]
  }
  */
  getRightProds: function (payload) {
    return http.post("/api/store/homepage/rightProds", {
      ...payload,
    });
  },

  /**
   * 返回示例：{
    "prodClassList": [
      {
        "createUser": "",
        "createTime": "",
        "updateUser": "",
        "updateTime": "",
        "remark": "",
        "params": {
          "": {}
        },
        "prodClassId": 0,
        "className": "",
        "classUrl": "",
        "sort": 0,
        "delFlag": ""
      }
    ]
  }
  */
  getProdClasses: function (payload) {
    return http.post("/api/store/homepage/prodClasses", {
      ...payload,
    });
  },
}