feat: 免授权直达 H5 — 无 token 不再跳登录页,按需授权(requireAuth 返回后刷新身份)

This commit is contained in:
2026-07-31 11:25:39 +08:00
parent 96571fee73
commit edb084bd7a
2 changed files with 20 additions and 9 deletions

View File

@@ -15,7 +15,6 @@ import {
} from '../config/app.js';
import { LOGIN_STATUS } from '../config/cache.js';
import store from '../store';
import { toLogin } from '../libs/login';
import {
customerType
} from '@/api/api.js'
@@ -263,9 +262,11 @@ export default {
}
console.log('[GoUrl] 最终参数: openid=' + (openid || '(空)') + ', unionid=' + (unionid || '(空)') + ', t=' + Math.floor(Date.now() / 1000));
if (!openid) {
// 先存目标路径,登录后自动跳回 web_view
Cache.set('login_back_url', '/pages/annex/web_view/index?url=' + encodeURIComponent(openUrl));
toLogin();
// 无 openid:不拦截,匿名进入 H5(需要身份时由 H5 调 bridge.requireAuth() 再授权)
console.log('[GoUrl] 无 openid,匿名加载 H5(按需授权)');
uni.navigateTo({
url: `/pages/annex/web_view/index?url=${encodeURIComponent(openUrl)}`
});
return;
}
const joiner = url.indexOf('?') !== -1 ? '&' : '?';