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