@nuskin/product-components 3.18.0-td-341.2 → 4.0.0-cx15-11969.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,147 +0,0 @@
1
- <template>
2
- <div :class="priceContainerClass">
3
- <span class="price--regular">{{
4
- price.regularPrice | currencyFilter(currencyLocale, currencyCode)
5
- }}</span
6
- >&nbsp;
7
- <span class="price--sale">{{
8
- price.salePrice | currencyFilter(currencyLocale, currencyCode)
9
- }}</span>
10
- </div>
11
- </template>
12
-
13
- <script>
14
- import globalHelper from "../../mixins/globalHelper";
15
- import { getProp, fromJsonString } from "@nuskin/ns-common-lib";
16
-
17
- export default {
18
- filters: {
19
- currencyFilter(price, currencyLocale, currencyCode) {
20
- return globalHelper.methods.currencyFormatter(
21
- currencyLocale,
22
- "currency",
23
- currencyCode,
24
- price
25
- );
26
- }
27
- },
28
- mixins: [globalHelper],
29
- props: {
30
- product: {
31
- type: Object,
32
- required: true
33
- },
34
- user: {
35
- type: Object,
36
- default: () => null
37
- },
38
- salesEvents: {
39
- type: Array,
40
- default: () => []
41
- }
42
- },
43
- data() {
44
- return {
45
- salesEvent: ""
46
- };
47
- },
48
- computed: {
49
- isSale() {
50
- return this.salesEvent !== "";
51
- },
52
- priceContainerClass() {
53
- return this.isSale ? "price__container--sale" : "price__container";
54
- },
55
- currencyLocale() {
56
- const { market, language } = globalHelper.methods.getMarketAndLanguage();
57
- return `${language}-${market.toUpperCase()}`;
58
- },
59
- currencyCode() {
60
- return this.variant.price.currencyCode;
61
- },
62
- variant() {
63
- return this.product.firstVariant;
64
- },
65
- isWholeSale() {
66
- return (
67
- this.user && (this.user.isDistributor || this.user.isPreferredCustomer)
68
- );
69
- },
70
- price() {
71
- const typeKey = this.isWholeSale ? "wholesale" : "retail";
72
- const regularPrice = this.variant.price[typeKey];
73
-
74
- let salePrice = null;
75
- if (this.isSale) {
76
- salePrice = this.variant.price[this.salesEvent][typeKey];
77
- }
78
-
79
- return {
80
- regularPrice,
81
- salePrice
82
- };
83
- }
84
- },
85
- watch: {
86
- salesEvents() {
87
- this.initSalesEvent();
88
- }
89
- },
90
- mounted() {
91
- this.initSalesEvent();
92
- },
93
- methods: {
94
- initSalesEvent() {
95
- if (!this.salesEvents) return;
96
- const pricing = fromJsonString(this.variant.pricingJson, {});
97
-
98
- let salesEvent = "";
99
- for (const activeSalesEvent of this.salesEvents) {
100
- const retailPrice = getProp(
101
- pricing,
102
- `retail.${activeSalesEvent}.price`,
103
- null
104
- );
105
- const wholesalePrice = getProp(
106
- pricing,
107
- `wholesale.${activeSalesEvent}.price`,
108
- null
109
- );
110
-
111
- if (retailPrice || wholesalePrice) {
112
- if (!wholesalePrice && this.isWholeSale) continue;
113
- if (!retailPrice && !this.isWholeSale) continue;
114
-
115
- this.variant.price[activeSalesEvent] = {
116
- retail: retailPrice,
117
- wholesale: wholesalePrice
118
- };
119
-
120
- salesEvent = activeSalesEvent;
121
- }
122
- }
123
-
124
- this.salesEvent = salesEvent;
125
- }
126
- }
127
- };
128
- </script>
129
-
130
- <style lang="scss" scoped>
131
- .price__container {
132
- display: flex;
133
- .price--sale {
134
- display: none;
135
- }
136
- &--sale {
137
- .price--regular {
138
- text-decoration: line-through;
139
- color: #8c8c8c;
140
- font-size: 18px;
141
- }
142
- .price--sale {
143
- display: inline-block;
144
- }
145
- }
146
- }
147
- </style>