feat: 注册和登录兼容h5
This commit is contained in:
@@ -63,13 +63,38 @@ const apiRequest = async (url, options = {}) => {
|
||||
|
||||
export const authService = {
|
||||
/**
|
||||
* 获取微信二维码授权链接
|
||||
* 获取微信二维码授权链接(PC扫码登录)
|
||||
* @returns {Promise<{auth_url: string, session_id: string}>}
|
||||
*/
|
||||
getWechatQRCode: async () => {
|
||||
return await apiRequest('/api/auth/wechat/qrcode');
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取微信H5授权链接(移动端网页授权)
|
||||
* @param {string} redirectUrl - 授权成功后的回调地址
|
||||
* @returns {Promise<{auth_url: string}>}
|
||||
*/
|
||||
getWechatH5AuthUrl: async (redirectUrl) => {
|
||||
return await apiRequest('/api/auth/wechat/h5-auth', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ redirect_url: redirectUrl }),
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 微信H5授权回调处理
|
||||
* @param {string} code - 微信授权code
|
||||
* @param {string} state - 状态参数
|
||||
* @returns {Promise<{success: boolean, user?: object, token?: string}>}
|
||||
*/
|
||||
handleWechatH5Callback: async (code, state) => {
|
||||
return await apiRequest('/api/auth/wechat/h5-callback', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ code, state }),
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 检查微信扫码状态
|
||||
* @param {string} sessionId - 会话ID
|
||||
|
||||
Reference in New Issue
Block a user