fix: 修改活动详情页面日期计算逻辑,修改评价提交校验规则
This commit is contained in:
parent
bd413f19b3
commit
f76b79c7f9
@ -798,10 +798,17 @@
|
||||
},
|
||||
async submitForm() {
|
||||
if (!this.isFormValid) {
|
||||
uni.showToast({
|
||||
title: '请填写评价内容',
|
||||
icon: 'none'
|
||||
});
|
||||
if (!this.form.reviewImg) {
|
||||
uni.showToast({
|
||||
title: '请上传至少一张图片',
|
||||
icon: 'none'
|
||||
});
|
||||
} else if (this.form.reviewContent.trim().length < 15) {
|
||||
uni.showToast({
|
||||
title: '评价内容至少15个字',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -817,7 +824,10 @@
|
||||
icon: 'success'
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
// 跳转回酒款详情页
|
||||
uni.redirectTo({
|
||||
url: `/pages/index/review?beerId=${this.form.beerId}`
|
||||
});
|
||||
}, 1500);
|
||||
}
|
||||
} catch (error) {
|
||||
|
@ -34,7 +34,7 @@
|
||||
</view>
|
||||
<view class="progress-labels">
|
||||
<text class="start">0天</text>
|
||||
<text class="end">{{activityInfo.duration}}天</text>
|
||||
<text class="end">{{totalDays}}天</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -49,7 +49,7 @@
|
||||
<view class="cuIcon-right"></view>
|
||||
</view>
|
||||
<template v-if="currentTab == 1">
|
||||
<view class="activity-duration">首次扫码开始累计 <text class="duration-value">{{activityInfo.activityDuration || '-'}} 天内</text></view>
|
||||
<view class="activity-duration">首次扫码开始累计 <text class="duration-value">{{activityInfo.duration || '-'}} 天内</text></view>
|
||||
<view class="activity-target">
|
||||
{{ activityInfo.beer_scope === 0 ? '全系列酒款' : '以下酒款' }}累计扫码 ≥ {{activityInfo.activityTarget || '-'}} 桶
|
||||
</view>
|
||||
@ -148,6 +148,14 @@
|
||||
this.checkLoginStatus();
|
||||
},
|
||||
computed: {
|
||||
totalDays() {
|
||||
if(this.activityInfo.endDate && this.activityInfo.startDate) {
|
||||
const endDate = new Date(this.activityInfo.endDate);
|
||||
const startDate = new Date(this.activityInfo.startDate);
|
||||
return Math.ceil((endDate - startDate) / (1000 * 3600 * 24));
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
processNum() {
|
||||
if(this.activityInfo.endDate) {
|
||||
const endDate = new Date(this.activityInfo.endDate);
|
||||
@ -177,8 +185,8 @@
|
||||
this.activityInfo = res.data;
|
||||
|
||||
// 检查关键数据是否存在
|
||||
if (!this.activityInfo.activityDuration) {
|
||||
console.warn('缺少活动累计天数:activityDuration');
|
||||
if (!this.activityInfo.duration) {
|
||||
console.warn('缺少活动累计天数:duration');
|
||||
}
|
||||
if (!this.activityInfo.activityTarget) {
|
||||
console.warn('缺少活动目标数量:activityTarget');
|
||||
@ -190,22 +198,15 @@
|
||||
// 计算剩余天数
|
||||
this.activityInfo.remainingDays = this.getRemainingDays(res.data.endDate);
|
||||
|
||||
// 计算活动总持续时间(用于进度条显示)
|
||||
if(res.data.endDate && res.data.startDate) {
|
||||
const endDate = new Date(res.data.endDate);
|
||||
const startDate = new Date(res.data.startDate);
|
||||
this.activityInfo.duration = Math.ceil((endDate - startDate) / (1000 * 3600 * 24));
|
||||
}
|
||||
|
||||
// 启动倒计时
|
||||
this.startCountdown();
|
||||
}).catch(err => {
|
||||
console.error('获取活动详情失败:', err);
|
||||
uni.showToast({
|
||||
title: '获取活动信息失败',
|
||||
title: '获取活动详情失败',
|
||||
icon: 'none'
|
||||
});
|
||||
})
|
||||
});
|
||||
},
|
||||
startCountdown() {
|
||||
if(this.timer) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user