feat: 微信审核适配 — 移除提现/分销页面 + 分享图片预取 + 登录链路修复
- pages.json 移除 14 个提现/分销页面注册(user_cash/user_spread/spreadData/promoter/distributor),文件保留可恢复 - template4.vue 隐藏'立即提现'区块(用户中心可见入口,分销功能已关闭) - record.vue 抽奖记录移除提现收款跳转(改 toast 提示) - web_view 分享图片:太阳码/点击应用时从 box_app 预取 shareImageUrl,H5 postMessage 传图优先 - web_view _fetchOpenidAndLoad 兼容老用户响应(openid 从 userInfo/JWT 兜底解析)并写回缓存 - App.vue 移除 expired=[object Promise] 无意义日志
This commit is contained in:
@@ -219,21 +219,15 @@ export default {
|
||||
// #endif
|
||||
// #ifdef MP || APP-PLUS
|
||||
let openUrl = url;
|
||||
let token = store.state.app.token;
|
||||
if (token && url.indexOf('token=') === -1 && (url.indexOf(HTTP_REQUEST_URL) === 0 || (TRUSTED_DOMAINS || []).some(d => url.indexOf(d) === 0))) {
|
||||
// 从 JWT payload 中提取 openid 和 unionid
|
||||
const isTrusted = url.indexOf(HTTP_REQUEST_URL) === 0 || (TRUSTED_DOMAINS || []).some(d => url.indexOf(d) === 0);
|
||||
if (isTrusted && url.indexOf('token=') === -1) {
|
||||
// 即使没有 token(用户已退出),只要缓存里有 openid 仍注入身份
|
||||
// 微信匿名标识同小程序内永久稳定,退出后跳 H5 不应丢失
|
||||
let openid = store.state.app.openid;
|
||||
let unionid = store.state.app.unionid || '';
|
||||
console.log('[GoUrl] store中 unionid=' + (store.state.app.unionid || '(空)'));
|
||||
if (!openid) {
|
||||
try { openid = uni.getStorageSync('OPENID'); } catch (e) {}
|
||||
}
|
||||
if (!unionid) {
|
||||
try {
|
||||
unionid = uni.getStorageSync('UNIONID');
|
||||
console.log('[GoUrl] 缓存中 unionid=' + (unionid || '(空)'));
|
||||
} catch (e) {}
|
||||
}
|
||||
if (!openid) { try { openid = uni.getStorageSync('OPENID'); } catch (e) {} }
|
||||
if (!unionid) { try { unionid = uni.getStorageSync('UNIONID'); } catch (e) {} }
|
||||
const token = store.state.app.token;
|
||||
if ((!openid || !unionid) && token) {
|
||||
try {
|
||||
let parts = token.split('.');
|
||||
@@ -245,38 +239,32 @@ export default {
|
||||
const data = JSON.parse(base64Decode(payload));
|
||||
if (!openid) openid = data.openid || '';
|
||||
if (!unionid) unionid = data.unionid || '';
|
||||
console.log('[GoUrl] JWT中 unionid=' + (data.unionid || '(空)'));
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
// 最后兜底:从用户信息缓存中读 unionid
|
||||
if (!unionid) {
|
||||
try {
|
||||
const userInfo = uni.getStorageSync('user_info');
|
||||
if (userInfo) {
|
||||
const info = typeof userInfo === 'string' ? JSON.parse(userInfo) : userInfo;
|
||||
unionid = info.unionid || '';
|
||||
console.log('[GoUrl] userInfo中 unionid=' + (info.unionid || '(空)'));
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
console.log('[GoUrl] 最终参数: openid=' + (openid || '(空)') + ', unionid=' + (unionid || '(空)') + ', t=' + Math.floor(Date.now() / 1000));
|
||||
if (!openid) {
|
||||
// 无 openid:不拦截,匿名进入 H5(需要身份时由 H5 调 bridge.requireAuth() 再授权)
|
||||
console.log('[auth-flow] JumpPath: 🔓 无 openid,匿名跳转 H5(不弹授权,按需授权由 H5 requireAuth 触发)');
|
||||
uni.navigateTo({
|
||||
url: `/pages/annex/web_view/index?url=${encodeURIComponent(openUrl)}`
|
||||
});
|
||||
return;
|
||||
if (openid) {
|
||||
const joiner = url.indexOf('?') !== -1 ? '&' : '?';
|
||||
const t = Math.floor(Date.now() / 1000);
|
||||
openUrl = url + joiner + 'openid=' + encodeURIComponent(openid);
|
||||
if (unionid) {
|
||||
openUrl += '&unionid=' + encodeURIComponent(unionid);
|
||||
}
|
||||
openUrl += '&t=' + t;
|
||||
console.log('[auth-flow] JumpPath: ✅ 有 openid (token=' + (token ? '有' : '无') + '),注入身份跳转 web_view (unionid ' + (unionid ? '已携带' : '为空') + ')');
|
||||
} else {
|
||||
// 无 openid:调 silenceAuthNoLogin 拿 openid
|
||||
// 走 web_view 让 _initWebView 用 _fetchOpenidAndLoad 拿 openid
|
||||
console.log('[auth-flow] JumpPath: 🔑 无 openid,跳转 web_view 由 _fetchOpenidAndLoad 处理');
|
||||
}
|
||||
const joiner = url.indexOf('?') !== -1 ? '&' : '?';
|
||||
const t = Math.floor(Date.now() / 1000);
|
||||
openUrl = url + joiner + 'openid=' + encodeURIComponent(openid);
|
||||
if (unionid) {
|
||||
openUrl += '&unionid=' + encodeURIComponent(unionid);
|
||||
}
|
||||
openUrl += '&t=' + t;
|
||||
console.log('[auth-flow] JumpPath: ✅ 有 openid,注入身份跳转 web_view (unionid ' + (unionid ? '已携带' : '为空') + ')');
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: `/pages/annex/web_view/index?url=${encodeURIComponent(openUrl)}`
|
||||
|
||||
Reference in New Issue
Block a user