OMS_H5/src/api/auth.ts

20 lines
584 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import http from '@/utils/http'
import type { ApiResponse, LoginParams } from '@/types'
import type { AxiosResponse } from 'axios'
/**
* 用户登录
*/
export const login = (params: LoginParams): Promise<AxiosResponse<ApiResponse<{
token: string
userInfo: any
}>>> => {
// 创建FormData对象
const formData = new FormData()
formData.append('username', params.username)
formData.append('password', params.password)
// 添加rememberMe参数默认为true
formData.append('rememberMe', String(params.rememberMe ?? true))
return http.post('/login', formData)
}