import fly from "./main";


//通过code值获取用户信息
export function get_user_by_code($code) {
  return fly.post('activity/activity-user', {js_code: $code})
}

//获取活动
export function getActivity($activity_id) {
  let $params = {
    activity_id: $activity_id
  }
  return fly.post('activity/get-activity', $params)
}


//根据游戏报报告的id 获取 游戏报告
export function getUserReportLine() {
  let $user_id = JSON.parse(store.getters.getUserInfo())['user_id']
  let $params = {
    activity_id: store.getters.getActivityId(),
    user_id: $user_id
  }
  return fly.post('activity/user-record', $params)
}


//预选赛排行榜
export function getPromotionRanking($activity_id) {
  let $params = {
    activity_id: $activity_id
  }
  return fly.post('activity/promotion-ranking', $params)
}

//晋级赛排行榜
export function getFinalsRanking($activity_id) {
  let $params = {
    activity_id: $activity_id
  }
  return fly.post('activity/finals-ranking', $params)
}

//总决赛排行榜
export function getAllFinalsRanking($activity_id) {
  let $params = {
    activity_id: $activity_id
  }
  return fly.post('activity/all-finals-ranking', $params)
}


//活动报名
export function doEnroll($activity_id, $user_id) {
  let $params = {
    activity_id: $activity_id,
    user_id: $user_id
  }
  return fly.post('activity/enroll', $params)
}

// 查看用户是否参加比赛
export function checkJoined($activity_id, $user_id) {
  let $params = {
    activity_id: $activity_id,
    user_id: $user_id
  }
  return fly.post('activity/is-match', $params)
}

//获取jssdk
export function getJsSDK($activity_id) {
  let $params = {
    url: window.location.href,
    access_token: 11,
    activity_id: $activity_id,
  }
  return fly.post('activity/get-jsdk', $params)
}

// 添加联名
export function addJoint($joint) {
  let $params = {
    phone: $joint.phone,
    school: $joint.school,
    name: $joint.name,
  }
  $params['access_token'] = wx.getStorageSync('token')
  return fly.post('jointly/add', $params)
}

// 获取联名
export function getJoint() {
  let $params = {
    "access_token": wx.getStorageSync('token'),
  }
  return fly.post('jointly/index', $params)
}
