From 3a05cbfcd674e3ff6821badd6f7fb03705b5874c Mon Sep 17 00:00:00 2001 From: xh-pan1 Date: Tue, 16 May 2023 17:16:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=8E=AF=E5=A2=83=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/util/server.js | 5 ++- src/views/placeOrder/components/shopOrder.vue | 2 +- src/views/placeOrder/index.vue | 59 ++++++++++++++++++--------- 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/src/util/server.js b/src/util/server.js index ee4a27a..f599a1c 100644 --- a/src/util/server.js +++ b/src/util/server.js @@ -8,7 +8,10 @@ import Cookie from 'js-cookie' promise.polyfill() export const baseURL = (process.env.NODE_ENV === 'production') ? 'http://122.9.152.120/ceres-app-api' : '/api' -export const uploadURL = 'https://ceres.zkthink.com/api' +export const uploadURL = 'http://122.9.152.120/ceres-app-api/api' + +// export const baseURL = (process.env.NODE_ENV === 'production') ? 'http://14.22.116.132:81/ceres-app-api' : '/api' +// export const uploadURL = 'http://14.22.116.132:81/ceres-app-api/api' const service = axios.create({ baseURL, diff --git a/src/views/placeOrder/components/shopOrder.vue b/src/views/placeOrder/components/shopOrder.vue index 7cd1a10..9273462 100644 --- a/src/views/placeOrder/components/shopOrder.vue +++ b/src/views/placeOrder/components/shopOrder.vue @@ -38,7 +38,7 @@
¥{{order.total}}
-
当前地址不支持配送,,可更换其他地址试试
+
当前地址不支持配送,可更换其他地址试试
diff --git a/src/views/placeOrder/index.vue b/src/views/placeOrder/index.vue index 74a8da0..620997a 100644 --- a/src/views/placeOrder/index.vue +++ b/src/views/placeOrder/index.vue @@ -27,7 +27,7 @@
请确认订单信息
@@ -327,9 +327,9 @@ export default { ...mapGetters([ 'newAddress' // 新增修改收货地址 ]), - shopIds () { + uniqueIds () { return this.settlement.shops.map(item => { - return item.shopId + return item.uniqueId }) } }, @@ -533,6 +533,7 @@ export default { this.settlement = res.data this.currentAddressId = res.data.receive.receiveId || '' this.settlement.shops = res.data.shops || [] // 订单商家信息 + // 平台优惠券 this.settlement.coupons.forEach((item, index) => { item.index = index item.type = 1 @@ -550,7 +551,8 @@ export default { item.shopCoupons = item.shopCoupons.map((i, index) => { i.index = index i.type = 2 // type 1平台券 2商家券 - i.uniWebId = `${item.shopId}+${index}` // 创建一个前端单方面的唯一值,处理选中状态 + i.uniWebId = `${item.uniqueId}+${index}` // 创建一个前端单方面的唯一值,处理选中状态 + i.uniqueId = item.uniqueId i.shopId = item.shopId // 方便后续确定优惠券 i.discountAmount = 0 return i @@ -571,25 +573,32 @@ export default { // 商家券 本方法参考uniapp代码的同名方法 shopCouponItemTap (coupon) { const index = coupon.index - this.shopIndex = this.shopIds.indexOf(coupon.shopId) - + // 订单序号 + this.shopIndex = this.uniqueIds.indexOf(coupon.uniqueId) + var checkShop = this.settlement.shops[this.shopIndex] // 取消选择优惠券 if (coupon.checked) { coupon.checked = false coupon.discountAmount = 0 - this.settlement.shops[this.shopIndex].totalAfterDiscount = this.settlement.shops[this.shopIndex].total - this.settlement.shops[this.shopIndex].currentCoupon = {} - this.settlement.shops[this.shopIndex].skus.forEach(item => { + checkShop.totalAfterDiscount = checkShop.total + checkShop.currentCoupon = {} + checkShop.skus.forEach(item => { item.buyerShopCouponId = null }) - this.selectShopCoupon = [] + this.selectShopCoupon.splice(this.selectShopCoupon.indexOf(coupon), 1) this.getTotal() return false } - if (this.settlement.shops[this.shopIndex].total < coupon.fullMoney) { + for (let i = 0; i < this.selectShopCoupon.length; i++) { + if (this.selectShopCoupon[i].id === coupon.id) { + this.$message.warning('优惠券不能重复使用!') + return false + } + } + if (checkShop.total < coupon.fullMoney) { this.$message.warning('不满足优惠券使用条件!') - } else if (coupon.couponType === 1 && this.settlement.shops[this.shopIndex].total < coupon.reduceMoney) { + } else if (coupon.couponType === 1 && checkShop.total < coupon.reduceMoney) { this.$message.warning('不可使用大于商品金额的优惠劵!') } else { // 选择优惠券 @@ -598,7 +607,7 @@ export default { return false } if (coupon.couponType === 1) { - if (coupon.reduceMoney >= this.settlement.shops[this.shopIndex].total) { + if (coupon.reduceMoney >= checkShop.total) { this.$message.warning('优惠券优惠金额不能大于等于合计金额!') return false } @@ -608,23 +617,30 @@ export default { this.shopCouIndex = index let useCoupon = this.useShopCoupon(this.shopIndex, this.shopCouIndex) if (useCoupon) { + let otherSelectShopCoupon // 确认使用当前点击的商家券,先将所有的商家券取消选中 for (let i = 0; i < this.selectShopCoupon.length; i++) { - this.selectShopCoupon[i].checked = false + if (this.selectShopCoupon[i].uniqueId === coupon.uniqueId) { + this.selectShopCoupon[i].checked = false + otherSelectShopCoupon = this.selectShopCoupon[i] + break + } + } + if (otherSelectShopCoupon != null) { + this.selectShopCoupon.splice(this.selectShopCoupon.indexOf(otherSelectShopCoupon), 1) } - this.selectShopCoupon = [] coupon.checked = true - this.settlement.shops[this.shopIndex].id = coupon.id - this.settlement.shops[this.shopIndex].currentCoupon = coupon - this.settlement.shops[this.shopIndex].skus.forEach(item => { + checkShop.id = coupon.id + checkShop.currentCoupon = coupon + checkShop.skus.forEach(item => { if (item.buyerShopCouponId > 0 && item.buyerShopCouponId !== coupon.shopCouponId) { item.buyerShopCouponId = null } }) this.selectShopCoupon.push(coupon) } else { - this.settlement.shops[this.shopIndex].totalAfterDiscount = this.settlement.shops[this.shopIndex].total + checkShop.totalAfterDiscount = checkShop.total } this.getTotal() } @@ -691,7 +707,7 @@ export default { } totalPrice += matchCouponNormalPrice } - if (this.settlement.shops[this.shopIndex].total < coupon.fullMoney) { + if (totalPrice < coupon.fullMoney) { this.$message.warning('不满足优惠券使用条件!') } if (coupon.couponType === 1 && coupon.reduceMoney >= totalPrice) { @@ -917,7 +933,10 @@ export default { if (skus.length) { shops.push({ id: j.id, + uniqueId: j.uniqueId, + isCross: j.isCross, shopId: j.shopId, + storehouseId: j.storehouseId, remark: j.remark, distribution: { distributionPrice: j.distribution.distributionPrice,