feat(auth): 小程序绑定手机改走平台 /auth/bind-phone —— 按手机号合并并切换新令牌

This commit is contained in:
Pine
2026-08-26 12:15:41 +08:00
parent a39fbc7955
commit 294178df90
+8 -7
View File
@@ -92,15 +92,16 @@ export async function updateProfile(body) {
return data;
}
/* ---------------- 手机绑定(培训 /api/auth,阶段3 读写平台 users + 验平台 JWT ---------------- */
/** 绑定手机:验证码校验后把手机号挂到当前账号 */
/* ---------------- 手机绑定(平台 /auth,统一账号;绑定即按手机号合并去重 ---------------- */
/** 绑定手机:若该手机号已被其它账号占用,后端会按手机号把两个账号合并为同一账号,
* 并返回合并后账号的新令牌 —— 这里必须切换到新令牌,避免用已失效的旧令牌。 */
export async function bindPhone(phone, code) {
const data = await request('POST', '/api/auth/bind-phone', { phone, code }, true);
if (data.ok) {
const u = getUser() || {};
Taro.setStorageSync('pine_user', { ...u, phone, phoneBound: true });
const data = await request('POST', '/auth/bind-phone', { phone, code }, true);
if (data.token) {
Taro.setStorageSync('pine_token', data.token);
Taro.setStorageSync('pine_user', JSON.stringify(pickUser(data)));
}
return data;
return { ok: true, phone, phoneBound: true, ...data };
}
/** 微信官方手机号一键绑定(getPhoneNumber 回调 code */