import { requestApi } from '../util/network'

// 获取卖家商品列表
export const getGoodsList =
    (controller, params, keyword, goods_type, search_type) =>
      requestApi(
        '/' + controller + '/goods_list',
        'POST',
        {
          'keyword': keyword,
          'goods_type': goods_type,
          'search_type': search_type,
          'page': params.page,
          'per_page': params.per_page,
          'client_type': 'wap'
        },
        'seller'
      )
// 删除商品
export const dropGoods =
    (controller, commonid) =>
      requestApi(
        '/' + controller + '/drop_goods',
        'POST',
        {
          'commonid': commonid,
          'client_type': 'wap'
        },
        'seller'
      )
// 商品上架
export const goodsShow =
    (controller, commonid) =>
      requestApi(
        '/' + controller + '/goods_show',
        'POST',
        {
          'commonid': commonid,
          'client_type': 'wap'
        },
        'seller'
      )
// 商品下架
export const goodsUnshow =
    (controller, commonid) =>
      requestApi(
        '/' + controller + '/goods_unshow',
        'POST',
        {
          'commonid': commonid,
          'client_type': 'wap'
        },
        'seller'
      )
// 商品编辑
export const goodsEdit =
    (controller, commonid) =>
      requestApi(
        '/' + controller + '/edit_goods',
        'POST',
        {
          'commonid': commonid
        },
        'seller'
      )
// 保存商品规格
export const goodsSpecSave =
    (data) =>
      requestApi(
        '/Sellerspec/save_spec',
        'POST',
        data,
        'seller'
      )
// 商品规格值
export const goodsSpecAdd =
    (controller, name, gc_id, sp_id) =>
      requestApi(
        '/' + controller + '/add_spec',
        'POST',
        {
          'name': name,
          'gc_id': gc_id,
          'sp_id': sp_id
        },
        'seller'
      )
export const uploadInfoFile =
    (controller, file) =>
      requestApi(
        '/' + controller + '/image_upload',
        'POST',
        file,
        'seller',
        true
      )
export const uploadVideo =
    (controller, file) =>
      requestApi(
        '/' + controller + '/video_upload',
        'POST',
        file,
        'seller',
        true
      )
export const uploadResource =
    (file) =>
        requestApi(
            '/seller_resource/resource_upload',
            'POST',
            file,
            'seller',
            true
        )
export const delResource =
    (data) =>
        requestApi(
            '/seller_resource/del_resource',
            'POST',
            data,
            'seller'
        )
// 商品保存
export const goodsSave =
    (controller, class_id, commonid, goods, goods_body, sgcate_id, spec, sp_name, sp_val, attr, g_fccount, g_fcprefix) =>
      requestApi(
        '/' + controller + '/save_goods',
        'POST',
        {
          'class_id': class_id,
          'commonid': commonid,
          'goods': goods,
          'goods_body': goods_body,
          'sgcate_id': sgcate_id,
          'spec': spec,
          'sp_name': sp_name,
          'sp_val': sp_val,
          'attr': attr,
          'g_fcprefix': g_fcprefix,
          'g_fccount': g_fccount
        },
        'seller'
      )
// 获取店铺商品分类公共数据
export const getCommonData =
    (controller, class_id) =>
      requestApi(
        '/' + controller + '/get_common_data',
        'POST',
        {
          'class_id': class_id
        },
        'seller'
      )
// 图片编辑
export const imageEdit =
    (controller, commonid) =>
      requestApi(
        '/' + controller + '/edit_image',
        'POST',
        {
          'commonid': commonid
        },
        'seller'
      )
// 图片保存
export const imageSave =
    (controller, commonid, img) =>
      requestApi(
        '/' + controller + '/save_image',
        'POST',
        {
          'commonid': commonid,
          'img': img
        },
        'seller'
      )
// 获取店铺经营分类
export const getGoodsClass =
    (controller) =>
      requestApi(
        '/' + controller + '/goods_class',
        'POST',
        {

        },
        'seller'
      )
