保留code参数
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 45s

This commit is contained in:
kk
2026-07-02 19:32:07 +08:00
parent 2560d9d529
commit 5bb31516a0
2 changed files with 12 additions and 7 deletions
+7 -3
View File
@@ -21,9 +21,13 @@ export default {
this.deviceId = options.device_id || '';
// #ifdef H5
// 检查 URL 中是否有授权回调的 code
const urlParams = new URLSearchParams(window.location.search);
const code = urlParams.get('code');
// 优先从页面参数获取 code(App.vue 跳转时带过来)
// 兜底从 URL search 参数获取(微信直接回调时)
let code = options.code || '';
if (!code) {
const urlParams = new URLSearchParams(window.location.search);
code = urlParams.get('code') || '';
}
if (code) {
// 有 code → 调用后端登录