| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- import type { IAuthLoginRes, ICaptcha, IDoubleTokenRes, IUpdateInfo, IUpdatePassword, IUserInfoRes } from './types/login'
- // import { http } from '@/http/http'
- import { API_DOMAINS, http } from '@/http/alova'
- /**
- * 登录表单
- */
- export interface ILoginForm {
- username: string
- password: string
- }
- /**
- * 获取验证码
- * @returns ICaptcha 验证码
- */
- export function getCode() {
- return http.Get<ICaptcha>('/user/getCode')
- }
- /**
- * 用户登录
- * @param loginForm 登录表单
- */
- export function login(loginForm: ILoginForm) {
- return http.Post<IAuthLoginRes>('/auth/login', loginForm)
- }
- /**
- * 刷新token
- * @param refreshToken 刷新token
- */
- export function refreshToken(refreshToken: string) {
- return http.Post<IDoubleTokenRes>('/auth/refreshToken', { refreshToken })
- }
- /**
- * 获取用户信息
- */
- export function getUserInfo() {
- return http.Get<IUserInfoRes>('/couponCenter/APP/couponCenterUser/queryInformationAndStatus')
- }
- /**
- * 退出登录
- */
- export function logout() {
- return http.Post<void>('/couponCenter/APP/wx/logout')
- }
- /**
- * 修改用户密码
- */
- 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)),
- })
- })
- }
- export function getUserProfile() {
- return new Promise<UniApp.GetUserProfileRes>((resolve, reject) => {
- uni.getUserProfile({
- provider: 'weixin',
- desc: '用于获取登录用户信息',
- success: res => resolve(res),
- fail: err => reject(new Error(err)),
- })
- })
- }
- /**
- * 微信登录
- * @param params 微信登录参数,包含code
- * @returns Promise 包含登录结果
- */
- export function wxLogin(code: string) {
- return http.Post<IAuthLoginRes>('/couponCenter/APP/wx/login', { code }, {
- meta: {
- ignoreAuth: true,
- },
- })
- }
- export function addInviteConversion(params) {
- return http.Get(`/couponCenter/APP/shareRecord/addInviteConversion?shareRecordId=${params.shareRecordId}`)
- }
|