diff --git a/src/config/dev.js b/src/config/dev.js index 52e4e4c..9d73c37 100644 --- a/src/config/dev.js +++ b/src/config/dev.js @@ -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', diff --git a/src/config/prod.js b/src/config/prod.js index 0ca7694..8b6223c 100644 --- a/src/config/prod.js +++ b/src/config/prod.js @@ -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: '', diff --git a/src/pages/auth/loading.vue b/src/pages/auth/loading.vue index 9000b71..57b00c5 100644 --- a/src/pages/auth/loading.vue +++ b/src/pages/auth/loading.vue @@ -56,9 +56,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', {