sync changes: 出场顺序优化、联系人功能
This commit is contained in:
+4
-4
@@ -10,7 +10,7 @@ import request from '@/utils/request.js'
|
||||
*/
|
||||
export function getScheduleResult(competitionId) {
|
||||
return request.get('/martial/schedule/result', {
|
||||
params: { competitionId }
|
||||
competitionId
|
||||
})
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ export function saveDispatch(data) {
|
||||
*/
|
||||
export function getScheduleStatus(competitionId) {
|
||||
return request.get('/mini/schedule/status', {
|
||||
params: { competitionId }
|
||||
competitionId
|
||||
})
|
||||
}
|
||||
|
||||
@@ -106,9 +106,9 @@ export function getScheduleStatus(competitionId) {
|
||||
* @param {Number} competitionId - 赛事ID
|
||||
* @param {Number} projectId - 项目ID (可选)
|
||||
*/
|
||||
export function getLineup(competitionId, projectId) {
|
||||
export function getLineup(competitionId, projectId, orderId) {
|
||||
return request.get('/mini/schedule/lineup', {
|
||||
params: { competitionId, projectId }
|
||||
competitionId, projectId, orderId
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -124,6 +124,36 @@ export default {
|
||||
try {
|
||||
await athleteAPI.saveContact(this.formData);
|
||||
uni.showToast({ title: '保存成功', icon: 'success' });
|
||||
|
||||
// Set flag to notify previous page
|
||||
uni.setStorageSync('contactListNeedRefresh', true);
|
||||
|
||||
// Notify previous page to refresh contact list
|
||||
try {
|
||||
const pages = getCurrentPages();
|
||||
console.log('页面栈长度:', pages.length);
|
||||
console.log('页面栈:', pages);
|
||||
if (pages.length >= 2) {
|
||||
const prevPage = pages[pages.length - 2];
|
||||
console.log('上一页:', prevPage);
|
||||
// Try different ways to access the component
|
||||
const vm = prevPage.$vm || prevPage;
|
||||
console.log('vm:', vm);
|
||||
if (vm && typeof vm.loadContactList === 'function') {
|
||||
console.log('调用 loadContactList');
|
||||
vm.loadContactList();
|
||||
} else if (vm && vm.$refs && vm.$refs.page && typeof vm.$refs.page.loadContactList === 'function') {
|
||||
console.log('通过 $refs 调用');
|
||||
vm.$refs.page.loadContactList();
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('通知上一页失败:', e);
|
||||
}
|
||||
|
||||
// Also emit event as backup
|
||||
uni.$emit('contactAdded');
|
||||
|
||||
setTimeout(() => { uni.navigateBack(); }, 1500);
|
||||
} catch (err) {
|
||||
console.error('保存联系人失败:', err);
|
||||
|
||||
@@ -168,7 +168,15 @@ export default {
|
||||
})
|
||||
|
||||
let list = res.records || (Array.isArray(res) ? res : [])
|
||||
this.playerList = list.map(item => ({
|
||||
// Deduplicate by idCard
|
||||
const seen = new Set()
|
||||
const uniqueList = list.filter(item => {
|
||||
const idCard = item.idCard || item.idCardNumber
|
||||
if (idCard && seen.has(idCard)) return false
|
||||
if (idCard) seen.add(idCard)
|
||||
return true
|
||||
})
|
||||
this.playerList = uniqueList.map(item => ({
|
||||
id: item.id,
|
||||
name: item.name || item.playerName,
|
||||
idCard: item.idCard || item.idCardNumber,
|
||||
|
||||
@@ -82,6 +82,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
eventId: '',
|
||||
orderId: '',
|
||||
eventInfo: {
|
||||
id: '',
|
||||
title: '',
|
||||
@@ -96,6 +97,7 @@ export default {
|
||||
onLoad(options) {
|
||||
if (options.id) {
|
||||
this.eventId = options.id
|
||||
this.orderId = options.orderId || null
|
||||
this.loadEventDetail(options.id)
|
||||
}
|
||||
},
|
||||
@@ -192,7 +194,7 @@ export default {
|
||||
if (url) {
|
||||
// 跳转时传递赛事ID
|
||||
uni.navigateTo({
|
||||
url: `${url}?eventId=${this.eventId}`
|
||||
url: `${url}?eventId=${this.eventId}&orderId=${this.orderId || ""}`
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
|
||||
@@ -63,6 +63,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
eventId: '',
|
||||
orderId: '',
|
||||
loading: true,
|
||||
isScheduleCompleted: false,
|
||||
currentGroupIndex: 0,
|
||||
@@ -79,6 +80,7 @@ export default {
|
||||
onLoad(options) {
|
||||
if (options.eventId) {
|
||||
this.eventId = options.eventId
|
||||
this.orderId = options.orderId || null
|
||||
this.checkScheduleStatus()
|
||||
}
|
||||
},
|
||||
@@ -87,8 +89,8 @@ export default {
|
||||
async checkScheduleStatus() {
|
||||
try {
|
||||
const res = await getScheduleStatus(this.eventId)
|
||||
if (res.data) {
|
||||
this.isScheduleCompleted = res.data.isCompleted
|
||||
if (res) {
|
||||
this.isScheduleCompleted = res.isCompleted
|
||||
if (this.isScheduleCompleted) {
|
||||
await this.loadLineup()
|
||||
}
|
||||
@@ -103,9 +105,9 @@ export default {
|
||||
|
||||
async loadLineup() {
|
||||
try {
|
||||
const res = await getLineup(this.eventId)
|
||||
if (res.data && res.data.groups) {
|
||||
this.groups = res.data.groups
|
||||
const res = await getLineup(this.eventId, null, this.orderId)
|
||||
if (res && res.groups) {
|
||||
this.groups = res.groups
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载出场顺序失败:', error)
|
||||
|
||||
@@ -282,6 +282,11 @@ export default {
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
// Listen for contact added event
|
||||
uni.$on('contactAdded', () => {
|
||||
console.log('=== 收到 contactAdded 事件 ===')
|
||||
this.loadContactList()
|
||||
})
|
||||
if (options.eventId) {
|
||||
this.eventId = options.eventId
|
||||
this.loadEventDetail(options.eventId)
|
||||
@@ -309,9 +314,21 @@ export default {
|
||||
this.loadPlayerList()
|
||||
}
|
||||
},
|
||||
onUnload() {
|
||||
uni.$off('contactAdded')
|
||||
},
|
||||
onShow() {
|
||||
// Refresh contact list when returning from add-contact page
|
||||
this.loadContactList()
|
||||
console.log('=== onShow 被触发 ===')
|
||||
// Check if contact list needs refresh
|
||||
const needRefresh = uni.getStorageSync('contactListNeedRefresh')
|
||||
if (needRefresh) {
|
||||
console.log('检测到需要刷新联系人列表')
|
||||
uni.removeStorageSync('contactListNeedRefresh')
|
||||
this.loadContactList()
|
||||
} else {
|
||||
// Always refresh contact list when page shows
|
||||
this.loadContactList()
|
||||
}
|
||||
if (this.currentStep === 1) {
|
||||
if (this.isTeamProject) {
|
||||
this.loadTeamList()
|
||||
@@ -324,13 +341,19 @@ export default {
|
||||
// Contact methods
|
||||
async loadContactList() {
|
||||
try {
|
||||
console.log('=== 开始加载联系人列表 ===')
|
||||
const res = await athleteAPI.getContactList({ current: 1, size: 100 })
|
||||
this.contactList = (res.records || []).map(item => ({
|
||||
console.log('联系人API返回:', res)
|
||||
const records = res.records || res.data?.records || []
|
||||
console.log('联系人记录:', records)
|
||||
this.contactList = records.map(item => ({
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
phone: item.phone,
|
||||
idCard: item.idCard
|
||||
idCard: item.idCard,
|
||||
isDefault: item.isDefault
|
||||
}))
|
||||
console.log('处理后的联系人列表:', this.contactList)
|
||||
// Auto select default contact if exists
|
||||
if (!this.selectedContact && this.contactList.length > 0) {
|
||||
const defaultContact = this.contactList.find(c => c.isDefault) || this.contactList[0]
|
||||
|
||||
@@ -341,7 +341,7 @@ export default {
|
||||
},
|
||||
goToEventDetail(item) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/event-detail/event-detail?id=' + item.competitionId
|
||||
url: '/pages/event-detail/event-detail?id=' + item.competitionId + '&orderId=' + item.id
|
||||
});
|
||||
},
|
||||
handleViewCert(item) {
|
||||
|
||||
Reference in New Issue
Block a user