const auth = require('../../../utils/auth'); const PAGE_SIZE = 20; Page({ data: { orgName: '', loading: false, noMore: false, pageNo: 1, total: 0, teams: [] }, onLoad() { this.loadTeams(true); }, onPullDownRefresh() { this.loadTeams(true).finally(() => wx.stopPullDownRefresh()); }, async loadTeams(refresh = false) { if (this.data.loading) return; const pageNo = refresh ? 1 : this.data.pageNo; if (!refresh && this.data.noMore) return; this.setData({ loading: true }); try { const res = await auth.fetchMyTeams({ pageNo, pageSize: PAGE_SIZE }); const rows = (res && res.rows) || []; const total = (res && res.total) || 0; const newTeams = refresh ? rows : [...this.data.teams, ...rows]; const noMore = newTeams.length >= total; this.setData({ teams: newTeams, pageNo: pageNo + 1, total, noMore }); } catch (err) { wx.showToast({ title: err?.message || '加载失败', icon: 'none' }); } finally { this.setData({ loading: false }); } }, onBack() { if (getCurrentPages().length > 1) { wx.navigateBack(); } else { wx.switchTab({ url: '/pages/mine/mine' }); } }, onViewOrgPoints() { wx.showToast({ title: '单位积分功能开发中', icon: 'none' }); }, onTeamTap(e) { const { id } = e.currentTarget.dataset; wx.navigateTo({ url: `/subpackages/mine/team-detail/team-detail?id=${id}` }); } });