import fetch from "@/common/fetch.js";
import BASE_URL from "./base.js";
import useNetWork from "@/common/useNetWork.js";
const LOGIN = BASE_URL + "/user/getLoginToken";
const UserType = BASE_URL + "/user/getUserType";
const UserRegister = BASE_URL + "/user/userRegister";
const UpdateUserImg = BASE_URL + "/user/updateUserImg";
const UserJurisdiction = BASE_URL + "/user/getUserJurisdiction";

export function login(code) {
  useNetWork();
  const params = `${LOGIN}?code=${code}`;
  return fetch.get(params).then((res) => res);
}

/**
 * 获取到用户权限
 * @param {*}
 */
export function getUserJurisdiction(data) {
  useNetWork();
  return fetch.post(UserJurisdiction,data).then((res) => res);
}

/**
 * 获取到用户类型
 * @param {*}
 */
export function getUserType() {
  useNetWork();
  return fetch.get(UserType).then((res) => res);
}

/**
 * 注册
 * @param {*}
 */
export function getUserRegister(data) {
  useNetWork();
  const params = {
    phone: data.phone,
    account: data.account,
    name: data.name,
    salt: data.salt,
  };
  return fetch.post(UserRegister, params).then((res) => res);
}
