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

View File

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