/*
 * @Author: jixiang
 * @Date: 2021-04-07 11:06:09
 * @Description:
 * @FilePath: /vite_pc/src/api/user.ts
 * 56580223@qq.com
 */
/**
 * 所有跟用户相关的接口
 */

import { HttpResponse } from '@/@type';
import Axios from './axios';

const user = {
  login: '/api/admin/user/userLogin',
  userInfo: '/api/admin/user/userDetail',
};

interface HttpParams {
  coinName: string;
  cashName: string;
}

/**
 * @interface loginParams -登录参数
 * @property {string} username -用户账号
 * @property {string} captcha -验证码
 * @property {string} password -用户密码
 */
interface LoginParams {
  username: string;
  password: string;
  captcha: number;
}

/**
 * @description: BatchList -查询班次
 * @param {*}
 * @return {*}
 */
 interface userInfo {
  id: string;
}

/**
 * @interface SendPhoneCodeParams -发送手机验证码参数
 * @property {string} phone -手机号
 */
interface SendPhoneCodeParams {
  phone: string;
}

export interface UserApi {
  coin2cash(param: HttpParams): Promise<any>;
}

/**
 * @example Axios.get(`https://xxx.com}`)
 * @todo Get the exchange rate of the current currency
 */

class UserService {
  // 登录
  static async login(params: LoginParams): Promise<HttpResponse> {
    return Axios(user.login, {
      method: 'GET',
      // responseType: 'json',
      params: params,
    });
  }

    //根据id获取用户详细信息
  static getUserInfo(params: userInfo): Promise<HttpResponse> {
      console.log(params, 'params');
      return Axios(user.userInfo, {
      method: 'get',
      // responseType: 'json',
      params: params,
    });
  }
}

export default UserService;
