feat(glt): 完善水票总数获取逻辑并优化用户体验
- 新增 normalizeTotal 函数处理多种数据格式的总数解析 - 支持通过 userId 参数查询指定用户的水票总数 - 添加多服务器地址尝试机制提高接口可用性 - 优化首页和用户中心页面的水票总数加载逻辑 - 修复水票页面滚动区域高度计算问题 - 移除自动跳转登录页面的定时器逻辑 - 个人中心页面支持下拉刷新统计数据 - 统一请求参数传递方式简化代码结构
This commit is contained in:
@@ -90,11 +90,14 @@ function Home() {
|
||||
|
||||
const reload = () => {
|
||||
const token = Taro.getStorageSync('access_token')
|
||||
if (!token) {
|
||||
const userIdRaw = Taro.getStorageSync('UserId')
|
||||
const userId = Number(userIdRaw)
|
||||
const hasUserId = Number.isFinite(userId) && userId > 0
|
||||
if (!token && !hasUserId) {
|
||||
setTicketTotal(0)
|
||||
return
|
||||
}
|
||||
getMyGltUserTicketTotal()
|
||||
getMyGltUserTicketTotal(hasUserId ? userId : undefined)
|
||||
.then((total) => setTicketTotal(typeof total === 'number' ? total : 0))
|
||||
.catch((err) => {
|
||||
console.error('首页水票总数加载失败:', err)
|
||||
|
||||
Reference in New Issue
Block a user