解决微信小程序首页空白问题。
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
|
||||
<script>
|
||||
import mixin from '@/uni_modules/uni-id-pages/common/login-page.mixin.js';
|
||||
import { mutations } from '@/common/store.js'
|
||||
import { store, mutations } from '@/common/store.js'
|
||||
import { getApiUrl } from '@/common/config.js'
|
||||
export default {
|
||||
mixins: [mixin],
|
||||
@@ -184,6 +184,7 @@
|
||||
email: loginData.email,
|
||||
avatar_file: loginData.avatar ? { url: loginData.avatar } : undefined
|
||||
}, { cover: true })
|
||||
console.log('[Login] Store updated successfully, hasLogin:', store.hasLogin, 'userInfo:', store.userInfo)
|
||||
} catch (e) {
|
||||
console.error('更新本地用户信息失败:', e)
|
||||
}
|
||||
@@ -196,7 +197,7 @@
|
||||
|
||||
// 更新全局角色信息
|
||||
try {
|
||||
const app = getApp();
|
||||
const app = getApp({ allowDefault: true });
|
||||
if (app && app.setGlobalRoleInfo) {
|
||||
app.setGlobalRoleInfo();
|
||||
}
|
||||
@@ -205,11 +206,32 @@
|
||||
}
|
||||
|
||||
// 登录成功后跳转到首页(接待页面)
|
||||
// 在微信小程序中增加延迟,确保store更新完全后再跳转
|
||||
// #ifdef MP-WEIXIN
|
||||
setTimeout(() => {
|
||||
console.log('[Login] Preparing to navigate after login, hasLogin:', store.hasLogin)
|
||||
uni.switchTab({
|
||||
url: '/pages/furniture_reception/furniture_reception',
|
||||
success: () => {
|
||||
console.log('[Login] Navigation successful, checking login status after navigation')
|
||||
// 延迟检查,确保页面跳转完成后再检查状态
|
||||
setTimeout(() => {
|
||||
console.log('[Login] Final check - hasLogin:', store.hasLogin, 'backend-token exists:', !!uni.getStorageSync('backend-token'))
|
||||
}, 500)
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('[Login] Navigation failed:', err)
|
||||
}
|
||||
})
|
||||
}, 500)
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
setTimeout(() => {
|
||||
uni.switchTab({
|
||||
url: '/pages/furniture_reception/furniture_reception'
|
||||
})
|
||||
}, 300)
|
||||
// #endif
|
||||
} catch (err) {
|
||||
console.error('调用登录接口失败:', err)
|
||||
uni.showToast({
|
||||
|
||||
Reference in New Issue
Block a user