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: {