diff --git a/src/pages.json b/src/pages.json index 757cf81..5ece1f9 100644 --- a/src/pages.json +++ b/src/pages.json @@ -54,6 +54,14 @@ "navigationBarTextStyle": "white" } }, + { + "path": "pages/add-team/add-team", + "style": { + "navigationBarTitleText": "新增集体", + "navigationBarBackgroundColor": "#C93639", + "navigationBarTextStyle": "white" + } + }, { "path": "pages/edit-player/edit-player", "style": { diff --git a/src/pages/add-team/add-team.vue b/src/pages/add-team/add-team.vue new file mode 100644 index 0000000..22fffe1 --- /dev/null +++ b/src/pages/add-team/add-team.vue @@ -0,0 +1,374 @@ + + + + + diff --git a/src/pages/common-info/common-info.vue b/src/pages/common-info/common-info.vue index 9a1584f..e7e2313 100644 --- a/src/pages/common-info/common-info.vue +++ b/src/pages/common-info/common-info.vue @@ -6,10 +6,10 @@ - {{ currentTab === 0 ? '新增选手' : '新增联系人' }} + {{ addButtonText }} - + @@ -21,7 +21,7 @@ 编辑 - + 删除 @@ -29,21 +29,46 @@ - + 暂无选手信息 - - + + + + + {{ item.name }} + 成员数:{{ item.memberCount || 0 }}人 + + + + + 编辑 + + + + 删除 + + + + + + + + 暂无集体信息 + + + + 暂无联系人信息 @@ -69,42 +94,53 @@ export default { }, data() { return { - tabs: ['选手', '联系人'], + tabs: ['选手', '集体', '联系人'], currentTab: 0, playerList: [], + teamList: [], showDeleteModal: false, showSuccessToast: false, - currentItem: null + currentItem: null, + deleteType: 'player' }; }, + computed: { + addButtonText() { + if (this.currentTab === 0) return '新增选手' + if (this.currentTab === 1) return '新增集体' + return '新增联系人' + }, + deleteModalTitle() { + return this.deleteType === 'team' ? '删除集体' : '删除选手' + }, + deleteModalContent() { + return this.deleteType === 'team' ? '确定要删除该集体吗?' : '确定要删除该选手吗?' + } + }, onLoad() { this.loadPlayerList() + this.loadTeamList() }, onShow() { - // 从新增/编辑页面返回时重新加载列表 this.loadPlayerList() + this.loadTeamList() }, methods: { /** - * 加载选手列表 + * Load player list */ async loadPlayerList() { try { - // 获取当前用户信息 const userInfo = getUserInfo() if (!userInfo || !userInfo.userId) { console.error('未获取到用户信息') - uni.showToast({ - title: '请先登录', - icon: 'none' - }) return } const res = await athleteAPI.getAthleteList({ current: 1, size: 100, - createUser: userInfo.userId // 只查询当前用户创建的选手 + createUser: userInfo.userId }) let list = [] @@ -114,7 +150,6 @@ export default { list = res } - // 数据映射 this.playerList = list.map(item => ({ id: item.id, name: item.name || item.playerName, @@ -128,6 +163,43 @@ export default { } }, + /** + * Load team list + */ + async loadTeamList() { + try { + const userInfo = getUserInfo() + if (!userInfo || !userInfo.userId) { + return + } + + // Try to load team list from API + if (athleteAPI.getTeamList) { + const res = await athleteAPI.getTeamList({ + current: 1, + size: 100, + createUser: userInfo.userId + }) + + let list = [] + if (res.records) { + list = res.records + } else if (Array.isArray(res)) { + list = res + } + + this.teamList = list.map(item => ({ + id: item.id, + name: item.name || item.teamName, + memberCount: item.memberCount || item.members?.length || 0 + })) + } + } catch (err) { + console.error('加载集体列表失败:', err) + this.teamList = [] + } + }, + handleTabChange(index) { this.currentTab = index; }, @@ -137,6 +209,10 @@ export default { url: '/pages/add-player/add-player' }); } else if (this.currentTab === 1) { + uni.navigateTo({ + url: '/pages/add-team/add-team' + }); + } else if (this.currentTab === 2) { uni.navigateTo({ url: '/pages/add-contact/add-contact' }); @@ -147,30 +223,42 @@ export default { url: '/pages/edit-player/edit-player?id=' + item.id }); }, - handleDelete(item) { + handleEditTeam(item) { + uni.navigateTo({ + url: '/pages/edit-team/edit-team?id=' + item.id + }); + }, + handleDelete(item, type) { this.currentItem = item; + this.deleteType = type; this.showDeleteModal = true; }, async confirmDelete() { this.showDeleteModal = false; try { - // 调用删除API - await athleteAPI.removeAthlete(this.currentItem.id) - - // 从列表中移除 - const index = this.playerList.findIndex(item => item.id === this.currentItem.id); - if (index > -1) { - this.playerList.splice(index, 1); + if (this.deleteType === 'team') { + if (athleteAPI.removeTeam) { + await athleteAPI.removeTeam(this.currentItem.id) + } + const index = this.teamList.findIndex(item => item.id === this.currentItem.id); + if (index > -1) { + this.teamList.splice(index, 1); + } + } else { + await athleteAPI.removeAthlete(this.currentItem.id) + const index = this.playerList.findIndex(item => item.id === this.currentItem.id); + if (index > -1) { + this.playerList.splice(index, 1); + } } - // 显示成功提示 this.showSuccessToast = true; setTimeout(() => { this.showSuccessToast = false; }, 2000); } catch (err) { - console.error('删除选手失败:', err) + console.error('删除失败:', err) uni.showToast({ title: '删除失败', icon: 'none'