import { http, httpGet, httpPost } from '@/utils/http'

export interface IFooItem {
  id: string
  name: string
}

export interface UserT {
  tokenValue: string
}

export interface LoginI {
  coin_address?: string
  share_code?: string
  firstName: string
  id: string | number
  languageCode: string
  lastName: string
  username: string
  token?: string
}

export interface UserCenter {
  userId: number
  currentValue: number
  startTimestamp: number
  endTimestamp: number
  residueTimestamp: number
  currentRate: string
  durableRate: string
  temporaryRate: string
  status: number
}
interface LoginCheck {
  show: number
}
export interface JinbiT {
  id: number
  sn: number
  account: string
  nickname: string
  real_name: string
  avatar: string
  create_time: string
  gold_coin: number
  key: number
  development_gold_coin: number
  history_gold_coin: number
  history_key: number
  usdt: number | null
  stamina: number
  temporary_status: number
  temporary_start_time: number
  temporary_coin: number
  temporary_time: number
  total_development_gold: number
}

export interface ProductionIncreaseInterface {
  id: number
  name: string
  level: number
  gold_coin: number
  value: number
  image: string
  upgrades: boolean
}

// 登录接口
export const coinLoginApi = (data: LoginI) => {
  return httpPost<UserT>('/app/login/coinLogin', data)
}

// 获取当前登录用户金币数量
export const getGoldCoinProductState = () => {
  return httpPost<UserCenter>('/app/gold/coin/product/getGoldCoinProductState')
}
// 开始金币活动
export const startCoinGame = () => {
  return http.post<LoginCheck>('/app/gold/coin/product/start')
}
// 统计用户在线时长
export const updateOnlineTime = (onlineTime: number) => {
  return http.post<UserCenter>('/app/user/updateOnlineTime', { online_time: onlineTime })
}

// 检查是否注册过
export const coinLoginCheck = (id: number) => {
  return http.get<LoginCheck>('/app/login/coinLoginCheck', { terminal: 3, id })
}

// 收取金币
export const stageCoinAdd = () => {
  return http.post<any>('/app/gold/coin/product/collectGoldCoin')
}

// 获取推进器信息
export const propellerAllTwo = () => {
  return http.get<ProductionIncreaseInterface[]>('/app/propeller/propellerAllTwo')
}
// 升级推进器
export const prepellerDeduction = (id: number) => {
  return http.post<any>('/app/propeller/prepellerDeduction', { id })
}

// 存入当前语言 user/checkLanguage
export const postCheckLang = (lang: string) => {
  return http.post<any>('/app/user/checkLanguage', { lang })
}
