diff --git a/packages/shop/goodsSubmit/index.vue b/packages/shop/goodsSubmit/index.vue index cb48385c..d4d0e168 100644 --- a/packages/shop/goodsSubmit/index.vue +++ b/packages/shop/goodsSubmit/index.vue @@ -371,21 +371,28 @@ export default { user_id: uni.getStorageSync('userId'), // 先判断shopCarList数据中是否包含isAdver且为true order_cate: this.carList.some(item => item.isAdver === true) ? 3 : 1, - goods_list: [{ - supplier_id: this.orderList[0].supplier_id, - supplier_name: this.orderList[0].supplier_name || '', - is_same_day: this.orderList[0].commodity_goods_info.is_same_day, - receiving_name: this.defAddress.name, - receiving_phone: this.defAddress.phone, - receiving_address: this.defAddress.address + this.defAddress.house_number, - merchant_id: this.defAddress.address_id, - goods_and_count: this.orderList.map(item => ({ + goods_list: Object.values(this.orderList.reduce((acc, item) => { + const supplierId = item.supplier_id; + if (!acc[supplierId]) { + acc[supplierId] = { + supplier_id: supplierId, + supplier_name: item.supplier_name || '', + is_same_day: item.commodity_goods_info.is_same_day, + receiving_name: this.defAddress.name, + receiving_phone: this.defAddress.phone, + receiving_address: this.defAddress.address + this.defAddress.house_number, + merchant_id: this.defAddress.address_id, + goods_and_count: [] + }; + } + acc[supplierId].goods_and_count.push({ goods_id: item.goods_id, count: item.count, price: item.commodity_goods_info.sales_price, freight: item.commodity_goods_info.freight, - })) - }] + }); + return acc; + }, {})) } request(apiArr.createOrder, "POST", params).then(resVal => {