实现活动报名页面跳转0.5
This commit is contained in:
parent
539d4be245
commit
9a8a087594
|
|
@ -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",
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
url: `/pages/activity/application?actId=${activity.id}`,
|
||||
});
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
url: `/pages/activity/application?actId=${this.activityData.id}`,
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user