Compare commits

...

2 Commits

Author SHA1 Message Date
kk b1924e2623 userId 改为依赖 this.userInfo.user_id
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 47s
2026-07-11 20:29:00 +08:00
kk e12663052f 查询用户信息接口增加open_id参数
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 47s
2026-07-11 20:21:58 +08:00
+6 -5
View File
@@ -181,7 +181,7 @@ export default {
loading: false,
categoryList: [],
activeCategory: 'all',
userInfo: { nickname: '', phone: '', avatar: '' },
userInfo: { user_id: '', nickname: '', phone: '', avatar: '' },
avatarClickCount: 0,
avatarClickTimer: null,
fromPage: '', // 记录从哪个页面跳转过来的
@@ -199,8 +199,7 @@ export default {
},
computed: {
userId() {
const info = getCachedUserInfo();
return (info && info.user_id) || '';
return this.userInfo.user_id || '';
},
canGoBack() {
// 有上一页,或者从 tab 切换过来的,都可以返回
@@ -304,7 +303,7 @@ export default {
if (cached) {
this.userInfo = { ...this.userInfo, ...cached };
} else {
this.userInfo = { nickname: '', phone: '', avatar: '' };
this.userInfo = { user_id: '', nickname: '', phone: '', avatar: '' };
}
console.log('[index] this.userInfo:', JSON.stringify(this.userInfo, null, 2));
},
@@ -317,6 +316,7 @@ export default {
this.userInfo = { ...this.userInfo, ...cached };
} else {
this.userInfo = {
user_id: config.mockUser.user_info.user_id || '',
nickname: config.mockUser.user_info.nickname || '',
phone: config.mockUser.user_info.phone || '',
avatar: config.mockUser.user_info.avatar || '',
@@ -415,7 +415,8 @@ export default {
// 检查用户信息,若缓存中没有则调接口获取
if (!this.userId) {
try {
const infoRes = await gatewayGet('/api/v1/user/info', {});
const openId = uni.getStorageSync('openid') || '';
const infoRes = await gatewayGet('/api/v1/user/info', { open_id: openId });
const infoData = (infoRes.data || {}).data || {};
if (infoData.user_id) {
const existing = getCachedUserInfo() || {};