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) : '');