满减活动优化
This commit is contained in:
parent
67b25125fe
commit
76cf312e12
|
|
@ -92,6 +92,7 @@
|
||||||
<up-switch
|
<up-switch
|
||||||
:activeValue="1"
|
:activeValue="1"
|
||||||
:inactiveValue="0"
|
:inactiveValue="0"
|
||||||
|
:disabled="true"
|
||||||
v-model="form.couponShare"
|
v-model="form.couponShare"
|
||||||
size="18"
|
size="18"
|
||||||
></up-switch>
|
></up-switch>
|
||||||
|
|
@ -162,7 +163,10 @@ import {
|
||||||
} from "@dcloudio/uni-app";
|
} from "@dcloudio/uni-app";
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
thresholds: [],
|
thresholds: [{
|
||||||
|
fullAmount: 0,
|
||||||
|
discountAmount: 0,
|
||||||
|
}],
|
||||||
validStartTime: "",
|
validStartTime: "",
|
||||||
validEndTime: "",
|
validEndTime: "",
|
||||||
useDays: ['周一','周二','周三','周四','周五','周六','周日'],
|
useDays: ['周一','周二','周三','周四','周五','周六','周日'],
|
||||||
|
|
@ -172,14 +176,14 @@ const form = reactive({
|
||||||
useType: [],
|
useType: [],
|
||||||
sort: 0,
|
sort: 0,
|
||||||
couponShare: 0,
|
couponShare: 0,
|
||||||
discountShare: 0,
|
discountShare: 1,
|
||||||
vipPriceShare: 0,
|
vipPriceShare: 1,
|
||||||
pointsShare: 0,
|
pointsShare: 1,
|
||||||
});
|
});
|
||||||
function addThresholds() {
|
function addThresholds() {
|
||||||
form.thresholds.push({
|
form.thresholds.push({
|
||||||
fullAmount: 0,
|
fullAmount: '',
|
||||||
discountAmount: 0,
|
discountAmount: '',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -210,6 +214,14 @@ async function save() {
|
||||||
// validStartTime:'',
|
// validStartTime:'',
|
||||||
// validEndTime:'',
|
// 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){
|
if(!submitData.thresholds.length){
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "请添加门槛",
|
title: "请添加门槛",
|
||||||
|
|
@ -252,6 +264,14 @@ async function save() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!form.useType.length){
|
||||||
|
uni.showToast({
|
||||||
|
title: "请选择可使用类型",
|
||||||
|
icon: "none",
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
|
return
|
||||||
|
}
|
||||||
const res = !form.id
|
const res = !form.id
|
||||||
? await discountActivityApi.add(submitData)
|
? await discountActivityApi.add(submitData)
|
||||||
:await discountActivityApi.update(submitData);
|
:await discountActivityApi.update(submitData);
|
||||||
|
|
@ -278,6 +298,12 @@ function setForm(data) {
|
||||||
data.useType = data.useType.split(",");
|
data.useType = data.useType.split(",");
|
||||||
data.validStartTime = data.validStartTime.split(" ")[0];
|
data.validStartTime = data.validStartTime.split(" ")[0];
|
||||||
data.validEndTime = data.validEndTime.split(" ")[0];
|
data.validEndTime = data.validEndTime.split(" ")[0];
|
||||||
|
data.thresholds=data.thresholds||[
|
||||||
|
{
|
||||||
|
fullAmount: '',
|
||||||
|
discountAmount: '',
|
||||||
|
}
|
||||||
|
]
|
||||||
Object.assign(form, data);
|
Object.assign(form, data);
|
||||||
console.log(form);
|
console.log(form);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue