注册成功后保存用户id与手机号
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 44s

This commit is contained in:
kk
2026-07-11 18:30:16 +08:00
parent d392ff98b7
commit 842defea21
+6 -3
View File
@@ -183,15 +183,18 @@ export default {
}); });
const ret = res.data || {}; const ret = res.data || {};
console.log('[register] 注册响应:', JSON.stringify(ret, null, 2));
if (ret.code === 0 && ret.data) { if (ret.code === 0 && ret.data) {
// 保存 token // 保存 token
uni.setStorageSync('token', ret.data.token); uni.setStorageSync('token', ret.data.token);
// 存储 user_info至少有 user_id 就能开门 // 存储 user_info接口返回 user_info.user_id 和 phone
const existing = uni.getStorageSync('user_info') || {}; const existing = uni.getStorageSync('user_info') || {};
const apiUserInfo = ret.data.user_info || {};
const userInfo = { const userInfo = {
user_id: ret.data.user_id || existing.user_id || '', user_id: apiUserInfo.user_id || existing.user_id || '',
phone: this.phone || existing.phone || '', phone: apiUserInfo.phone || this.phone || existing.phone || '',
nickname: existing.nickname || '', nickname: existing.nickname || '',
avatar: existing.avatar || '', avatar: existing.avatar || '',
}; };