mothercup/SmartAssiter/api/requestApi.ts
2026-09-04 08:56:15 +08:00

81 lines
1.9 KiB
TypeScript

import { $http, JSONObject } from "@/api/httpInstance"
export type RegisteredUserReq = {
userName: string,
userPassword: string,
rndcode: string
}
// 获取pinCode
export async function GetPindCodeReqApi(params: RegisteredUserReq): Promise<JSONObject>{
const body: JSONObject = {
userName: params.userName,
userPassword: params.userPassword,
rndcode: params.rndcode
} as JSONObject
const res = await $http({
url: "/ocpp-mtapp-api/api/v1/users/getPinCode",
method: "POST",
data: body
})
return res
}
// 注册用户
export async function RegisteredUserReqApi(params: RegisteredUserReq): Promise<JSONObject>{
const body: JSONObject = {
userName: params.userName,
userPassword: params.userPassword,
rndcode: params.rndcode
} as JSONObject
const res = await $http({
url: "/ocpp-mtapp-api/api/v1/users/add",
method: "POST",
data: body
})
return res
}
export type LoginReq = {
username: string
password: string
}
// 登录请求
export async function LoginReqApi(params: LoginReq): Promise<JSONObject>{
const body: JSONObject = {
username: params.username,
password: params.password,
expirationTime: 0
} as JSONObject
const res = await $http({
url: "/ocpp-mtapp-api/api/v1/auth/login",
method: "POST",
data: body
})
return res
}
export type ModifyUserInfoReq = {
name?: string | null,
phone?: string | null,
password?: string | null,
nickName?: string | null
}
// 修改用户信息
export async function ModifyUserInfoReqApi(params: ModifyUserInfoReq): Promise<JSONObject>{
const body: JSONObject = {
name: params.name,
phone: params.phone,
password: params.password
} as JSONObject
const res = await $http({
url: `/ocpp-mtapp-api/api/v1/users/${params.name}`,
method: "GET",
data: body
})
return res
}