// 用户管理函数库
import apis from "../apis_moudles";
import req from "../request";

function toQuery(params) {
  if (!params) {
    return "";
  }
  let query = [];
  for (let i in params) {
    query.push(`${i}=${params[i]}`);
  }
  return query.join("&");
}
// 对象数组
const GETVERIFYIMG = function () {
  return req.get(apis.getVerifyImg, { responseType: "blob" });
};

const GETVERIFYEMAIL = function (params) {
  const queryStr = toQuery(params);
  return req.post(apis.getVerifyEmail + "?" + queryStr);
};

const LOGIN = function (params) {
  const queryStr = toQuery(params);
  return req.post(apis.login + "?" + queryStr);
};

const LOGINOUT = function () {
  return req.get(apis.loginOut);
};

const RESETPASSWORD = function (params) {
  const queryStr = toQuery(params);
  return req.post(apis.pwdReset + "?" + queryStr);
};

export default { GETVERIFYIMG, GETVERIFYEMAIL, LOGIN, LOGINOUT, RESETPASSWORD };
