|
|
@ -27,7 +27,7 @@ |
|
|
|
<div class="shoplist"> |
|
|
|
<div class="shopTitle">请确认订单信息</div> |
|
|
|
<ShopOrder v-for="item in this.settlement.shops" |
|
|
|
:key="item.shopId" |
|
|
|
:key="item.uniqueId" |
|
|
|
:type="state" |
|
|
|
:shopsData="item" |
|
|
|
> |
|
|
@ -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, |
|
|
|