|
|
@ -369,6 +369,9 @@ export default { |
|
|
// 初始化TCP连接监听器 |
|
|
// 初始化TCP连接监听器 |
|
|
this.initTcpListeners() |
|
|
this.initTcpListeners() |
|
|
|
|
|
|
|
|
|
|
|
// 监听游客登录成功事件 |
|
|
|
|
|
uni.$on('visitorLoginSuccess', this.handleVisitorLoginSuccess) |
|
|
|
|
|
|
|
|
// 页面渲染完成后自动连接两个TCP连接 |
|
|
// 页面渲染完成后自动连接两个TCP连接 |
|
|
this.$nextTick(() => { |
|
|
this.$nextTick(() => { |
|
|
console.log('页面渲染完成,开始自动连接TCP服务器...') |
|
|
console.log('页面渲染完成,开始自动连接TCP服务器...') |
|
|
@ -421,9 +424,36 @@ export default { |
|
|
|
|
|
|
|
|
// 移除TCP监听器,防止内存泄漏 |
|
|
// 移除TCP监听器,防止内存泄漏 |
|
|
this.removeTcpListeners() |
|
|
this.removeTcpListeners() |
|
|
|
|
|
|
|
|
|
|
|
// 移除游客登录成功事件监听器 |
|
|
|
|
|
uni.$off('visitorLoginSuccess', this.handleVisitorLoginSuccess) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
methods: { |
|
|
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) { |
|
|
debounce(fn, delay = 300) { |
|
|
if (this.debounceTimer) clearTimeout(this.debounceTimer) |
|
|
if (this.debounceTimer) clearTimeout(this.debounceTimer) |
|
|
|