实现活动报名页面跳转0.5

This commit is contained in:
WindowBird 2025-08-15 10:34:32 +08:00
parent 539d4be245
commit 9a8a087594
3 changed files with 14 additions and 116 deletions

View File

@ -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}`,
});
},
},

View File

@ -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}`,
});
},

View File

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