diff --git a/src/components/NFTBook/CrossSellDialog.vue b/src/components/NFTBook/CrossSellDialog.vue index 9aa71eef8..58de102f7 100644 --- a/src/components/NFTBook/CrossSellDialog.vue +++ b/src/components/NFTBook/CrossSellDialog.vue @@ -72,10 +72,11 @@ import { getNFTBookPurchaseLink } from '~/util/api'; import { logTrackerEvent, logPurchaseFlowEvent } from '~/util/EventLogger'; import nftOrCollectionMixin from '~/mixins/nft-or-collection'; +import couponMixin from '~/mixins/coupon'; export default { name: 'NFTBookCrossSellDialog', - mixins: [nftOrCollectionMixin], + mixins: [nftOrCollectionMixin, couponMixin], props: { open: { type: Boolean, @@ -150,7 +151,9 @@ export default { { gaClientId: this.getGaClientId, gaSessionId: this.getGaSessionId, - coupon: this.$route.query.coupon, + coupon: this.getApplicableCoupon({ + checkoutPrice: customPriceInDecimal, + }), customPriceInDecimal, utmCampaign: this.utmCampaign, utmSource: `${this.utmSource}_cross-sell`, diff --git a/src/constant/index.js b/src/constant/index.js index bbbfea896..096f1e53d 100644 --- a/src/constant/index.js +++ b/src/constant/index.js @@ -452,3 +452,6 @@ export const SEARCH_SUGGESTIONS = [ '信仰', '邵家臻', ]; + +export const CHRISTMAS_CAMPAIGN_MIN_SPEND = 9; +export const CHRISTMAS_CAMPAIGN_COUPON = 'XMASREAD'; diff --git a/src/mixins/coupon.js b/src/mixins/coupon.js new file mode 100644 index 000000000..cee638cb9 --- /dev/null +++ b/src/mixins/coupon.js @@ -0,0 +1,22 @@ +import { + CHRISTMAS_CAMPAIGN_MIN_SPEND, + CHRISTMAS_CAMPAIGN_COUPON, +} from '@/constant/index'; + +export default { + computed: { + mixinCoupon() { + return this.$route.query.coupon || ''; + }, + }, + methods: { + getApplicableCoupon({ cartCoupon, checkoutPrice }) { + if (this.mixinCoupon || cartCoupon) { + return this.mixinCoupon || cartCoupon; + } + return checkoutPrice > CHRISTMAS_CAMPAIGN_MIN_SPEND + ? CHRISTMAS_CAMPAIGN_COUPON + : ''; + }, + }, +}; diff --git a/src/pages/nft/class/_classId/index.vue b/src/pages/nft/class/_classId/index.vue index db66e2b1f..e8bc0888a 100644 --- a/src/pages/nft/class/_classId/index.vue +++ b/src/pages/nft/class/_classId/index.vue @@ -426,9 +426,6 @@