76 lines
2.0 KiB
TypeScript
76 lines
2.0 KiB
TypeScript
import httpFetch from "@/api/fetch"
|
|
import { ResultData } from "@/api/typing"
|
|
import { Login } from "./types"
|
|
|
|
const BASE_PATH =
|
|
process.env.NEXT_PUBLIC_ENV === "production"
|
|
? "http://172.16.104.95:9110"
|
|
: process.env.NEXT_PUBLIC_ENV === "staging"
|
|
? "http://172.16.115.128:9110"
|
|
: "https://label.softtest.cowarobot.com"
|
|
|
|
// 获取验证码
|
|
export const getVerifyCode = (params: { phone: string }) => {
|
|
return httpFetch<ResultData<{}>>({
|
|
url: BASE_PATH + `/api/v1/label_server/login/get_verify_code`,
|
|
method: "POST",
|
|
body: JSON.stringify(params),
|
|
})
|
|
}
|
|
|
|
// 账户登录
|
|
export const passwdLogin = (params: Login.ReqPasswdLogin) => {
|
|
return httpFetch<Login.ResLabelLogin>({
|
|
url: BASE_PATH + `/api/v1/label_server/user/login`,
|
|
method: "POST",
|
|
body: JSON.stringify({ ...params, name: params.account || params.phone }),
|
|
isLogin: true,
|
|
})
|
|
}
|
|
|
|
// 验证码登录
|
|
export const verificationLogin = (params: Login.ReqVerificationLogin) => {
|
|
return httpFetch<ResultData<Login.ResLogin>>({
|
|
url: BASE_PATH + `/api/v1/label_server/login/verification`,
|
|
method: "POST",
|
|
body: JSON.stringify(params),
|
|
isLogin: true,
|
|
})
|
|
}
|
|
|
|
// 飞书登录
|
|
export const fetchFeishuLogin = (params: Login.ReqFeishuLogin) => {
|
|
return httpFetch<ResultData<Login.ResLogin>>({
|
|
url: BASE_PATH + `/api/v1/label_server/login/feishu`,
|
|
method: "POST",
|
|
body: JSON.stringify(params),
|
|
isLogin: true,
|
|
})
|
|
}
|
|
|
|
// 刷新token
|
|
// export const refreshKey = (params: { token: string }) => {
|
|
// return httpFetch<ResultData<Login.ResRefreshKey>>({
|
|
// url: BASE_PATH + `/api/v1/label_server/user/refresh_token`,
|
|
// method: "POST",
|
|
// data: params,
|
|
// isRefresh: true,
|
|
// })
|
|
// }
|
|
export const refreshKey = () => {
|
|
return httpFetch<Login.ResRefreshKey>({
|
|
url: BASE_PATH + `/api/v1/label_server/user/refresh_token`,
|
|
method: "GET",
|
|
isRefresh: true,
|
|
})
|
|
}
|
|
|
|
// 删除cookie
|
|
export const deleteCookie = () => {
|
|
return httpFetch<ResultData<string>>({
|
|
url: `/api/session`,
|
|
method: "DELETE",
|
|
isDeleteCookie: true,
|
|
})
|
|
}
|