@ecomplus/storefront-components 1.0.0-beta.19 → 1.0.0-beta.191
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.
- package/.version +0 -0
- package/CHANGELOG.md +1333 -135
- package/all.js +3 -1
- package/dist/1.storefront-components.min.js +2 -0
- package/dist/1.storefront-components.min.js.map +1 -0
- package/dist/2.storefront-components.min.js +5 -0
- package/dist/2.storefront-components.min.js.map +1 -0
- package/dist/3.storefront-components.min.js +5 -0
- package/dist/3.storefront-components.min.js.map +1 -0
- package/dist/storefront-components.min.js +33 -12
- package/dist/storefront-components.min.js.map +1 -1
- package/package.json +17 -12
- package/src/APagination.vue +2 -0
- package/src/AShare.vue +2 -0
- package/src/AccountAddresses.vue +3 -0
- package/src/AccountForm.vue +3 -0
- package/src/AccountPoints.vue +3 -0
- package/src/BuyTogether.vue +3 -0
- package/src/EarnPointsProgress.vue +3 -0
- package/src/ItemCustomizations.vue +2 -0
- package/src/KitProductVariations.vue +3 -0
- package/src/PointsApplier.vue +2 -0
- package/src/ProductQuickview.vue +3 -0
- package/src/QuantitySelector.vue +3 -0
- package/src/RecommendedItems.vue +3 -0
- package/src/ShippingLine.vue +1 -0
- package/src/TheCart.vue +3 -0
- package/src/html/APagination.html +90 -0
- package/src/html/APrices.html +24 -4
- package/src/html/AShare.html +31 -0
- package/src/html/AccountAddresses.html +90 -0
- package/src/html/AccountForm.html +269 -0
- package/src/html/AccountPoints.html +39 -0
- package/src/html/AddressForm.html +9 -7
- package/src/html/BuyTogether.html +60 -0
- package/src/html/CartItem.html +86 -38
- package/src/html/CartQuickview.html +28 -5
- package/src/html/DiscountApplier.html +3 -3
- package/src/html/EarnPointsProgress.html +28 -0
- package/src/html/InputDate.html +1 -1
- package/src/html/InputDocNumber.html +1 -0
- package/src/html/InputPhone.html +1 -1
- package/src/html/InstantSearch.html +3 -3
- package/src/html/ItemCustomizations.html +14 -0
- package/src/html/KitProductVariations.html +92 -0
- package/src/html/LoginBlock.html +34 -32
- package/src/html/LoginModal.html +9 -4
- package/src/html/PaymentOption.html +7 -5
- package/src/html/PointsApplier.html +26 -0
- package/src/html/ProductCard.html +68 -8
- package/src/html/ProductGallery.html +21 -3
- package/src/html/ProductQuickview.html +64 -0
- package/src/html/ProductVariations.html +30 -3
- package/src/html/QuantitySelector.html +85 -0
- package/src/html/RecommendedItems.html +48 -0
- package/src/html/SearchEngine.html +101 -24
- package/src/html/ShippingCalculator.html +84 -3
- package/src/html/ShippingLine.html +5 -2
- package/src/html/TheAccount.html +43 -9
- package/src/html/TheCart.html +156 -0
- package/src/html/TheProduct.html +416 -138
- package/src/js/APagination.js +74 -0
- package/src/js/APicture.js +27 -7
- package/src/js/APrices.js +80 -41
- package/src/js/AShare.js +83 -0
- package/src/js/AccountAddresses.js +201 -0
- package/src/js/AccountForm.js +312 -0
- package/src/js/AccountPoints.js +63 -0
- package/src/js/AddressForm.js +80 -35
- package/src/js/BuyTogether.js +246 -0
- package/src/js/CartItem.js +67 -14
- package/src/js/CartQuickview.js +20 -1
- package/src/js/DiscountApplier.js +181 -50
- package/src/js/EarnPointsProgress.js +77 -0
- package/src/js/InputDate.js +8 -8
- package/src/js/InputDocNumber.js +20 -0
- package/src/js/ItemCustomizations.js +10 -0
- package/src/js/KitProductVariations.js +218 -0
- package/src/js/LoginBlock.js +47 -6
- package/src/js/LoginModal.js +18 -10
- package/src/js/PaymentOption.js +28 -1
- package/src/js/PointsApplier.js +110 -0
- package/src/js/ProductCard.js +115 -11
- package/src/js/ProductGallery.js +32 -12
- package/src/js/ProductQuickview.js +72 -0
- package/src/js/ProductVariations.js +76 -19
- package/src/js/QuantitySelector.js +175 -0
- package/src/js/RecommendedItems.js +178 -0
- package/src/js/SearchEngine.js +185 -55
- package/src/js/ShippingCalculator.js +176 -35
- package/src/js/ShippingLine.js +44 -5
- package/src/js/TheAccount.js +97 -6
- package/src/js/TheCart.js +146 -0
- package/src/js/TheProduct.js +387 -43
- package/src/js/helpers/add-idle-callback.js +7 -0
- package/src/js/helpers/check-form-validity.js +3 -0
- package/src/js/helpers/favorite-products.js +24 -0
- package/src/js/helpers/scroll-to-element.js +10 -0
- package/src/js/helpers/sort-apps.js +14 -0
- package/src/js/helpers/wait-storefront-info.js +21 -0
- package/src/scss/APicture.scss +2 -0
- package/src/scss/APrices.scss +13 -1
- package/src/scss/AccountAddresses.scss +27 -0
- package/src/scss/AccountForm.scss +5 -0
- package/src/scss/AccountPoints.scss +17 -0
- package/src/scss/BuyTogether.scss +38 -0
- package/src/scss/CartItem.scss +17 -1
- package/src/scss/EarnPointsProgress.scss +6 -0
- package/src/scss/InstantSearch.scss +1 -0
- package/src/scss/KitProductVariations.scss +72 -0
- package/src/scss/LoginBlock.scss +5 -0
- package/src/scss/PaymentOption.scss +10 -1
- package/src/scss/ProductCard.scss +63 -25
- package/src/scss/ProductGallery.scss +4 -2
- package/src/scss/ProductQuickview.scss +36 -0
- package/src/scss/ProductVariations.scss +20 -4
- package/src/scss/QuantitySelector.scss +39 -0
- package/src/scss/RecommendedItems.scss +28 -0
- package/src/scss/SearchEngine.scss +9 -5
- package/src/scss/ShippingCalculator.scss +42 -1
- package/src/scss/ShippingLine.scss +24 -0
- package/src/scss/TheAccount.scss +4 -0
- package/src/scss/TheCart.scss +54 -0
- package/src/scss/TheProduct.scss +146 -1
- package/webpack.config.js +20 -6
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
i19add,
|
|
3
3
|
i19addDiscountCoupon,
|
|
4
|
+
// i19add$1ToGetDiscountMsg,
|
|
4
5
|
i19campaignAppliedMsg,
|
|
5
6
|
i19code,
|
|
6
7
|
i19couponAppliedMsg,
|
|
@@ -10,12 +11,53 @@ import {
|
|
|
10
11
|
i19invalidCouponMsg
|
|
11
12
|
} from '@ecomplus/i18n'
|
|
12
13
|
|
|
13
|
-
import { i18n } from '@ecomplus/utils'
|
|
14
|
-
import { modules } from '@ecomplus/client'
|
|
14
|
+
import { i18n, formatMoney } from '@ecomplus/utils'
|
|
15
|
+
import { store, modules } from '@ecomplus/client'
|
|
15
16
|
import ecomCart from '@ecomplus/shopping-cart'
|
|
16
17
|
import ecomPassport from '@ecomplus/passport-client'
|
|
17
18
|
import AAlert from '../AAlert.vue'
|
|
18
19
|
|
|
20
|
+
const addFreebieItems = (ecomCart, productIds) => {
|
|
21
|
+
if (Array.isArray(productIds)) {
|
|
22
|
+
ecomCart.data.items.forEach(({ _id, product_id: productId, flags }) => {
|
|
23
|
+
if (flags && flags.includes('freebie') && !productIds.includes(productId)) {
|
|
24
|
+
ecomCart.removeItem(_id)
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
productIds.forEach(productId => {
|
|
28
|
+
const canAddFreebie = !ecomCart.data.items.find(item => {
|
|
29
|
+
return item.product_id === productId && item.flags && item.flags.includes('freebie')
|
|
30
|
+
})
|
|
31
|
+
if (canAddFreebie) {
|
|
32
|
+
store({ url: `/products/${productId}.json` })
|
|
33
|
+
.then(({ data }) => {
|
|
34
|
+
if (data.quantity > 0 && (!data.variations || !data.variations.length)) {
|
|
35
|
+
ecomCart.addProduct(
|
|
36
|
+
{
|
|
37
|
+
...data,
|
|
38
|
+
flags: ['freebie', '__tmp']
|
|
39
|
+
},
|
|
40
|
+
null,
|
|
41
|
+
productIds.reduce((qnt, _id) => {
|
|
42
|
+
return _id === productId ? qnt + 1 : qnt
|
|
43
|
+
}, 0)
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
.catch(console.error)
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
} else {
|
|
51
|
+
if (ecomCart.data && ecomCart.data.items && ecomCart.data.items.length) {
|
|
52
|
+
ecomCart.data.items.forEach(({ _id, flags }) => {
|
|
53
|
+
if (flags && flags.includes('freebie')) {
|
|
54
|
+
ecomCart.removeItem(_id)
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
19
61
|
export default {
|
|
20
62
|
name: 'DiscountApplier',
|
|
21
63
|
|
|
@@ -33,13 +75,20 @@ export default {
|
|
|
33
75
|
isFormAlwaysVisible: Boolean,
|
|
34
76
|
isCouponApplied: Boolean,
|
|
35
77
|
isAttentionWanted: Boolean,
|
|
78
|
+
canAddFreebieItems: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: true
|
|
81
|
+
},
|
|
36
82
|
modulesPayload: Object,
|
|
83
|
+
paymentGateway: Object,
|
|
37
84
|
ecomCart: {
|
|
38
85
|
type: Object,
|
|
39
86
|
default () {
|
|
40
87
|
return ecomCart
|
|
41
88
|
}
|
|
42
89
|
},
|
|
90
|
+
customer: Object,
|
|
91
|
+
canPassManyDiscountApps: Boolean,
|
|
43
92
|
ecomPassport: {
|
|
44
93
|
type: Object,
|
|
45
94
|
default () {
|
|
@@ -55,14 +104,16 @@ export default {
|
|
|
55
104
|
isFormVisible: this.isFormAlwaysVisible || this.couponCode,
|
|
56
105
|
isLoading: false,
|
|
57
106
|
localCouponCode: this.couponCode,
|
|
58
|
-
localAmountTotal:
|
|
59
|
-
localAmountDiscount: this.amount.discount || 0,
|
|
60
|
-
extraDiscountValue: 0,
|
|
107
|
+
localAmountTotal: null,
|
|
61
108
|
isUpdateSheduled: false
|
|
62
109
|
}
|
|
63
110
|
},
|
|
64
111
|
|
|
65
112
|
computed: {
|
|
113
|
+
i19add$1ToGetDiscountMsg: () => i18n({
|
|
114
|
+
en_us: 'Add more $1 to cart to get the discount.',
|
|
115
|
+
pt_br: 'Adicione mais $1 ao carrinho para ganhar o desconto.'
|
|
116
|
+
}),
|
|
66
117
|
i19add: () => i18n(i19add),
|
|
67
118
|
i19addDiscountCoupon: () => i18n(i19addDiscountCoupon),
|
|
68
119
|
i19code: () => i18n(i19code),
|
|
@@ -75,62 +126,137 @@ export default {
|
|
|
75
126
|
canAddCoupon () {
|
|
76
127
|
return !this.couponCode || !this.isCouponApplied ||
|
|
77
128
|
this.couponCode !== this.localCouponCode
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
paymentGatewayDiscount () {
|
|
132
|
+
if (!this.paymentGateway) return 0
|
|
133
|
+
const { discount } = this.paymentGateway
|
|
134
|
+
if (!discount || !discount.value) return 0
|
|
135
|
+
const applyAt = discount.apply_at || 'total'
|
|
136
|
+
const maxDiscount = applyAt === 'total' ? this.localAmountTotal : this.amount[applyAt]
|
|
137
|
+
if (maxDiscount > 0) {
|
|
138
|
+
const { type, value } = discount
|
|
139
|
+
if (type === 'percentage') {
|
|
140
|
+
return maxDiscount * value / 100
|
|
141
|
+
}
|
|
142
|
+
return value <= maxDiscount ? value : maxDiscount
|
|
143
|
+
}
|
|
144
|
+
return 0
|
|
78
145
|
}
|
|
79
146
|
},
|
|
80
147
|
|
|
81
148
|
methods: {
|
|
149
|
+
fixAmount () {
|
|
150
|
+
const amount = this.amount || {
|
|
151
|
+
subtotal: this.ecomCart.data.subtotal
|
|
152
|
+
}
|
|
153
|
+
this.localAmountTotal = Math.round(((amount.subtotal || 0) +
|
|
154
|
+
(amount.freight || 0) - this.paymentGatewayDiscount) * 100) / 100
|
|
155
|
+
},
|
|
156
|
+
|
|
82
157
|
parseDiscountOptions (listResult = []) {
|
|
83
|
-
|
|
158
|
+
let extraDiscountValue = 0
|
|
159
|
+
let hasFreebies = false
|
|
84
160
|
if (listResult.length) {
|
|
85
|
-
let discountRule, invalidCouponMsg
|
|
161
|
+
let discountRule, invalidCouponMsg, invalidAlertVariant
|
|
86
162
|
listResult.forEach(appResult => {
|
|
87
163
|
const { validated, error, response } = appResult
|
|
88
164
|
if (validated && !error) {
|
|
89
165
|
const appDiscountRule = response.discount_rule
|
|
90
166
|
if (appDiscountRule) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
167
|
+
if (!this.canPassManyDiscountApps) {
|
|
168
|
+
const discountRuleValue = appDiscountRule.extra_discount.value
|
|
169
|
+
if (!(extraDiscountValue > discountRuleValue)) {
|
|
170
|
+
extraDiscountValue = discountRuleValue
|
|
171
|
+
discountRule = {
|
|
172
|
+
app_id: appResult.app_id,
|
|
173
|
+
...appDiscountRule
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
if (extraDiscountValue) {
|
|
178
|
+
appDiscountRule.extra_discount.value += extraDiscountValue
|
|
179
|
+
discountRule = appDiscountRule
|
|
180
|
+
} else {
|
|
181
|
+
discountRule = {
|
|
182
|
+
app_id: appResult.app_id,
|
|
183
|
+
...appDiscountRule
|
|
184
|
+
}
|
|
97
185
|
}
|
|
186
|
+
extraDiscountValue = appDiscountRule.extra_discount.value
|
|
98
187
|
}
|
|
99
|
-
} else if (response.
|
|
188
|
+
} else if (response.available_extra_discount && response.available_extra_discount.min_amount) {
|
|
189
|
+
invalidCouponMsg = this.i19add$1ToGetDiscountMsg
|
|
190
|
+
.replace('$1', formatMoney(response.available_extra_discount.min_amount - this.amount.subtotal))
|
|
191
|
+
invalidAlertVariant = 'info'
|
|
192
|
+
}
|
|
193
|
+
if (response.invalid_coupon_message) {
|
|
100
194
|
invalidCouponMsg = response.invalid_coupon_message
|
|
101
195
|
}
|
|
196
|
+
if (this.canAddFreebieItems) {
|
|
197
|
+
const freebieProductIds = response.freebie_product_ids
|
|
198
|
+
if (Array.isArray(freebieProductIds) && freebieProductIds.length) {
|
|
199
|
+
hasFreebies = true
|
|
200
|
+
addFreebieItems(this.ecomCart, freebieProductIds)
|
|
201
|
+
if (this.localCouponCode) {
|
|
202
|
+
this.$emit('update:coupon-code', this.localCouponCode)
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
102
206
|
}
|
|
103
207
|
})
|
|
104
|
-
if (
|
|
208
|
+
if (extraDiscountValue) {
|
|
105
209
|
if (this.localCouponCode) {
|
|
106
|
-
|
|
107
|
-
|
|
210
|
+
if (invalidCouponMsg) {
|
|
211
|
+
this.alertText = invalidCouponMsg
|
|
212
|
+
this.alertVariant = invalidAlertVariant || 'warning'
|
|
213
|
+
} else {
|
|
214
|
+
this.$emit('update:coupon-code', this.localCouponCode)
|
|
215
|
+
this.alertText = this.i19couponAppliedMsg
|
|
216
|
+
this.alertVariant = 'info'
|
|
217
|
+
}
|
|
108
218
|
} else {
|
|
109
219
|
this.alertText = this.i19campaignAppliedMsg
|
|
220
|
+
this.alertVariant = 'info'
|
|
110
221
|
}
|
|
111
222
|
this.$emit('set-discount-rule', discountRule)
|
|
112
|
-
this.alertVariant = 'info'
|
|
113
223
|
} else {
|
|
114
|
-
if (this.localCouponCode) {
|
|
224
|
+
if (this.localCouponCode && !hasFreebies) {
|
|
115
225
|
this.alertText = invalidCouponMsg || this.i19invalidCouponMsg
|
|
116
|
-
this.alertVariant = 'warning'
|
|
226
|
+
this.alertVariant = invalidAlertVariant || 'warning'
|
|
227
|
+
} else {
|
|
228
|
+
this.alertText = null
|
|
117
229
|
}
|
|
118
230
|
this.$emit('set-discount-rule', {})
|
|
119
231
|
}
|
|
120
232
|
}
|
|
121
233
|
},
|
|
122
234
|
|
|
123
|
-
fetchDiscountOptions (data) {
|
|
235
|
+
fetchDiscountOptions (data = {}) {
|
|
124
236
|
this.isLoading = true
|
|
237
|
+
const customer = this.customer || this.ecomPassport.getCustomer()
|
|
238
|
+
if (customer && (customer._id || customer.doc_number)) {
|
|
239
|
+
data.customer = {}
|
|
240
|
+
if (customer._id) {
|
|
241
|
+
data.customer._id = customer._id
|
|
242
|
+
}
|
|
243
|
+
if (customer.display_name) {
|
|
244
|
+
data.customer.display_name = customer.display_name
|
|
245
|
+
}
|
|
246
|
+
if (customer.doc_number) {
|
|
247
|
+
data.customer.doc_number = customer.doc_number
|
|
248
|
+
}
|
|
249
|
+
}
|
|
125
250
|
modules({
|
|
126
251
|
url: '/apply_discount.json',
|
|
127
252
|
method: 'POST',
|
|
128
253
|
data: {
|
|
129
254
|
...this.modulesPayload,
|
|
130
255
|
amount: {
|
|
256
|
+
subtotal: this.localAmountTotal,
|
|
131
257
|
...this.amount,
|
|
132
258
|
total: this.localAmountTotal,
|
|
133
|
-
discount: this.
|
|
259
|
+
discount: Math.round(this.paymentGatewayDiscount * 100) / 100
|
|
134
260
|
},
|
|
135
261
|
items: this.ecomCart.data.items,
|
|
136
262
|
...data
|
|
@@ -153,15 +279,6 @@ export default {
|
|
|
153
279
|
const data = {
|
|
154
280
|
discount_coupon: localCouponCode
|
|
155
281
|
}
|
|
156
|
-
if (this.ecomPassport.checkLogin()) {
|
|
157
|
-
const customer = this.ecomPassport.getCustomer()
|
|
158
|
-
data.customer = {
|
|
159
|
-
_id: customer._id
|
|
160
|
-
}
|
|
161
|
-
if (customer.display_name) {
|
|
162
|
-
data.customer.display_name = customer.display_name
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
282
|
this.fetchDiscountOptions(data)
|
|
166
283
|
}
|
|
167
284
|
},
|
|
@@ -171,15 +288,29 @@ export default {
|
|
|
171
288
|
if (isForceUpdate || !this.isCouponApplied) {
|
|
172
289
|
this.submitCoupon(isForceUpdate)
|
|
173
290
|
}
|
|
174
|
-
} else if (
|
|
291
|
+
} else if (
|
|
292
|
+
isForceUpdate ||
|
|
293
|
+
(!this.isUpdateSheduled && this.amount && this.localAmountTotal)
|
|
294
|
+
) {
|
|
175
295
|
this.fetchDiscountOptions()
|
|
176
296
|
}
|
|
297
|
+
},
|
|
298
|
+
|
|
299
|
+
scheduleUpdateDiscount () {
|
|
300
|
+
if (this.isUpdateSheduled) return
|
|
301
|
+
this.isUpdateSheduled = true
|
|
302
|
+
this.$nextTick(() => {
|
|
303
|
+
setTimeout(() => {
|
|
304
|
+
this.updateDiscount()
|
|
305
|
+
this.isUpdateSheduled = false
|
|
306
|
+
}, 600)
|
|
307
|
+
})
|
|
177
308
|
}
|
|
178
309
|
},
|
|
179
310
|
|
|
180
311
|
watch: {
|
|
181
312
|
couponCode (couponCode) {
|
|
182
|
-
if (couponCode !== this.
|
|
313
|
+
if (couponCode !== this.localCouponCode) {
|
|
183
314
|
this.localCouponCode = couponCode
|
|
184
315
|
if (couponCode && !this.isFormVisible) {
|
|
185
316
|
this.isFormVisible = true
|
|
@@ -187,6 +318,12 @@ export default {
|
|
|
187
318
|
}
|
|
188
319
|
},
|
|
189
320
|
|
|
321
|
+
localCouponCode () {
|
|
322
|
+
if (this.alertVariant === 'info') {
|
|
323
|
+
this.alertText = null
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
|
|
190
327
|
isFormAlwaysVisible (isFormVisible) {
|
|
191
328
|
if (isFormVisible) {
|
|
192
329
|
this.isFormVisible = true
|
|
@@ -201,32 +338,26 @@ export default {
|
|
|
201
338
|
}
|
|
202
339
|
},
|
|
203
340
|
|
|
204
|
-
localAmountTotal () {
|
|
205
|
-
if (
|
|
206
|
-
this.
|
|
207
|
-
this.$nextTick(() => {
|
|
208
|
-
setTimeout(() => {
|
|
209
|
-
this.updateDiscount()
|
|
210
|
-
this.isUpdateSheduled = false
|
|
211
|
-
}, 150)
|
|
212
|
-
})
|
|
341
|
+
localAmountTotal (total, oldTotal) {
|
|
342
|
+
if (oldTotal !== null && Math.abs(total - oldTotal) > 0.02) {
|
|
343
|
+
this.scheduleUpdateDiscount()
|
|
213
344
|
}
|
|
214
345
|
},
|
|
215
346
|
|
|
216
347
|
amount: {
|
|
217
|
-
handler (
|
|
218
|
-
|
|
219
|
-
this.localAmountDiscount = discountDiff > 0.01 ? discountDiff : 0
|
|
220
|
-
const fixedTotal = amount.total + this.extraDiscountValue
|
|
221
|
-
if (Math.abs(fixedTotal - this.localAmountTotal) > 0.01) {
|
|
222
|
-
this.localAmountTotal = fixedTotal
|
|
223
|
-
}
|
|
348
|
+
handler () {
|
|
349
|
+
this.fixAmount()
|
|
224
350
|
},
|
|
225
351
|
deep: true
|
|
352
|
+
},
|
|
353
|
+
|
|
354
|
+
paymentGatewayDiscount () {
|
|
355
|
+
this.scheduleUpdateDiscount()
|
|
226
356
|
}
|
|
227
357
|
},
|
|
228
358
|
|
|
229
|
-
|
|
359
|
+
mounted () {
|
|
360
|
+
this.fixAmount()
|
|
230
361
|
this.updateDiscount(false)
|
|
231
362
|
}
|
|
232
363
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
i19add$1ToEarn,
|
|
3
|
+
i19loyaltyPoints
|
|
4
|
+
} from '@ecomplus/i18n'
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
i18n,
|
|
8
|
+
formatMoney
|
|
9
|
+
} from '@ecomplus/utils'
|
|
10
|
+
|
|
11
|
+
import waitStorefrontInfo from './helpers/wait-storefront-info'
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
name: 'EarnPointsProgress',
|
|
15
|
+
|
|
16
|
+
props: {
|
|
17
|
+
pointsPrograms: Object,
|
|
18
|
+
cartSubtotal: {
|
|
19
|
+
type: Number,
|
|
20
|
+
required: true
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
data () {
|
|
25
|
+
return {
|
|
26
|
+
localPointsPrograms: this.pointsPrograms,
|
|
27
|
+
programName: ''
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
computed: {
|
|
32
|
+
i19add$1ToEarn: () => i18n(i19add$1ToEarn),
|
|
33
|
+
i19loyaltyPoints: () => i18n(i19loyaltyPoints),
|
|
34
|
+
|
|
35
|
+
minSubtotalToEarn () {
|
|
36
|
+
let minSubtotal
|
|
37
|
+
const pointsPrograms = this.localPointsPrograms
|
|
38
|
+
if (pointsPrograms) {
|
|
39
|
+
for (const programId in pointsPrograms) {
|
|
40
|
+
const pointsProgram = pointsPrograms[programId]
|
|
41
|
+
const programMinSubtotal = pointsProgram && pointsProgram.min_subtotal_to_earn
|
|
42
|
+
if (
|
|
43
|
+
programMinSubtotal >= 0 &&
|
|
44
|
+
(minSubtotal === undefined || minSubtotal > programMinSubtotal)
|
|
45
|
+
) {
|
|
46
|
+
minSubtotal = programMinSubtotal
|
|
47
|
+
this.programName = pointsProgram.name
|
|
48
|
+
if (!minSubtotal) {
|
|
49
|
+
break
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return minSubtotal
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
earnFromPercentage () {
|
|
58
|
+
return this.minSubtotalToEarn >= 0 && this.cartSubtotal < this.minSubtotalToEarn
|
|
59
|
+
? Math.round(this.cartSubtotal * 100 / this.minSubtotalToEarn)
|
|
60
|
+
: null
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
methods: {
|
|
65
|
+
formatMoney
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
created () {
|
|
69
|
+
if (!this.pointsPrograms || !Object.keys(this.pointsPrograms).length) {
|
|
70
|
+
waitStorefrontInfo('list_payments', 'loyalty_points_programs')
|
|
71
|
+
.then(pointsPrograms => {
|
|
72
|
+
this.localPointsPrograms = pointsPrograms
|
|
73
|
+
this.$emit('update:points-programs', pointsPrograms)
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
package/src/js/InputDate.js
CHANGED
|
@@ -36,15 +36,15 @@ export default {
|
|
|
36
36
|
cleaveOptions () {
|
|
37
37
|
return countryCode === 'BR'
|
|
38
38
|
? {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
date: true,
|
|
40
|
+
delimiter: '/',
|
|
41
|
+
datePattern: ['d', 'm', 'Y']
|
|
42
|
+
}
|
|
43
43
|
: {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
date: true,
|
|
45
|
+
delimiter: '-',
|
|
46
|
+
datePattern: ['Y', 'm', 'd']
|
|
47
|
+
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
package/src/js/InputDocNumber.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { i19docNumber } from '@ecomplus/i18n'
|
|
2
2
|
import { $ecomConfig, i18n } from '@ecomplus/utils'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
isValidCPF as validateCPF,
|
|
6
|
+
isValidCNPJ as validateCNPJ
|
|
7
|
+
} from '@brazilian-utils/brazilian-utils'
|
|
8
|
+
|
|
3
9
|
import CleaveInput from 'vue-cleave-component'
|
|
4
10
|
|
|
5
11
|
const countryCode = $ecomConfig.get('country_code')
|
|
@@ -39,6 +45,20 @@ export default {
|
|
|
39
45
|
return '[\\d]+{9,19}'
|
|
40
46
|
},
|
|
41
47
|
|
|
48
|
+
isInvalid () {
|
|
49
|
+
if (countryCode === 'BR') {
|
|
50
|
+
const docNumber = this.localValue.toString().replace(/D/g, '')
|
|
51
|
+
if (this.isCompany) {
|
|
52
|
+
if (docNumber.length === 14) {
|
|
53
|
+
return !validateCNPJ(this.localValue)
|
|
54
|
+
}
|
|
55
|
+
} else if (docNumber.length === 11) {
|
|
56
|
+
return !validateCPF(this.localValue)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return false
|
|
60
|
+
},
|
|
61
|
+
|
|
42
62
|
localValue: {
|
|
43
63
|
get () {
|
|
44
64
|
return this.value
|