import http from '@/utils/http'
import { AppDispatch } from '..'

/**
 * 藏品关注-关注
 */
export const C3_APIfocus = (id: number) => {
  return http.get(`cms/goods/focus/${id}`)
}

/**
 * 藏品关注-取消关注
 */
export const C3_APIfocusNo = (id: number) => {
  return http.get(`cms/goodsFocus/focusDel/${id}`)
}

/**
 * 藏品关注-获取分页列表
 */
export const C3_APIgetList = (data: any, exportFlag?: boolean): any => {
  if (exportFlag) return http.post('cms/goodsFocus/page', data)
  else {
    return async (dispatch: AppDispatch) => {
      const res = await http.post('cms/goodsFocus/page', data)
      if (res.code === 0) {
        const obj = {
          list: res.data.records,
          total: res.data.total
        }

        dispatch({ type: 'C3/getList', payload: obj })
      }
    }
  }
}
