import { fetch } from '@utils/request'
import {
  API_NEWS_LIST,
  API_NEWS_FAVOR,
  API_NEWS_UV,
  API_NEWS_SHARE,
  API_ACTIVITY_GROUP
} from '@constants/api'

/**
 * 项目uv埋点
 * @param {*} id  项目id
 */
export const addNewsUv = id => fetch({ url: `${API_NEWS_UV}/${id}`, method: 'PUT' })

/**
 * 项目分享埋点
 * @param {*} id  名片id
 */
export const addNewsShareNum = id => fetch({ url: `${API_NEWS_SHARE}/${id}`, method: 'POST' })

/**
 * 获取资讯列表
 * @param {*} payload
 */
export const queryNewsList = payload => fetch({ url: API_NEWS_LIST, payload })

/**
 * 获取资讯详情 
 * @param {*} id
 */
export const queryNewsDetail = id => fetch({ url: `${API_NEWS_LIST}/${id}` })

/**
 * 首页获取助力拼团 
 * @param {*} payload 
 */
export const queryHelpGroup = payload => fetch({ url: API_ACTIVITY_GROUP, payload })


/**
 *资讯收藏
 * @param {*} payload 
 */
export const favorNews = id => fetch({ url: `${API_NEWS_FAVOR}/${id}`, method:'POST' })


/**
 * 取消资讯收藏
 * @param {*} payload 
 */
export const cancelFavorNews = id => fetch({ url: `${API_NEWS_FAVOR}/${id}`, method:'DELETE' })