diff --git a/pageMarket/discountActivity/add.vue b/pageMarket/discountActivity/add.vue index 01830a8..4ceb9e3 100644 --- a/pageMarket/discountActivity/add.vue +++ b/pageMarket/discountActivity/add.vue @@ -92,6 +92,7 @@ @@ -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); }