From 9a8a087594dc7ad9901a644d4363feb6ed92044b Mon Sep 17 00:00:00 2001 From: WindowBird <13870814+windows-bird@user.noreply.gitee.com> Date: Fri, 15 Aug 2025 10:34:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=B4=BB=E5=8A=A8=E6=8A=A5?= =?UTF-8?q?=E5=90=8D=E9=A1=B5=E9=9D=A2=E8=B7=B3=E8=BD=AC0.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/activity/activity.vue | 61 ++----------------------------- pages/activity/activityDetail.vue | 61 ++----------------------------- pages/activity/application.vue | 8 +++- 3 files changed, 14 insertions(+), 116 deletions(-) diff --git a/pages/activity/activity.vue b/pages/activity/activity.vue index 22dba9a..fc20ba9 100644 --- a/pages/activity/activity.vue +++ b/pages/activity/activity.vue @@ -156,65 +156,12 @@ export default { }, // 处理报名 - async handleRegister(activity) { + handleRegister(activity) { console.log("报名活动:", activity); - // 检查用户是否登录 - const userInfo = uni.getStorageSync("userInfo"); - if (!userInfo) { - uni.showModal({ - title: "提示", - content: "请先登录后再报名活动", - confirmText: "去登录", - success: (res) => { - if (res.confirm) { - // 跳转到登录页 - uni.navigateTo({ - url: "/pages/login/login", - }); - } - }, - }); - return; - } - - // 确认报名 - uni.showModal({ - title: "确认报名", - content: `确定要报名参加"${activity.name}"活动吗?`, - success: async (res) => { - if (res.confirm) { - try { - const response = await activityApi.registerActivity({ - activityId: activity.id, - userId: userInfo.id, - userName: userInfo.userName || userInfo.nickName, - phone: userInfo.phone, - }); - - if (response.code === 200) { - uni.showToast({ - title: "报名成功", - icon: "success", - }); - - // 刷新活动列表以更新报名状态 - this.refreshData(); - } else { - uni.showToast({ - title: response.msg || "报名失败", - icon: "none", - }); - } - } catch (error) { - console.error("报名失败:", error); - uni.showToast({ - title: "报名失败,请稍后重试", - icon: "none", - }); - } - } - }, + // 直接跳转到活动报名页面 + uni.navigateTo({ + url: `/pages/activity/application?actId=${activity.id}`, }); }, }, diff --git a/pages/activity/activityDetail.vue b/pages/activity/activityDetail.vue index 1e33d20..4e5471f 100644 --- a/pages/activity/activityDetail.vue +++ b/pages/activity/activityDetail.vue @@ -184,67 +184,14 @@ export default { }, // 处理报名 - async handleRegister() { + handleRegister() { if (!this.activityData) return; console.log("报名活动:", this.activityData); - // 检查用户是否登录 - const userInfo = uni.getStorageSync("userInfo"); - if (!userInfo) { - uni.showModal({ - title: "提示", - content: "请先登录后再报名活动", - confirmText: "去登录", - success: (res) => { - if (res.confirm) { - // 跳转到登录页 - uni.navigateTo({ - url: "/pages/login/login", - }); - } - }, - }); - return; - } - - // 确认报名 - uni.showModal({ - title: "确认报名", - content: `确定要报名参加"${this.activityData.title}"活动吗?`, - success: async (res) => { - if (res.confirm) { - try { - const response = await activityApi.registerActivity({ - activityId: this.activityData.id, - userId: userInfo.id, - userName: userInfo.userName || userInfo.nickName, - phone: userInfo.phone, - }); - - if (response.code === 200) { - uni.showToast({ - title: "报名成功", - icon: "success", - }); - - // 刷新活动详情以更新报名状态 - this.loadPageData(); - } else { - uni.showToast({ - title: response.msg || "报名失败", - icon: "none", - }); - } - } catch (error) { - console.error("报名失败:", error); - uni.showToast({ - title: "报名失败,请稍后重试", - icon: "none", - }); - } - } - }, + // 直接跳转到活动报名页面 + uni.navigateTo({ + url: `/pages/activity/application?actId=${this.activityData.id}`, }); }, diff --git a/pages/activity/application.vue b/pages/activity/application.vue index 4a398ee..66d9679 100644 --- a/pages/activity/application.vue +++ b/pages/activity/application.vue @@ -95,7 +95,7 @@ export default { searchName: "", // 活动ID - activityId: 3, + activityId: "", // 加载状态 loading: false, @@ -125,7 +125,11 @@ export default { showCustomNumberModal: false, }; }, - onLoad() { + onLoad(options) { + // 如果从其他页面传递了活动ID,使用传递的ID + if (options.actId) { + this.activityId = parseInt(options.actId); + } this.fetchActivitySlots(); }, methods: {