import { axios } from '@/utils/request'

//  商城产品列表  有分页
export const shopProductList = (params) => {
  const url = `/shopProduct/queryProductPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('列表查询')
    }
  })
}

// 商城产品列表 删除
export const shopProductDel = params => {
  return axios({
    url: '/shopProduct/delete',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('删除')
    }
  })
}
// 商城产品 导出模板
export const shopProductDownloadExcel = params => {
  return axios.request({
    url: '/shopProduct/downloadExcel',
    method: 'post',
    data: params,
    responseType: 'blob',
    headers: {
      'module': encodeURIComponent('下载导入模板')
    }
  })
}

// 商城产品 导入解析
export const shopProductParseExcel = (params) => {
  return axios({
    url: '/shopProduct/parseExcel',
    data: params,
    method: 'post'
  })
}

// 商城产品  导出错误项
export const shopProductExport = params => {
  return axios.request({
    url: '/shopProduct/exportError',
    method: 'post',
    data: params,
    responseType: 'blob',
    headers: {
      'module': encodeURIComponent('导出错误项')
    }
  })
}

// 商城产品 详情
export const shopProductDetail = params => {
  return axios({
    url: `/shopProduct/queryBySn/${params.shopProductSn}`,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('详情')
    }
  })
}

// 商城产品 批量保存
export const saveBatchProduct = params => {
  return axios({
    url: '/shopProduct/saveBatchProduct',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('批量保存')
    }
  })
}

// 商城产品 导入产品批量保存
export const saveBatchProductExcel = params => {
  return axios({
    url: '/shopProduct/saveBatchProductExcel',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('批量保存')
    }
  })
}

// 商城产品  产品保存
export const shopProductSaveProduct = params => {
  return axios({
    url: '/shopProduct/saveProduct',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('保存')
    }
  })
}

// 商城产品  更新上架、下架状态
export const shopProductUpdateStatus = params => {
  return axios({
    url: '/shopProduct/updateStatus',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('更新状态')
    }
  })
}

// 获取类目中已选择的产品  列表
export const queryProductSnList = (params) => {
  return axios({
    url: '/shopProduct/queryProductSnList',
    data: params,
    method: 'post'
  })
}

// 商城目录 列表  无分页
export const queryExtList = (params) => {
  return axios({
    url: '/shopCategory/queryExtList',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('商城目录列表')
    }
  })
}
