Compare commits

...

3 Commits

Author SHA1 Message Date
kk 020e131df0 解决user_id为空提示
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 42s
2026-07-11 20:43:56 +08:00
kk 533170f0a9 接口返回数据结构问题处理
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 39s
2026-07-11 20:33:58 +08:00
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
2 changed files with 15 additions and 12 deletions
+4 -2
View File
@@ -151,17 +151,19 @@ export default {
}, },
methods: { methods: {
// 外部调用:启动开门流程 // 外部调用:启动开门流程
async open() { async open(userId) {
if (this.step) return; if (this.step) return;
this.cancelled = false; this.cancelled = false;
this.step = 'opening'; this.step = 'opening';
const uid = userId || this.userId;
try { try {
const res = await post('/device-scan/open', { const res = await post('/device-scan/open', {
device_id: this.deviceId, device_id: this.deviceId,
door_index: 0, door_index: 0,
user_id: this.userId user_id: uid
}); });
const ret = res.data || {}; const ret = res.data || {};
+11 -10
View File
@@ -181,7 +181,7 @@ export default {
loading: false, loading: false,
categoryList: [], categoryList: [],
activeCategory: 'all', activeCategory: 'all',
userInfo: { nickname: '', phone: '', avatar: '' }, userInfo: { user_id: '', nickname: '', phone: '', avatar: '' },
avatarClickCount: 0, avatarClickCount: 0,
avatarClickTimer: null, avatarClickTimer: null,
fromPage: '', // 记录从哪个页面跳转过来的 fromPage: '', // 记录从哪个页面跳转过来的
@@ -199,8 +199,7 @@ export default {
}, },
computed: { computed: {
userId() { userId() {
const info = getCachedUserInfo(); return this.userInfo.user_id || '';
return (info && info.user_id) || '';
}, },
canGoBack() { canGoBack() {
// 有上一页,或者从 tab 切换过来的,都可以返回 // 有上一页,或者从 tab 切换过来的,都可以返回
@@ -304,7 +303,7 @@ export default {
if (cached) { if (cached) {
this.userInfo = { ...this.userInfo, ...cached }; this.userInfo = { ...this.userInfo, ...cached };
} else { } else {
this.userInfo = { nickname: '', phone: '', avatar: '' }; this.userInfo = { user_id: '', nickname: '', phone: '', avatar: '' };
} }
console.log('[index] this.userInfo:', JSON.stringify(this.userInfo, null, 2)); console.log('[index] this.userInfo:', JSON.stringify(this.userInfo, null, 2));
}, },
@@ -317,6 +316,7 @@ export default {
this.userInfo = { ...this.userInfo, ...cached }; this.userInfo = { ...this.userInfo, ...cached };
} else { } else {
this.userInfo = { this.userInfo = {
user_id: config.mockUser.user_info.user_id || '',
nickname: config.mockUser.user_info.nickname || '', nickname: config.mockUser.user_info.nickname || '',
phone: config.mockUser.user_info.phone || '', phone: config.mockUser.user_info.phone || '',
avatar: config.mockUser.user_info.avatar || '', avatar: config.mockUser.user_info.avatar || '',
@@ -418,14 +418,15 @@ export default {
const openId = uni.getStorageSync('openid') || ''; const openId = uni.getStorageSync('openid') || '';
const infoRes = await gatewayGet('/api/v1/user/info', { open_id: openId }); const infoRes = await gatewayGet('/api/v1/user/info', { open_id: openId });
const infoData = (infoRes.data || {}).data || {}; const infoData = (infoRes.data || {}).data || {};
if (infoData.user_id) { const userInfo = infoData.user_info || {};
if (userInfo.user_id) {
const existing = getCachedUserInfo() || {}; const existing = getCachedUserInfo() || {};
uni.setStorageSync('user_info', { uni.setStorageSync('user_info', {
...existing, ...existing,
user_id: infoData.user_id, user_id: userInfo.user_id,
nickname: infoData.nickname || existing.nickname || '', nickname: userInfo.nickname || existing.nickname || '',
avatar: infoData.avatar || existing.avatar || '', avatar: userInfo.avatar || existing.avatar || '',
phone: infoData.phone || existing.phone || '', phone: userInfo.phone || existing.phone || '',
}); });
this.loadUserInfo(); this.loadUserInfo();
} }
@@ -440,7 +441,7 @@ export default {
} }
// 调用组件方法启动开门流程 // 调用组件方法启动开门流程
this.$refs.doorPanel.open(); this.$refs.doorPanel.open(this.userId);
}, },
handleMenuClick(item) { handleMenuClick(item) {
switch (item.action) { switch (item.action) {