|
|
@@ -107,27 +107,18 @@
|
|
|
<view v-else class="gift-promo-reached">已达标,支付后自动赠送会员</view>
|
|
|
</view>
|
|
|
|
|
|
- <!-- 订单套餐自动定价优惠提示(后端权威下发,命中才显示) -->
|
|
|
- <view v-if="bundlePromo && bundlePromo.active" class="bundle-promo-section">
|
|
|
- <view class="bundle-promo-header">
|
|
|
- <text class="bundle-promo-icon">📦</text>
|
|
|
- <text class="bundle-promo-title">订单套餐自动匹配,已享套餐价</text>
|
|
|
- </view>
|
|
|
- <view v-for="(b, idx) in (bundlePromo.bundleList || [])" :key="idx" class="bundle-promo-row">
|
|
|
- <text class="bundle-promo-name">{{ b.bundleName }} × {{ b.times }}</text>
|
|
|
- <text class="bundle-promo-save">省 {{ formatPriceWithSymbol(b.saving) }}</text>
|
|
|
- </view>
|
|
|
- <view class="bundle-promo-total">
|
|
|
- <text class="bundle-promo-total-label">套餐优惠合计</text>
|
|
|
- <text class="bundle-promo-discount">-{{ formatPriceWithSymbol(bundlePromo.discount) }}</text>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
-
|
|
|
<view v-else-if="giftIsGranted" class="gift-granted-hint">
|
|
|
<text class="gift-granted-icon">✅</text>
|
|
|
<text class="gift-granted-text">本家庭已赠送会员,请前往会员中心查看</text>
|
|
|
</view>
|
|
|
|
|
|
+ <!-- 购物车套餐offer(勾选子集,后端权威下发,纯展示不扣款) -->
|
|
|
+ <view v-if="comboOffer && comboOffer.active" class="combo-offer-section">
|
|
|
+ <view class="combo-offer-title">{{ comboOfferText }}</view>
|
|
|
+ <view class="combo-offer-price">套餐价 {{ formatPriceWithSymbol(comboOffer.comboPrice) }} · 省 {{ formatPriceWithSymbol(comboOffer.saving) }}</view>
|
|
|
+ <button class="combo-replace-btn" @click="replaceWithCombo">一键替换为套餐</button>
|
|
|
+ </view>
|
|
|
+
|
|
|
<view class="bottom-bar" v-if="items.length > 0">
|
|
|
<view class="bottom-left">
|
|
|
<text class="selected-count">已选 {{ selectedCount }} 件</text>
|
|
|
@@ -157,8 +148,8 @@
|
|
|
|
|
|
<script>
|
|
|
import config from '@/config.js'
|
|
|
-import { getMyMembership, getGiftMembershipProgress } from '@/utils/api.js'
|
|
|
-import { applyBundleDiscount } from '@/utils/bundle-pricing.js'
|
|
|
+import { getMyMembership, getGiftMembershipProgress, queryComboOffer, replaceCartWithCombo } from '@/utils/api.js'
|
|
|
+import { formatComboOfferText } from '@/utils/bundle-pricing.js'
|
|
|
import fontScaleMixin from '@/mixins/font-scale.js'
|
|
|
|
|
|
export default {
|
|
|
@@ -173,7 +164,8 @@ export default {
|
|
|
isMember: false,
|
|
|
giftProgress: null, // 赠会员累计进度
|
|
|
giftPromo: null, // 送会员一口价促销信息(已废弃,后端恒返回非激活)
|
|
|
- bundlePromo: null // 订单套餐自动定价优惠(后端权威下发)
|
|
|
+ comboOffer: null, // 勾选子集套餐offer(后端权威下发,纯展示提示)
|
|
|
+ offerTimer: null // 勾选变化防抖定时器
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -198,8 +190,7 @@ export default {
|
|
|
total = total + (this.items[i].subtotal || this.items[i].unitPrice * this.items[i].quantity)
|
|
|
}
|
|
|
}
|
|
|
- // 套餐自动定价优惠(后端权威),命中则扣减
|
|
|
- return applyBundleDiscount(total, this.bundlePromo)
|
|
|
+ return total
|
|
|
},
|
|
|
originalTotalAmount() {
|
|
|
var total = 0
|
|
|
@@ -211,6 +202,13 @@ export default {
|
|
|
}
|
|
|
return total
|
|
|
},
|
|
|
+ comboOfferText() {
|
|
|
+ var count = 0
|
|
|
+ for (var i = 0; i < this.items.length; i++) {
|
|
|
+ if (this.items[i].checked) count++
|
|
|
+ }
|
|
|
+ return formatComboOfferText(this.comboOffer, count)
|
|
|
+ },
|
|
|
estimatedTotalAmount() {
|
|
|
var total = 0
|
|
|
for (var i = 0; i < this.items.length; i++) {
|
|
|
@@ -223,8 +221,7 @@ export default {
|
|
|
total = total + (price * this.items[i].quantity)
|
|
|
}
|
|
|
}
|
|
|
- // 套餐自动定价优惠(后端权威),命中则扣减
|
|
|
- return applyBundleDiscount(total, this.bundlePromo)
|
|
|
+ return total
|
|
|
},
|
|
|
hasGiftItems() {
|
|
|
for (var i = 0; i < this.items.length; i++) {
|
|
|
@@ -297,6 +294,44 @@ export default {
|
|
|
}
|
|
|
}).catch(function() {})
|
|
|
},
|
|
|
+ scheduleOfferCheck() {
|
|
|
+ if (this.offerTimer) clearTimeout(this.offerTimer)
|
|
|
+ this.offerTimer = setTimeout(() => { this.queryOffer() }, 400)
|
|
|
+ },
|
|
|
+ queryOffer() {
|
|
|
+ var that = this
|
|
|
+ var ids = []
|
|
|
+ for (var i = 0; i < this.items.length; i++) {
|
|
|
+ if (this.items[i].checked && this.items[i].id) ids.push(this.items[i].id)
|
|
|
+ }
|
|
|
+ if (!ids.length) {
|
|
|
+ that.comboOffer = null
|
|
|
+ return
|
|
|
+ }
|
|
|
+ queryComboOffer({ checkedCartItemIds: ids }).then(function(res) {
|
|
|
+ if (res && res.code === 200 && res.data && res.data.active) {
|
|
|
+ that.comboOffer = res.data
|
|
|
+ } else {
|
|
|
+ that.comboOffer = null
|
|
|
+ }
|
|
|
+ }).catch(function() {})
|
|
|
+ },
|
|
|
+ replaceWithCombo() {
|
|
|
+ var that = this
|
|
|
+ var ids = []
|
|
|
+ for (var i = 0; i < this.items.length; i++) {
|
|
|
+ if (this.items[i].checked && this.items[i].id) ids.push(this.items[i].id)
|
|
|
+ }
|
|
|
+ if (!ids.length || !this.comboOffer) return
|
|
|
+ replaceCartWithCombo({ checkedCartItemIds: ids, comboSkuId: this.comboOffer.comboSkuId }).then(function(res) {
|
|
|
+ if (res && res.code === 200) {
|
|
|
+ uni.showToast({ title: '已替换为套餐', icon: 'success' })
|
|
|
+ that.loadCart()
|
|
|
+ } else {
|
|
|
+ uni.showToast({ title: (res && res.message) || '替换失败', icon: 'none' })
|
|
|
+ }
|
|
|
+ }).catch(function() {})
|
|
|
+ },
|
|
|
goUpgrade() {
|
|
|
uni.navigateTo({ url: '/pages/membership/upgrade' })
|
|
|
},
|
|
|
@@ -323,8 +358,8 @@ export default {
|
|
|
that.items[i].subtotal = that.items[i].unitPrice * that.items[i].quantity
|
|
|
}
|
|
|
that.giftPromo = result.giftPromo || null
|
|
|
- that.bundlePromo = result.bundlePromo || null
|
|
|
that.loadGiftProgress()
|
|
|
+ that.scheduleOfferCheck()
|
|
|
}
|
|
|
},
|
|
|
fail: function() {
|
|
|
@@ -343,6 +378,7 @@ export default {
|
|
|
for (var i = 0; i < this.items.length; i++) {
|
|
|
this.items[i].checked = newState
|
|
|
}
|
|
|
+ this.scheduleOfferCheck()
|
|
|
},
|
|
|
toggleItem(productId) {
|
|
|
for (var i = 0; i < this.items.length; i++) {
|
|
|
@@ -351,6 +387,7 @@ export default {
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
+ this.scheduleOfferCheck()
|
|
|
},
|
|
|
increaseQty(item) {
|
|
|
item.quantity = item.quantity + 1
|
|
|
@@ -432,7 +469,6 @@ export default {
|
|
|
}
|
|
|
uni.setStorageSync('checkoutItems', selected)
|
|
|
uni.setStorageSync('checkoutGiftPromo', this.giftPromo)
|
|
|
- uni.setStorageSync('checkoutBundlePromo', this.bundlePromo)
|
|
|
uni.navigateTo({ url: '/pages/shop/checkout/checkout' + (this.taskId ? '?taskId=' + this.taskId : '') })
|
|
|
},
|
|
|
formatPriceWithSymbol(price) {
|
|
|
@@ -836,4 +872,29 @@ export default {
|
|
|
font-size: calc(26rpx * var(--font-scale, 1));
|
|
|
color: #15803D;
|
|
|
}
|
|
|
+.combo-offer-section {
|
|
|
+ margin: 20rpx $uni-space-page;
|
|
|
+ padding: 20rpx;
|
|
|
+ background: #FFF7E6;
|
|
|
+ border-radius: 16rpx;
|
|
|
+}
|
|
|
+.combo-offer-title {
|
|
|
+ font-size: calc(26rpx * var(--font-scale, 1));
|
|
|
+ color: $status-warning-strong;
|
|
|
+ line-height: 1.5;
|
|
|
+}
|
|
|
+.combo-offer-price {
|
|
|
+ font-size: calc(24rpx * var(--font-scale, 1));
|
|
|
+ color: $status-warning-deep;
|
|
|
+ margin-top: 8rpx;
|
|
|
+}
|
|
|
+.combo-replace-btn {
|
|
|
+ margin-top: 16rpx;
|
|
|
+ padding: 14rpx 24rpx;
|
|
|
+ background: $status-warning-deep;
|
|
|
+ color: #FFFFFF;
|
|
|
+ border-radius: 40rpx;
|
|
|
+ font-size: calc(26rpx * var(--font-scale, 1));
|
|
|
+ text-align: center;
|
|
|
+}
|
|
|
</style>
|