import request from "../request";

// 查询列表
export function crowdlist(query) {
  return request({
    url: '/crowdsource/list',
    method: 'get',
    params: query
  })
}
//首页查询众包
export function homecrowdlist(query) {
  return request({
    url: '/crowdsource/listAnon',
    method: 'get',
    params: query,
    headers: {
      isToken: false
    },
  })
}
//首页查询行业资讯
export function homeindust(query) {
  return request({
    url: '/news/newsList',
    method: 'get',
    params: query,
    headers: {
      isToken: false
    },
  })
}
export function industdetails(id) {
  return request({
    url: '/news/'+id,
    method: 'get',
    headers: {
      isToken: false
    },
  })
}
//发布任务的接口
export function publishTask(form) {
  return request({
    url: '/crowdsource/apply',
    method: 'post',
    data: form
  })
}
//修改任务的接口
export function editTask(form) {
  return request({
    url: '/crowdsource/reapply',
    method: 'post',
    data: form
  })
}

export function listApply(query) {
  return request({
    url: '/crowdsource/apply/list',
    method: 'get',
    params: query
  })
}


export function getApply(applyId) {
  return request({
    url: '/crowdsource/apply/' + applyId,
    method: 'get'
  })
}

export function auditTask(form) {
  return request({
    url: '/crowdsource/audit',
    method: 'post',
    data:form
  })
}
export function getById(id,userId) {
  const url = userId ? `?userId=${userId}` : ''
  return request({
    url: `/crowdsource/detail/${id}` + url,
    method: 'get',
    headers: { 
      isToken: false
    },
  })
}
export function claimTask(id) {
  return request({
    url: '/crowdsource/claim/'+id,
    method: 'get'
  })
}
///
export function competitivetask(data) {
  return request({
    url: '/crowdsource/bidding',
    method: 'post',
    data: data
  })
}

// 
export function myClaim(query,userId) {
  return request({
    url: '/crowdsource/claim/my/'+userId,
    method: 'get',
    params: query
  })
}
export function myApply(query) {
  return request({
    url: '/crowdsource/apply',
    method: 'get',
    params: query
  })
}
export function myPublish(query) {
  return request({
    url: '/crowdsource/publish',
    method: 'get',
    params: query
  })
}

export function getApplicant(taskId) {
  return request({
    url: '/crowdsource/applicant/'+ taskId,
    method: 'get'
  })
}

export function assignTester(param) {
  return request({
    url: '/crowdsource/assign',
    method: 'post',
    data: param
  })
}
export function reportTester(param) {
  return request({
    url: '/crowdsource/upload/report',
    method: 'post',
    data: param
  })
}
export function checkupTester(param) {
  return request({
    url: '/crowdsource/task/checkup',
    method: 'post',
    data: param
  })
}
// 众包提交订单
export function addlabor(data) {
  return request({
    url: '/labor/add',
    method: 'post',
    data:data
  })
}
export function payconfirm(param) {
  return request({
    url: '/crowdsource/task/payment',
    method: 'post',
    data: param
  })
}


// 获取类型字典
export function getType() {
  return request({
    url: '/system/dict/data/type/crowdsourcing_task_type',
    method: 'get',
    headers: {
      isToken: false
    },
  })
}



