import request from "../request";
import { LocationQueryValue } from "vue-router";

interface loginRes {
  code: number;
  msg: string;
  data: {
    token: string;
    wxUserInfo: {
      nickname: string;
      headimgurl: string;
    };
  };
}

/**
 *
 * @param code 微信code
 * @returns
 */
export async function login(code: LocationQueryValue | LocationQueryValue[]) {
  let res = await request({
    url: "/login/code",
    method: "post",
    headers: {
      isToken: false,
    },
    params: {
      authorizationCode: code,
    },
  });
  return <loginRes>res.data;
}

export async function userInfo() {
  return request({
    url: "/student/user/info",
  });
}
