consumer-app/api/auth.js

56 lines
1.3 KiB
JavaScript
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 { request } from './index.js'
/**
* 账户密码登录
* @param {Object} data 登录数据
* @param {String} data.mobile 手机号
* @param {String} data.password 密码
* @returns {Promise} 返回登录结果包含token等
*/
export function login(data) {
return request({
url: '/app-api/member/auth/login',
method: 'POST',
data: data,
showLoading: true,
needAuth: false // 登录接口不需要token认证
})
}
/**
* 小程序一键授权手机号登录
* @param {Object} data 登录数据
* @param {String} data.code 微信授权code
* @param {String} data.encryptedData 加密数据
* @param {String} data.iv 初始向量
* @returns {Promise} 返回登录结果包含token等
*/
export function loginByPhone(data) {
return request({
url: '/app-api/member/auth/login',
method: 'POST',
data: data,
showLoading: true,
needAuth: false // 登录接口不需要token认证
})
}
/**
* 刷新token
* @param {String} refreshToken 刷新令牌
* @returns {Promise} 返回新的token信息
*/
export function refreshToken(refreshToken) {
return request({
url: '/app-api/member/auth/refresh', // 根据实际接口调整
method: 'POST',
data: { refreshToken },
showLoading: false,
needAuth: false // 刷新token接口不需要accessToken认证
})
}