将必要参数拼接在redirect_uri中
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 44s

This commit is contained in:
kk
2026-07-11 11:01:22 +08:00
parent 7b2e4dc72e
commit 45147426e0
3 changed files with 34 additions and 28 deletions
+6 -4
View File
@@ -30,7 +30,7 @@
const urlParams = new URLSearchParams(window.location.search);
deviceId = urlParams.get('device_id') || '';
// 兜底:从路径解析(如 /pages/index/index/N1154
// 兜底:从路径解析(如 /N1154)
if (!deviceId) {
const path = window.location.pathname;
const segments = path.split('/').filter(Boolean);
@@ -46,14 +46,16 @@
const code = urlParams.get('code');
if (code) {
// 有 code → 进入授权 Loading 页处理,保留 code/action/device_id 参数
// 有 code → 进入授权 Loading 页处理
// redirect_uri 已携带 device_id 和 action,回调时直接从 URL 取
const action = urlParams.get('action') || '';
const callbackDeviceId = urlParams.get('device_id') || deviceId || '';
let loadingUrl = '/pages/auth/loading?code=' + encodeURIComponent(code);
if (action) {
loadingUrl += '&action=' + action;
}
if (deviceId) {
loadingUrl += '&device_id=' + deviceId;
if (callbackDeviceId) {
loadingUrl += '&device_id=' + callbackDeviceId;
}
uni.redirectTo({ url: loadingUrl });
return;