修改社区报名取消功能

This commit is contained in:
2025-10-11 22:09:53 +08:00
parent d66216c669
commit 8f79eeaae6
5 changed files with 345 additions and 67 deletions

View File

@@ -62,17 +62,29 @@
</view>
</view> -->
</view>
<!-- 取消报名按钮 -->
<view v-if="canCancel()">
<button class="cancel-btn" @click="cancelApply"
style="width: 100% !important; background-color: #ff4757 !important; color: white !important;
border: none !important; font-size: 18px !important; line-height: 2.55555556 !important;
border-radius: 5px !important; padding: 0 14px !important; box-sizing: border-box !important;
text-align: center !important; min-height: 46px !important; margin-top: 50px !important;">
取消报名
</button>
</view>
</view>
</template>
<script>
import {applyDetail} from '@/api/OneStopCommunity/apply.js'
import { applyDetail, cancelRegistration } from '@/api/OneStopCommunity/apply.js';
export default{
data(){
return{
activityInfo:{},//活动信息
applyInfo:{},//报名信息
headcount:null
headcount:null,
recordId: null
}
},
methods:{
@@ -83,9 +95,72 @@
this.activityInfo=res.data.communityActivitiesList[0]
this.applyInfo=res.data;
}
},
// 判断是否可以取消报名
canCancel() {
// 只有待审核(0)或已通过(1)的报名可以取消,已拒绝(2)的不能取消
if (this.applyInfo.auditStatus === 2) {
return false; // 已拒绝的不能取消
}
// 检查报名截止时间
if (this.activityInfo.signUpEndTime) {
const now = new Date();
const endTime = new Date(this.activityInfo.signUpEndTime);
if (now > endTime) {
return false; // 报名已截止
}
}
return true;
},
// 取消报名
cancelApply() {
uni.showModal({
title: '确认取消',
content: '确定要取消报名吗?取消后如需重新报名,请在报名截止时间前重新提交申请。',
success: async (res) => {
if (res.confirm) {
try {
uni.showLoading({
title: '取消中...'
});
const result = await cancelRegistration(this.recordId);
uni.hideLoading();
if (result.code === 200) {
uni.showToast({
title: '取消报名成功',
icon: 'success'
});
// 返回上一页并刷新
setTimeout(() => {
uni.navigateBack();
}, 1500);
} else {
uni.showToast({
title: result.msg || '取消报名失败',
icon: 'none'
});
}
} catch (error) {
uni.hideLoading();
uni.showToast({
title: '取消报名失败',
icon: 'none'
});
console.error('取消报名失败:', error);
}
}
}
});
}
},
onLoad(option) {
this.recordId = option.recordid;
this.getdetail(option.recordid)
},
}
@@ -184,5 +259,11 @@
}
}
}
.cancel-btn {
background-color: #ff4757 !important;
color: white;
margin-top: 100rpx;
}
}
</style>