unibest/src/api/login.ts

84 lines
1.6 KiB
TypeScript
Raw Normal View History

import type { ICaptcha, IUpdateInfo, IUpdatePassword, IUserInfoVo, IUserLogin } from './types/login'
import { http } from '@/utils/http'
/**
*
*/
export interface ILoginForm {
username: string
password: string
code: string
uuid: string
}
/**
*
* @returns ICaptcha
*/
export function getCode() {
return http.get<ICaptcha>('/user/getCode')
}
/**
*
* @param loginForm
*/
export function login(loginForm: ILoginForm) {
return http.post<IUserLogin>('/user/login', loginForm)
}
/**
*
*/
export function getUserInfo() {
return http.get<IUserInfoVo>('/user/info')
}
/**
* 退
*/
export function logout() {
return http.get<void>('/user/logout')
}
/**
*
*/
export function updateInfo(data: IUpdateInfo) {
return http.post('/user/updateInfo', data)
}
/**
*
*/
export function updateUserPassword(data: IUpdatePassword) {
return http.post('/user/updatePassword', data)
}
/**
*
* @returns Promise (code)
*/
export function 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 function wxLogin(data: { code: string }) {
return http.post<IUserLogin>('/user/wxLogin', data)
}