Compare commits

..

3 Commits

Author SHA1 Message Date
kk 4e612b1c12 清除旧的回调标记
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 50s
2026-07-22 10:36:24 +08:00
kk d326912bd3 redirectTo改为reLaunch
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 46s
2026-07-22 10:03:13 +08:00
kk be976f939f 简化state参数
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 46s
2026-07-20 17:55:22 +08:00
3 changed files with 7 additions and 9 deletions
+3 -1
View File
@@ -53,7 +53,9 @@
if (state) { if (state) {
loadingUrl += '&state=' + state; loadingUrl += '&state=' + state;
} }
uni.redirectTo({ url: loadingUrl }); // 必须用 reLaunch:支付宝回调时当前页可能就是 loading 页,
// redirectTo 到同一页面不会重新触发 onLoad,导致请求卡住
uni.reLaunch({ url: loadingUrl });
return; return;
} }
+3
View File
@@ -24,6 +24,9 @@ export default {
this.action = options.action || ''; this.action = options.action || '';
// #ifdef H5 // #ifdef H5
// 每次进入页面清除旧的回调标记,防止上次异常退出后标记残留导致 startAuth 被跳过
uni.removeStorageSync('__auth_callback_done');
// Mock 模式:跳过微信 OAuth,直接登录 // Mock 模式:跳过微信 OAuth,直接登录
if (config.mockWechatLogin && this.action !== 'userinfo') { if (config.mockWechatLogin && this.action !== 'userinfo') {
this.mockLogin(); this.mockLogin();
+1 -8
View File
@@ -334,7 +334,6 @@ export default {
try { try {
// 存入 localStorageloading 页面复用时 onLoad 不会重新触发,需要从 localStorage 读取) // 存入 localStorageloading 页面复用时 onLoad 不会重新触发,需要从 localStorage 读取)
localStorage.setItem('__auth_action', 'userinfo');
if (this.deviceId) { if (this.deviceId) {
localStorage.setItem('__auth_device_id', this.deviceId); localStorage.setItem('__auth_device_id', this.deviceId);
} }
@@ -344,12 +343,6 @@ export default {
window.location.origin.replace(/^http:/, 'https:') + window.location.pathname window.location.origin.replace(/^http:/, 'https:') + window.location.pathname
); );
// 构建 state(包含 action 和 device_id,回调时原样回传)
const stateObj = { action: 'userinfo' };
if (this.deviceId) {
stateObj.device_id = this.deviceId;
}
// 用户信息授权:微信用 snsapi_userinfo,支付宝用 auth_user // 用户信息授权:微信用 snsapi_userinfo,支付宝用 auth_user
const platform = uni.getStorageSync('platform') || 'wechat'; const platform = uni.getStorageSync('platform') || 'wechat';
const scopes = platform === 'alipay' ? 'auth_user' : 'snsapi_userinfo'; const scopes = platform === 'alipay' ? 'auth_user' : 'snsapi_userinfo';
@@ -358,7 +351,7 @@ export default {
app_no: appNo, app_no: appNo,
scopes: scopes, scopes: scopes,
redirect_uri: redirectUri, redirect_uri: redirectUri,
state: JSON.stringify(stateObj), state: 'userinfo',
}); });
const data = res.data || {}; const data = res.data || {};