Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5bb31516a0 | |||
| 2560d9d529 | |||
| 6534723050 |
@@ -0,0 +1 @@
|
||||
2K94E8Rn63mn6Nys
|
||||
+5
-4
@@ -25,10 +25,11 @@
|
||||
const code = urlParams.get('code');
|
||||
|
||||
if (code) {
|
||||
// 有 code → 进入授权 Loading 页处理
|
||||
const loadingUrl = deviceId
|
||||
? `/pages/auth/loading?device_id=${deviceId}`
|
||||
: '/pages/auth/loading';
|
||||
// 有 code → 进入授权 Loading 页处理,保留 code 参数
|
||||
let loadingUrl = '/pages/auth/loading?code=' + encodeURIComponent(code);
|
||||
if (deviceId) {
|
||||
loadingUrl += '&device_id=' + deviceId;
|
||||
}
|
||||
uni.redirectTo({ url: loadingUrl });
|
||||
return;
|
||||
}
|
||||
|
||||
+2
-2
@@ -8,8 +8,8 @@ const dev = {
|
||||
// 网关地址(vms-gateway,端口 4001)— 用户授权、短信等接口走网关
|
||||
apiGatewayUrl: 'https://gateway.arklinksmart.cn',
|
||||
|
||||
// 授权回调地址(支付宝/微信 OAuth redirect_uri)
|
||||
authRedirectUri: 'https://gateway.arklinksmart.cn/api/v1/user/auth/callback',
|
||||
// 授权回调地址(微信 OAuth redirect_uri,必须 HTTPS,指向前端页面)
|
||||
authRedirectUri: 'https://m.arklinksmart.cn/pages/auth/loading',
|
||||
|
||||
// 开发阶段硬编码 Token(生产环境应从登录流程获取)
|
||||
bearerToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImRlZXB2ZW5kaW5nIiwic3ViIjoiMTY0MDI0MTEyNiIsImZyb20iOiJwb3MiLCJyb2xlIjoicG9zIiwibWFpbmJvYXJkX2lkIjoiVDEwMDIiLCJwb3Nfc24iOiIxNjQwMjQxMTI2IiwiaWF0IjoxNzc4NDkxOTA3LCJleHAiOjE3NzkwOTY3MDd9.DjscZtrTCr30XOngToUifxoel4q2EGES_uqGQernkvg',
|
||||
|
||||
+2
-2
@@ -8,8 +8,8 @@ const prod = {
|
||||
// 网关地址(vms-gateway)— 用户授权、短信等接口走网关
|
||||
apiGatewayUrl: 'https://gateway.arklinksmart.cn',
|
||||
|
||||
// 授权回调地址(支付宝/微信 OAuth redirect_uri)
|
||||
authRedirectUri: 'https://gateway.arklinksmart.cn/api/v1/user/auth/callback',
|
||||
// 授权回调地址(微信 OAuth redirect_uri,必须 HTTPS,指向前端页面)
|
||||
authRedirectUri: 'https://m.arklinksmart.cn/pages/auth/loading',
|
||||
|
||||
// 生产环境 Token 从登录流程获取,此处为空
|
||||
bearerToken: '',
|
||||
|
||||
@@ -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 → 调用后端登录
|
||||
@@ -56,9 +60,9 @@ export default {
|
||||
try {
|
||||
this.statusText = '正在获取授权...';
|
||||
|
||||
// 构建回调地址(当前页面地址)
|
||||
const redirectUri = encodeURIComponent(
|
||||
window.location.origin + window.location.pathname
|
||||
// 回调地址必须是 HTTPS,使用配置文件中的地址
|
||||
const redirectUri = config.authRedirectUri || (
|
||||
window.location.origin.replace(/^http:/, 'https:') + window.location.pathname
|
||||
);
|
||||
|
||||
const res = await gatewayGet('/api/v1/user/auth/url', {
|
||||
|
||||
Reference in New Issue
Block a user