import type { PageParams, PageResult } from '@/types/global'
import type { bannerItem, goodsListItem, hotRecommendItem, noticeBarItem } from '@/types/home'
import { request } from '@/utils/request'

/**
 * 获取轮播图
 * @returns
 */
export const getBannerApi = (type : number = 1) => {
  return request<bannerItem[]>({
    method: 'GET',
    url: '/shop/advert/banner',
    data: {
      type,
    },
  })
}

/**
 * 获取商品列表
 * @param data
 * @returns
 */
export const getGoodsListApi = (data ?: PageParams) => {
  return request<PageResult<goodsListItem>>({
    method: 'GET',
    url: '/shop/goods',
    data,
  })
}

/**
 * 获取通告栏
 * @param id
 * @returns
 */
export const getNoticeBartApi = () => {
  return request<noticeBarItem[]>({
    method: 'GET',
    url: '/shop/advert/noticeBar',
  })
}

export const getHotRecommendApi = () => {
  return request<hotRecommendItem[]>({
    method: 'GET',
    url: '/shop/advert/hotRecommend',
  })
}
// 移动端-首页接口
export const configIndex = (data : { page : number, page_size : number }) => {
  return request({
    url: '/api/index/config',
    method: 'POST',
    data,
  })
}
// 移动端-首页接口-搜索接口
export const configSearch = (data:Record<string, any>) => {
  return request({
    url: '/api/index/search',
    method: 'POST',
    data,
  })
}
