"use strict";
const common_vendor = require("../common/vendor.js");
const api_request = require("./request.js");
const api_config = require("./config.js");
const { endpoints } = api_config.config;
const userService = {
  // 登录
  login: (data) => api_request.request.post(endpoints.USER.LOGIN, data),
  // 注册
  register: (data) => api_request.request.post(endpoints.USER.REGISTER, data),
  // 获取用户信息
  getProfile: () => api_request.request.get(endpoints.USER.PROFILE),
  // 更新用户信息
  updateProfile: (data) => api_request.request.put(endpoints.USER.UPDATE_PROFILE, data),
  // 上传头像
  uploadAvatar: (filePath) => api_request.request.upload(endpoints.USER.UPLOAD_AVATAR, filePath),
  // 退出登录
  logout: () => {
    common_vendor.index.removeStorageSync("token");
    common_vendor.index.removeStorageSync("refreshToken");
    return Promise.resolve();
  }
};
const travelService = {
  // 获取旅行计划列表
  getList: (params = {}) => api_request.request.get(endpoints.TRAVEL.LIST, params),
  // 获取旅行计划详情
  getDetail: (id) => api_request.request.get(`${endpoints.TRAVEL.DETAIL}/${id}`),
  // 创建旅行计划
  create: (data) => api_request.request.post(endpoints.TRAVEL.CREATE, data),
  // 更新旅行计划
  update: (id, data) => api_request.request.put(`${endpoints.TRAVEL.UPDATE}/${id}`, data),
  // 删除旅行计划
  deletePlan: (id) => api_request.request.delete(`${endpoints.TRAVEL.DELETE}/${id}`),
  // 加入旅行计划
  joinPlan: (travelId) => api_request.request.post(`${endpoints.TRAVEL.JOIN}/${travelId}`),
  // 退出旅行计划
  quitPlan: (travelId) => api_request.request.post(`${endpoints.TRAVEL.QUIT}/${travelId}`),
  // 点赞旅行计划
  likePlan: (travelId) => api_request.request.post(`${endpoints.TRAVEL.LIKE}/${travelId}`),
  // 取消点赞旅行计划
  unlikePlan: (travelId) => api_request.request.post(`${endpoints.TRAVEL.UNLIKE}/${travelId}`),
  // 添加评论
  addComment: (travelId, data) => api_request.request.post(`${endpoints.TRAVEL.COMMENT}/${travelId}`, data),
  // 获取评论列表
  getComments: (travelId, params = {}) => api_request.request.get(`${endpoints.TRAVEL.COMMENTS}/${travelId}`, params),
  // 获取我的旅行计划
  getMyPlans: (params = {}) => api_request.request.get(endpoints.TRAVEL.MY_PLANS, params),
  // 搜索旅行计划
  search: (keyword, params = {}) => api_request.request.get(endpoints.TRAVEL.SEARCH, { keyword, ...params })
};
const animalService = {
  // 获取动物列表
  getList: (params = {}) => api_request.request.get(endpoints.ANIMAL.LIST, params),
  // 获取动物详情
  getDetail: (id) => api_request.request.get(`${endpoints.ANIMAL.DETAIL}/${id}`),
  // 认养动物
  adopt: (animalId, data) => api_request.request.post(`${endpoints.ANIMAL.ADOPT}/${animalId}`, data),
  // 获取我的动物
  getMyAnimals: (params = {}) => api_request.request.get(endpoints.ANIMAL.MY_ANIMALS, params),
  // 获取动物分类
  getCategories: () => api_request.request.get(endpoints.ANIMAL.CATEGORIES)
};
const flowerService = {
  // 获取花束列表
  getList: (params = {}) => api_request.request.get(endpoints.FLOWER.LIST, params),
  // 获取花束详情
  getDetail: (id) => api_request.request.get(`${endpoints.FLOWER.DETAIL}/${id}`),
  // 下单
  order: (data) => api_request.request.post(endpoints.FLOWER.ORDER, data),
  // 获取我的订单
  getMyOrders: (params = {}) => api_request.request.get(endpoints.FLOWER.MY_ORDERS, params),
  // 获取花束分类
  getCategories: () => api_request.request.get(endpoints.FLOWER.CATEGORIES)
};
const orderService = {
  // 获取订单列表
  getList: (params = {}) => api_request.request.get(endpoints.ORDER.LIST, params),
  // 获取订单详情
  getDetail: (id) => api_request.request.get(`${endpoints.ORDER.DETAIL}/${id}`),
  // 取消订单
  cancel: (id) => api_request.request.post(`${endpoints.ORDER.CANCEL}/${id}`),
  // 支付订单
  pay: (id) => api_request.request.post(`${endpoints.ORDER.PAY}/${id}`),
  // 确认收货
  confirm: (id) => api_request.request.post(`${endpoints.ORDER.CONFIRM}/${id}`)
};
const paymentService = {
  // 创建支付
  create: (data) => api_request.request.post(endpoints.PAYMENT.CREATE, data),
  // 查询支付状态
  query: (paymentId) => api_request.request.get(`${endpoints.PAYMENT.QUERY}/${paymentId}`),
  // 退款
  refund: (paymentId, data) => api_request.request.post(`${endpoints.PAYMENT.REFUND}/${paymentId}`, data)
};
const systemService = {
  // 获取系统配置
  getConfig: () => api_request.request.get(endpoints.SYSTEM.CONFIG),
  // 获取公告列表
  getNotices: (params = {}) => api_request.request.get(endpoints.SYSTEM.NOTICE, params),
  // 提交反馈
  submitFeedback: (data) => api_request.request.post(endpoints.SYSTEM.FEEDBACK, data)
};
const homeService = {
  // 获取首页数据
  getHomeData: () => api_request.request.get("/home/data"),
  // 获取轮播图
  getBanners: () => api_request.request.get("/home/banners"),
  // 获取推荐旅行计划
  getRecommendedTravels: () => api_request.request.get("/home/recommended-travels"),
  // 获取热门动物
  getHotAnimals: () => api_request.request.get("/home/hot-animals"),
  // 获取精选花束
  getFeaturedFlowers: () => api_request.request.get("/home/featured-flowers")
};
const searchService = {
  // 全局搜索
  search: (params = {}) => api_request.request.get(endpoints.SEARCH.GLOBAL, params),
  // 获取搜索建议
  getSuggestions: (keyword) => api_request.request.get(endpoints.SEARCH.SUGGESTIONS, { keyword }),
  // 旅行计划搜索
  searchTravel: (params = {}) => api_request.request.get(endpoints.SEARCH.TRAVEL, params),
  // 动物搜索
  searchAnimal: (params = {}) => api_request.request.get(endpoints.SEARCH.ANIMAL, params),
  // 花束搜索
  searchFlower: (params = {}) => api_request.request.get(endpoints.SEARCH.FLOWER, params),
  // 用户搜索
  searchUser: (params = {}) => api_request.request.get(endpoints.SEARCH.USER, params)
};
const promotionService = {
  // 获取推广数据
  getPromotionData: () => api_request.request.get(endpoints.PROMOTION.DATA),
  // 获取邀请记录
  getRecentRecords: (params = {}) => api_request.request.get(endpoints.PROMOTION.RECORDS, params),
  // 获取所有邀请记录
  getAllRecords: (params = {}) => api_request.request.get(endpoints.PROMOTION.ALL_RECORDS, params),
  // 生成邀请二维码
  generateQRCode: () => api_request.request.get(endpoints.PROMOTION.QRCODE),
  // 获取奖励明细
  getRewardDetails: (params = {}) => api_request.request.get(endpoints.PROMOTION.REWARD_DETAILS, params),
  // 提现申请
  applyWithdraw: (data) => api_request.request.post(endpoints.PROMOTION.WITHDRAW, data),
  // 获取提现记录
  getWithdrawRecords: (params = {}) => api_request.request.get(endpoints.PROMOTION.WITHDRAW_RECORDS, params)
};
const authService = {
  // 手机号登录
  phoneLogin: (data) => api_request.request.post(endpoints.AUTH.PHONE_LOGIN, data),
  // 微信登录
  wechatLogin: (data) => api_request.request.post(endpoints.AUTH.WECHAT_LOGIN, data),
  // 密码登录
  passwordLogin: (data) => api_request.request.post(endpoints.AUTH.PASSWORD_LOGIN, data),
  // 发送短信验证码
  sendSmsCode: (phone) => api_request.request.post(endpoints.AUTH.SEND_SMS_CODE, { phone }),
  // 验证token
  checkToken: (token) => api_request.request.post(endpoints.AUTH.CHECK_TOKEN, { token }),
  // 刷新token
  refreshToken: (refreshToken) => api_request.request.post(endpoints.AUTH.REFRESH_TOKEN, { refreshToken }),
  // 绑定手机号
  bindPhone: (data) => api_request.request.post(endpoints.AUTH.BIND_PHONE, data),
  // 修改密码
  changePassword: (data) => api_request.request.post(endpoints.AUTH.CHANGE_PASSWORD, data),
  // 重置密码
  resetPassword: (data) => api_request.request.post(endpoints.AUTH.RESET_PASSWORD, data)
};
const apiUtils = {
  // 生成分页参数
  generatePagination: (page = 1, pageSize = 10) => ({
    page,
    pageSize,
    skip: (page - 1) * pageSize
  }),
  // 处理上传进度
  handleUploadProgress: (progressEvent) => {
    const percent = Math.round(progressEvent.loaded * 100 / progressEvent.total);
    return percent;
  },
  // 处理下载进度
  handleDownloadProgress: (progressEvent) => {
    const percent = Math.round(progressEvent.loaded * 100 / progressEvent.total);
    return percent;
  },
  // 格式化错误信息
  formatError: (error) => {
    if (error.code) {
      return error.message;
    }
    return "网络连接失败，请检查网络设置";
  }
};
const travelService$1 = {
  userService,
  travelService,
  animalService,
  flowerService,
  orderService,
  paymentService,
  systemService,
  homeService,
  authService,
  searchService,
  promotionService,
  apiUtils
};
exports.animalService = animalService;
exports.authService = authService;
exports.flowerService = flowerService;
exports.homeService = homeService;
exports.promotionService = promotionService;
exports.searchService = searchService;
exports.travelService = travelService;
exports.travelService$1 = travelService$1;
//# sourceMappingURL=../../.sourcemap/mp-weixin/api/services.js.map
