| | |
| | | if (token) { |
| | | this.lastToken = token |
| | | this.updateUnreadMessageBadge() |
| | | this.startMessagePolling() |
| | | // this.startMessagePolling() |
| | | } |
| | | }) |
| | | |
| | |
| | | this.updateUnreadMessageBadge() |
| | | // 重新启动轮询(如果之前已停止) |
| | | if (!this.messagePollingTimer) { |
| | | this.startMessagePolling() |
| | | // this.startMessagePolling() |
| | | } |
| | | } |
| | | }, |
| | |
| | | try { |
| | | if (!getToken()) { |
| | | console.log('用户未登录,准备跳转到登录页面') |
| | | // 保存目标页面用于登录后跳转 |
| | | if (options && options.path && |
| | | options.path !== 'pages/login' && |
| | | options.path !== 'pages/qylogin') { |
| | | // 构造完整的路径和查询参数 |
| | | let fullPath = '/' + options.path; |
| | | if (options.query) { |
| | | const queryString = Object.keys(options.query).map(key => |
| | | `${key}=${encodeURIComponent(options.query[key])}`).join('&'); |
| | | if (queryString) { |
| | | fullPath += '?' + queryString; |
| | | } |
| | | } |
| | | |
| | | // 保存目标URL到本地存储 |
| | | try { |
| | | uni.setStorageSync('targetUrl', fullPath); |
| | | } catch (e) { |
| | | console.error('保存目标URL失败:', e); |
| | | } |
| | | } |
| | | |
| | | // 使用工具类根据环境自动跳转到合适的登录页面 |
| | | redirectToLoginByEnvironment(options, this.$tab); |
| | | } else { |