fix: 修改活动详情页面日期计算逻辑,修改评价提交校验规则

This commit is contained in:
davy 2025-04-07 20:12:36 +08:00
parent bd413f19b3
commit f76b79c7f9
2 changed files with 29 additions and 18 deletions

View File

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

View File

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