满减活动优化

This commit is contained in:
YeMingfei666 2025-10-15 17:05:56 +08:00
parent 67b25125fe
commit 76cf312e12
1 changed files with 32 additions and 6 deletions

View File

@ -92,6 +92,7 @@
<up-switch
:activeValue="1"
:inactiveValue="0"
:disabled="true"
v-model="form.couponShare"
size="18"
></up-switch>
@ -162,7 +163,10 @@ import {
} from "@dcloudio/uni-app";
const form = reactive({
thresholds: [],
thresholds: [{
fullAmount: 0,
discountAmount: 0,
}],
validStartTime: "",
validEndTime: "",
useDays: ['周一','周二','周三','周四','周五','周六','周日'],
@ -172,14 +176,14 @@ const form = reactive({
useType: [],
sort: 0,
couponShare: 0,
discountShare: 0,
vipPriceShare: 0,
pointsShare: 0,
discountShare: 1,
vipPriceShare: 1,
pointsShare: 1,
});
function addThresholds() {
form.thresholds.push({
fullAmount: 0,
discountAmount: 0,
fullAmount: '',
discountAmount: '',
});
}
@ -210,6 +214,14 @@ async function save() {
// validStartTime:'',
// validEndTime:'',
};
const ispas=submitData.thresholds.every(item=>item.fullAmount>0&&item.discountAmount>0);
if(!ispas){
uni.showToast({
title: "请输入正确的满减金额",
icon: "none",
});
return;
}
if(!submitData.thresholds.length){
uni.showToast({
title: "请添加门槛",
@ -252,6 +264,14 @@ async function save() {
return
}
}
if(!form.useType.length){
uni.showToast({
title: "请选择可使用类型",
icon: "none",
duration: 2000,
});
return
}
const res = !form.id
? await discountActivityApi.add(submitData)
:await discountActivityApi.update(submitData);
@ -278,6 +298,12 @@ function setForm(data) {
data.useType = data.useType.split(",");
data.validStartTime = data.validStartTime.split(" ")[0];
data.validEndTime = data.validEndTime.split(" ")[0];
data.thresholds=data.thresholds||[
{
fullAmount: '',
discountAmount: '',
}
]
Object.assign(form, data);
console.log(form);
}