unibest/src/api/login.ts

84 lines
1.6 KiB
TypeScript
Raw Normal View History

import { ICaptcha, IUpdateInfo, IUpdatePassword, IUserInfoVo, IUserLogin } from './login.typings'
import { http } from '@/utils/http'
/**
*
*/
export interface ILoginForm {
username: string
password: string
code: string
uuid: string
}
/**
*
* @returns ICaptcha
*/
export const getCode = () => {
return http.get<ICaptcha>('/user/getCode')
}
/**
*
* @param loginForm
*/
export const login = (loginForm: ILoginForm) => {
return http.post<IUserLogin>('/user/login', loginForm)
}
/**
*
*/
export const getUserInfo = () => {
return http.get<IUserInfoVo>('/user/info')
}
/**
* 退
*/
export const logout = () => {
return http.get<void>('/user/logout')
}
/**
*
*/
export const updateInfo = (data: IUpdateInfo) => {
return http.post('/user/updateInfo', data)
}
/**
*
*/
export const updateUserPassword = (data: IUpdatePassword) => {
return http.post('/user/updatePassword', data)
}
/**
*
* @returns Promise (code)
*/
export const getWxCode = () => {
return new Promise<UniApp.LoginRes>((resolve, reject) => {
uni.login({
provider: 'weixin',
success: (res) => resolve(res),
fail: (err) => reject(new Error(err)),
})
})
}
/**
*
*/
/**
*
* @param params code
* @returns Promise
*/
export const wxLogin = (data: { code: string }) => {
return http.post<IUserLogin>('/user/wxLogin', data)
}