Browse Source

登录弹出组件加入对首页游客登录的事件监听;首页游客登录成功后,重新加载页面;

zhaowenkang/feature-20251028181547-行情页面
宋杰 4 weeks ago
parent
commit
1922787df7
  1. 5
      components/login-prompt.vue
  2. 30
      pages/home/home.vue

5
components/login-prompt.vue

@ -85,6 +85,11 @@ const continueAsVisitor = async () => {
if (res.code === 200) {
userStore.setUserInfo(res.data);
hide();
//
uni.$emit('visitorLoginSuccess', {
userInfo: res.data
});
}
};

30
pages/home/home.vue

@ -369,6 +369,9 @@ export default {
// TCP
this.initTcpListeners()
//
uni.$on('visitorLoginSuccess', this.handleVisitorLoginSuccess)
// TCP
this.$nextTick(() => {
console.log('页面渲染完成,开始自动连接TCP服务器...')
@ -421,9 +424,36 @@ export default {
// TCP
this.removeTcpListeners()
//
uni.$off('visitorLoginSuccess', this.handleVisitorLoginSuccess)
},
methods: {
//
handleVisitorLoginSuccess(data) {
console.log('收到游客登录成功事件:', data)
//
this.reloadPageData()
},
//
reloadPageData() {
console.log('重新加载页面数据...')
// store
this.userStore = useUserStore()
//
if (this.userStore.userInfo && this.userStore.userInfo.isVisitor) {
console.log('游客登录成功,加载默认自选股')
this.loadGuestDefaultStocks()
} else if (this.userStore.userInfo && !this.userStore.userInfo.isVisitor) {
console.log('用户登录,加载自选股数据')
this.loadMySelectionsData()
}
},
//
debounce(fn, delay = 300) {
if (this.debounceTimer) clearTimeout(this.debounceTimer)

Loading…
Cancel
Save