post请求用户授权信息
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 42s

This commit is contained in:
kk
2026-07-11 11:59:09 +08:00
parent 258fa4a9f5
commit 925ebe9bb9
2 changed files with 31 additions and 6 deletions
+11 -1
View File
@@ -344,8 +344,18 @@ export default {
if (this.deviceId) {
stateObj.device_id = this.deviceId;
}
const stateVal = encodeURIComponent(JSON.stringify(stateObj));
// 解析 auth_url,安全地设置 state 参数(避免重复)
let authUrl = data.data.auth_url;
authUrl += (authUrl.includes('?') ? '&' : '?') + 'state=' + encodeURIComponent(JSON.stringify(stateObj));
try {
const urlObj = new URL(authUrl);
urlObj.searchParams.set('state', stateVal);
authUrl = urlObj.toString();
} catch (_) {
// URL 解析失败时直接拼接
authUrl += (authUrl.includes('?') ? '&' : '?') + 'state=' + stateVal;
}
console.log('[index] 跳转授权页:', authUrl);
// 跳转微信授权页(弹窗确认)
window.location.href = authUrl;
} else {