import qs from 'qs';
import request from './api';

export const getHospital = async (params) => {
  let query = { pageNum: 1, pageSize: 1, ...params };
  const str = qs.stringify(query);
  
  return request({ url: `/api-ws/hospitals/?${str}` });
};

// 新的任务列表查询
export const getNewActivityDesc = async (data) => {
  const { id, token } = data;
  return request({
    url: `/campaign/tims/timsActivityInfo?activityId=${id}&token=${token}&setEntry=true`,
    headers: {
      token
    }
  });
}


// token校验
export const checkToken = async({token}) => {
  return request({
    url: `campaign/admin/task/checkToken?token=${token}`,
    withCredentials: true
  })
}

// 获取跳转链接
export const selectAppModuleParam = async ({id, token }) => {
  return request({
    url: `/contents/contentAppModule/selectAppModuleParam?id=${id}&token=${token}&setEntry=true`,
    withCredentials: true
  });
}

// 活动首页个人信息
export const getSelfAllScore = async (data) => {
  const { id, token } = data;
  return request({
    url: `campaign/rank/getTimsRankAndScore?activityId=${id}&token=${token}&setEntry=true`,
    headers: {
      token
    }
  });
}

// 个人明细
export const getSelfActivity = async (data) => {
  const { id, token } = data;
  return request({
    url: `/campaign/tims/personalDetails?activityId=${id}&token=${token}&setEntry=true`,
    headers: {
      token
    }
  });
}

// 个人排行榜
export const getRankData = async (data) => {
  const { id } = data;
  return request({
    url: `campaign/rank/getTimsRankTop?activityId=${id}&topN=100`
  })
}

// 获取图形验证码
export const getCaptchaGet = async () => {
  return request({
    url: `account/account/captcha`,
    method: 'get'
  })
}

// 获取短信验证码
export const getAuthCode = ({ mobilePhone, flag, captchaToken, captchaAnswer }) => {
  return request({
    url: `account/account/authCode`,
    method: 'get',
    params: {
      mobilePhone, flag, captchaToken, captchaAnswer
    },
  })
}