diff --git a/package2/myCenter/addGoods.vue b/package2/myCenter/addGoods.vue index 49d7138..77257e2 100644 --- a/package2/myCenter/addGoods.vue +++ b/package2/myCenter/addGoods.vue @@ -436,6 +436,7 @@ submit() { let that = this; this.syncLunchBoxByMoreBuy() + this.normalizeGroupBuyPrices() if (!this.validateProductSpecs()) { return } @@ -531,6 +532,17 @@ } return true }, + normalizeGroupBuyPrices() { + if (!Array.isArray(this.formData.productGroupBuyPrices)) { + this.formData.productGroupBuyPrices = [] + return + } + this.formData.productGroupBuyPrices = this.formData.productGroupBuyPrices.filter((item) => { + const groupCount = item && item.groupCount !== undefined && item.groupCount !== null ? String(item.groupCount).trim() : '' + const groupPrice = item && item.groupPrice !== undefined && item.groupPrice !== null ? String(item.groupPrice).trim() : '' + return groupCount !== '' || groupPrice !== '' + }) + }, isValidPrice(value) { return /^\d+(\.\d{1,2})?$/.test(value) && Number(value) > 0 },