Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d862cad1a0 | |||
| 85d5193071 | |||
| 9551d9d8b2 |
@@ -30,10 +30,11 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 从 URL 参数获取 code(App.vue 跳转时带过来)
|
// 从 URL 参数获取 code(App.vue 跳转时带过来)
|
||||||
let code = options.code || '';
|
// 支付宝回调参数名是 auth_code,微信是 code
|
||||||
|
let code = options.code || options.auth_code || '';
|
||||||
if (!code) {
|
if (!code) {
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
code = urlParams.get('code') || '';
|
code = urlParams.get('code') || urlParams.get('auth_code') || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 兜底:从 localStorage 恢复(页面复用时 onLoad 不触发,localStorage 由跳转函数清理)
|
// 兜底:从 localStorage 恢复(页面复用时 onLoad 不触发,localStorage 由跳转函数清理)
|
||||||
@@ -97,10 +98,11 @@ export default {
|
|||||||
window.location.origin.replace(/^http:/, 'https:') + window.location.pathname
|
window.location.origin.replace(/^http:/, 'https:') + window.location.pathname
|
||||||
);
|
);
|
||||||
|
|
||||||
// 使用 snsapi_base 静默授权,不弹窗
|
// 静默授权:微信用 snsapi_base,支付宝用 auth_base
|
||||||
|
const scopes = platform === 'alipay' ? 'auth_base' : 'snsapi_base';
|
||||||
const res = await gatewayGet('/api/v1/user/auth/url', {
|
const res = await gatewayGet('/api/v1/user/auth/url', {
|
||||||
app_no: appNo,
|
app_no: appNo,
|
||||||
scopes: 'snsapi_base',
|
scopes: scopes,
|
||||||
redirect_uri: redirectUri,
|
redirect_uri: redirectUri,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -154,6 +156,7 @@ export default {
|
|||||||
// 立即清除 URL 中的 code 参数,避免刷新重复处理
|
// 立即清除 URL 中的 code 参数,避免刷新重复处理
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
url.searchParams.delete('code');
|
url.searchParams.delete('code');
|
||||||
|
url.searchParams.delete('auth_code');
|
||||||
url.searchParams.delete('state');
|
url.searchParams.delete('state');
|
||||||
window.history.replaceState({}, '', url.toString());
|
window.history.replaceState({}, '', url.toString());
|
||||||
|
|
||||||
@@ -256,9 +259,11 @@ export default {
|
|||||||
window.location.origin.replace(/^http:/, 'https:') + window.location.pathname
|
window.location.origin.replace(/^http:/, 'https:') + window.location.pathname
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 用户信息授权:微信用 snsapi_userinfo,支付宝用 auth_user
|
||||||
|
const scopes = platform === 'alipay' ? 'auth_user' : 'snsapi_userinfo';
|
||||||
const res = await gatewayGet('/api/v1/user/auth/url', {
|
const res = await gatewayGet('/api/v1/user/auth/url', {
|
||||||
app_no: appNo,
|
app_no: appNo,
|
||||||
scopes: 'snsapi_userinfo',
|
scopes: scopes,
|
||||||
redirect_uri: redirectUri,
|
redirect_uri: redirectUri,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -313,6 +318,7 @@ export default {
|
|||||||
// 立即清除 URL 中的 code/action 参数,避免刷新重复处理
|
// 立即清除 URL 中的 code/action 参数,避免刷新重复处理
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
url.searchParams.delete('code');
|
url.searchParams.delete('code');
|
||||||
|
url.searchParams.delete('auth_code');
|
||||||
url.searchParams.delete('state');
|
url.searchParams.delete('state');
|
||||||
url.searchParams.delete('action');
|
url.searchParams.delete('action');
|
||||||
window.history.replaceState({}, '', url.toString());
|
window.history.replaceState({}, '', url.toString());
|
||||||
|
|||||||
+3
-3
@@ -6,9 +6,9 @@
|
|||||||
// app_no 编码表:platform + terminalType → app_no
|
// app_no 编码表:platform + terminalType → app_no
|
||||||
const APP_NO_MAP = {
|
const APP_NO_MAP = {
|
||||||
'wechat_h5': '60000001102001',
|
'wechat_h5': '60000001102001',
|
||||||
'wechat_mp': '600102101',
|
'wechat_mp': '60000001102101',
|
||||||
'alipay_h5': '600112001',
|
'alipay_h5': '60000001112001',
|
||||||
'alipay_mp': '600112101',
|
'alipay_mp': '60000001112101',
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user