From 58d9f460b2f8c34430285115e2557d18333c5cab Mon Sep 17 00:00:00 2001 From: Codex Assistant <codex@example.com> Date: 星期三, 08 十月 2025 14:16:55 +0800 Subject: [PATCH] feat: 修复Player实体phone字段数据冗余问题并优化小程序报名逻辑 --- wx/pages/index/index.js | 81 ++++++++++++++++++++++++---------------- 1 files changed, 49 insertions(+), 32 deletions(-) diff --git a/wx/pages/index/index.js b/wx/pages/index/index.js index 4c96146..cf405ea 100644 --- a/wx/pages/index/index.js +++ b/wx/pages/index/index.js @@ -162,7 +162,7 @@ }, // 鍔犺浇璧涗簨鍒楄〃 - loadActivities() { + loadActivities(isLoadMore = false) { this.setData({ loading: true }) const { currentPage, pageSize, searchKeyword, filterStatus } = this.data @@ -170,9 +170,21 @@ // 鍚嶇О鎼滅储鏉′欢 const nameFilter = searchKeyword || "" + // 鐘舵�佺瓫閫夋潯浠讹細灏嗗墠绔殑绛涢�夌姸鎬佽浆鎹负鍚庣鐨剆tate鍙傛暟 + let stateFilter = null + if (filterStatus !== 'all') { + // 鏍规嵁filterStatus鏄犲皠鍒板搴旂殑state鍊� + const stateMapping = { + 'upcoming': 1, // 鍗冲皢寮�濮� + 'ongoing': 2, // 杩涜涓� + 'ended': 3 // 宸茬粨鏉� + } + stateFilter = stateMapping[filterStatus] + } + return app.graphqlRequest(` - query getActivities($page: Int!, $size: Int!, $name: String) { - activities(page: $page, size: $size, name: $name) { + query getActivities($page: Int!, $size: Int!, $name: String, $state: Int) { + activities(page: $page, size: $size, name: $name, state: $state) { content { id name @@ -201,7 +213,8 @@ `, { page: currentPage, size: pageSize, - name: nameFilter + name: nameFilter, + state: stateFilter }).then(data => { if (data.activities) { let newActivities = data.activities.content @@ -211,20 +224,15 @@ } catch (e) {} // 涓烘瘡涓椿鍔ㄦ坊鍔犲悕绉版枃瀛� - newActivities = newActivities.map(activity => ({ - ...activity, - nameText: (activity.name || '娲诲姩').substring(0, 2) - })) + // newActivities = newActivities.map(activity => ({ + // ...activity, + // nameText: (activity.name || '娲诲姩').substring(0, 2) + // })) - // 鏍规嵁绛涢�夌姸鎬佽繃婊ゆ椿鍔� - if (filterStatus !== 'all') { - newActivities = newActivities.filter(activity => activity.state === filterStatus) - } - - // 鍚堝苟鏁版嵁 - const mergedActivities = currentPage === 1 - ? newActivities - : [...this.data.activities, ...newActivities] + // 鍚堝苟鏁版嵁锛氬彧鏈夊湪鐪熸鐨勫姞杞芥洿澶氭椂鎵嶈拷鍔狅紝鍏朵粬鎯呭喌閮芥槸鍏ㄩ噺鏇挎崲 + const mergedActivities = isLoadMore && this.data.activities.length > 0 + ? [...this.data.activities, ...newActivities] + : newActivities this.setData({ activities: mergedActivities, @@ -244,7 +252,7 @@ this.setData({ currentPage: this.data.currentPage + 1 }) - this.loadActivities() + this.loadActivities(true) // 浼犲叆true琛ㄧず杩欐槸鍔犺浇鏇村 }, // 杞挱鍥惧垏鎹� @@ -329,14 +337,6 @@ utils.navigateTo('/pages/activity/detail', { id: activityId }) }, - // 鐐瑰嚮璧涗簨鍗$墖 - onActivityTap(e) { - const index = e.currentTarget.dataset.index - const activity = this.data.activities[index] - if (activity) { - this.goToActivityDetail(activity.id) - } - }, // 鏍煎紡鍖栨棩鏈� formatDate(date) { @@ -366,12 +366,29 @@ const v = utils.formatDate(date, 'YYYY-MM-DD') return v && typeof v === 'string' && v.trim() ? v : '鈥�' }, - - // 鐐瑰嚮鈥滆鎯呪�濇寜閽紙涓庡崱鐗囩偣鍑讳竴鑷达級 - onDetailTap(e) { - const id = e.currentTarget.dataset.id - if (id) { - this.goToActivityDetail(id) + onTest(e){ + const activityId = e.currentTarget.dataset.id + const xid = e.currentTarget.dataset.xid; + const idx = e.currentTarget.dataset.idx; + + // 绠�鍖栫殑璋冭瘯淇℃伅 + console.log('鐐瑰嚮娲诲姩璇︽儏 - ID:', activityId, '鍚嶇О:', xid, '绱㈠紩:', idx) + + if (activityId) { + this.goToActivityDetail(activityId) + } + }, + // 鐐瑰嚮"璇︽儏"鎸夐挳锛堜笌鍗$墖鐐瑰嚮涓�鑷达級 + onActivityDetailTap(e) { + const activityId = e.currentTarget.dataset.id + const xid = e.currentTarget.dataset.xid; + const idx = e.currentTarget.dataset.idx; + + // 绠�鍖栫殑璋冭瘯淇℃伅 + console.log('鐐瑰嚮娲诲姩璇︽儏 - ID:', activityId, '鍚嶇О:', xid, '绱㈠紩:', idx) + + if (activityId) { + this.goToActivityDetail(activityId) } }, -- Gitblit v1.8.0