From c216865852b3ff3092aa63cafabf1743816fb7f7 Mon Sep 17 00:00:00 2001 From: Karlcarlo Date: Sat, 19 Sep 2026 17:41:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(user-center):=20=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E9=A1=B5=20submitAuth=20=E5=B8=A6=20unionid=EF=BC=88=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=B8=AD=E5=BF=83=E8=BA=AB=E4=BB=BD=E9=94=AE=EF=BC=8C?= =?UTF-8?q?=E9=A2=84=E7=95=99=E5=8A=9F=E8=83=BD=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 getUnionid()(store/Cache 'UNIONID') - POST /auth/profile 增加 unionid 参数:box_app 授权成功自动推送用户中心并回写 openid→unionid 映射 - 没拿到 unionid 也不影响授权(后端映射兜底) - 配套:box_app 1269058(已部署);需重新发版生效 --- pages/annex/auth/index.vue | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pages/annex/auth/index.vue b/pages/annex/auth/index.vue index be7b553..d21c33a 100644 --- a/pages/annex/auth/index.vue +++ b/pages/annex/auth/index.vue @@ -78,6 +78,15 @@ return ''; } + /* unionid:用户中心身份键(预留功能)。小程序登录态静默缓存(store/Cache 'UNIONID'); + 带上后 box_app 授权成功自动推送用户中心并回写 openid→unionid 映射。 */ + function getUnionid() { + let uid = store.state.app.unionid; + if (uid) return uid; + try { uid = uni.getStorageSync('UNIONID'); } catch (e) {} + return uid || ''; + } + export default { data() { return { @@ -141,7 +150,11 @@ } const openid = getOpenid() || this.openid; if (!openid) return uni.showToast({ title: '未获得 openid,请先登录', icon: 'none' }); + /* unionid:用户中心身份键(预留)。带上后 box_app 授权成功自动推送用户中心 + 并回写 openid→unionid 映射;没拿到也不影响授权(后端可映射兜底)。 */ + const unionid = getUnionid(); const api = 'https://mp.yizhezhe.com/api/mp/public/auth/profile?openid=' + encodeURIComponent(openid) + + (unionid ? '&unionid=' + encodeURIComponent(unionid) : '') + (this._authCode ? '&code=' + encodeURIComponent(this._authCode) : '') + (this.authNickname ? '&nickname=' + encodeURIComponent(this.authNickname) : '') + (this.authAvatar ? '&avatar=' + encodeURIComponent(this.authAvatar) : '');