feat(user-center): 授权页 submitAuth 带 unionid(用户中心身份键,预留功能)

- 新增 getUnionid()(store/Cache 'UNIONID')
- POST /auth/profile 增加 unionid 参数:box_app 授权成功自动推送用户中心并回写 openid→unionid 映射
- 没拿到 unionid 也不影响授权(后端映射兜底)
- 配套:box_app 1269058(已部署);需重新发版生效
This commit is contained in:
2026-09-19 17:41:02 +08:00
parent 6f033db7d4
commit c216865852

View File

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