feat: 注册和登录兼容h5

This commit is contained in:
zdl
2025-10-15 11:43:04 +08:00
parent 4e9acd12c2
commit 7d283aab8e
6 changed files with 306 additions and 19 deletions

View File

@@ -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